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 1ld5yf-00030w-OO for pgsql-bugs@arkaria.postgresql.org; Sun, 02 May 2021 06:53:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ld5yd-0003m2-K0 for pgsql-bugs@arkaria.postgresql.org; Sun, 02 May 2021 06:53:15 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ld5yd-0003lv-Bh for pgsql-bugs@lists.postgresql.org; Sun, 02 May 2021 06:53:15 +0000 Received: from mout.gmx.net ([212.227.15.15]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ld5yW-0005nP-T0 for pgsql-bugs@lists.postgresql.org; Sun, 02 May 2021 06:53:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1619938385; bh=4T0kQI4VdVVe0b4wNk3QLhLAFUtQZD7tm2spM1tIIHk=; h=X-UI-Sender-Class:Subject:To:Cc:References:From:Date:In-Reply-To; b=SaQ/uNQ89AFdgj+rfYWnj/h66VQxR5omqbSHT8YCaI5ko7GmoEMcH9O6aY7m4SIDe esKKNz4EiMPN2hU0G8BPMQMaWyqZ02lmrosTrplGshN7+KXqgdqX3Zs/y4HjnX5OMF kSz5eKZAKc7EiFi7W0yk86VI8ASjSQ8YtAUzTFZ8= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.178.42] ([91.64.91.78]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MCbIn-1llepW1dtz-009gjy; Sun, 02 May 2021 08:53:05 +0200 Subject: Re: BUG #16988: Spurious "SET LOCAL can only be used in transaction blocks" warning using implicit transaction block To: Tom Lane Cc: mike.adelson314@gmail.com, pgsql-bugs@lists.postgresql.org References: <16988-58edba102adb5128@postgresql.org> <3044772.1619712195@sss.pgh.pa.us> <3a158f8d-708e-ad13-617a-af8349aae4f4@gmx.de> <3493686.1619912155@sss.pgh.pa.us> From: Brar Piening Message-ID: Date: Sun, 2 May 2021 08:53:02 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: <3493686.1619912155@sss.pgh.pa.us> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Content-Language: de-DE X-Provags-ID: V03:K1:6w1hrXi+TfgebJoXRQoL3XgwbGo2JDhxiMMBrdfubV0bt6UazrV gpYfRfzA2Rzw9X3WQAuYBB5+AiV+/Mx8yDmOet7BMds3b1gwEBCN81I9AqRZpjtOsWd0kRR j7uzLIEPiStbIEkmOpNr4sWjtjrJTKooltCOqbmhPtwodMeHxxoGdQocPvRu4InyeAWgXfo f/+DXg9Vy48s5VwD9HlXQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:2h2qheSFbdg=:9uPYzkvbxUMr7tHPk/LLH4 MLbmWiOaJ2ApUjbdNpZLjBjC2SwOkSKndtU7JuS+wQqbbo12bys1+PVLxpJazvclLJTViF+vA J6E+V3hEXC/AIFscTmLw+xPD5pXNgLj+iVbphR98huP0SWoaAXR9NeuJKofyPrgt1T7WoLJKu rzN3d00BNAlk1Nj5pp8KShGa13Ancd0Iqv7dKID7aziQnM8Dhi3oNelaKrEAe2BFcf6dX25NO l0wfL/UFM7mGYRU32JlJ9bg/4cwDtzV+SGkRu1wYEOfzDHxUs+iOXc+LcrUfYVZppuo3h0kf0 UfDufGQ5HCDq7zPSq9U6VlThUSnN/fdl0BKpPj03s2CCUPGND4EYnmBNSqCpJa4SUfk0m6ul9 Z+79jabYSe5yb0aQ9Dylahts96BAImwvUT/QyvTiWoOVeeEdo7+x4ljZFKjNfNLSX1hSyfl6a TeMFcuEXLr2CiPuLHIuL98+ALBiEruBktJdgzn+chAgQfAxyBgQnPp3SEsLeKitoZmslir+3v gCbtuGp2v4pdCJy6xSxfJ50Ci/NiaZavuuCWG+8OooHt/HDjl/f8w+QuwPyBXPir6FFlSGV6V LiaNz1ownb8zWs/OqaVwgdtskUR3kATxPTMfUHMvIA1xHb/IXg4SCVdK6E8+FJhND9XbB6pTh bVZi7TtWD8C07NMjWYB3ogAXFFimGONpWIlADXg6/uAFKdwLal6bggIDXK+cuwQqpVMZqsmt4 1D0y3rdFLDMDOo/T6Zst+Dm9nDg169igztC5c7vKX2mOexKvL9mgh2gIjM3aVO1LBITa3g3IP 0V6yspT1yr+da02Ca/rkpa9VIrhn0wl6nvfcmLwd+ug3mMHleWwzebhSFEPE6SliecN7V/lyZ P72eU/YOi1QPbYgTHK1M5DyNPwnegpeMUI2lpSehfIVRBJiFFjb4Vn/tu2e5FfFeExERgR30O f3MDvtvSPjY7XYj6RrMo8r299C//bJJX1ck3eWMsDjRlXulTdunm4TS5ZhoD0TiaMZiPs3E6S zVBjoeeqpnvNg+6FtuEx6M61+AbZxM2On7DJMI7B2k0ZbM2/VqZlH/niwUmnR3yh/au9P8gDw NvAg/Psq0WH2TLOeYCFeX1hnwf2e3yv1J6Z8kR+XSbWquCmg1ecP6VmFbz8fH3fugG2Q7H3Dx 7Wl0ZdiFwB3pP1vylBT0wsb1SOXUmKGBWww1nG97JnWkdXEahYpo8r5QnnF2HErPJfNiU= List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Tom Lane schrieb: > Brar Piening writes: >> At the wire protocol level npgsql sends this as two queries via the >> extended query protocol without a sync inbetween them. >> (Parse,Bind,Describe,Execute;Parse,Bind,Describe,Execute,Sync) > There is no implicit transaction block around the two commands in such > a case, so that explains why it doesn't act as Mike was hoping. > > Omitting the Sync has zero effect on transactional semantics; it only > means that if the first command fails, we'll skip the second one. I think what Mike is wondering about (and I am too)=C2=A0 is the fat that Sync seems to have *partial* effect on transactional semantics. The libpq program I showed above outputs the following: WARNING:=C2=A0 SET LOCAL can only be used in transaction blocks 100kB So it produes the same tuple as If I had written 'PQexec(conn, "SET LOCAL work_mem =3D 100;show work_mem;");' but with the additional warning. I can reproduce the behavior of the sequence 'PQexec(conn, "SET LOCAL work_mem =3D 100;");/*PQclear,...*/PQexec(conn, "show work_mem;");' by introducing a Sync between the two commands in extended query protocol with pipelining mode like the following: int main(int argc, char **argv) { =C2=A0=C2=A0=C2=A0 PGconn* conn; =C2=A0=C2=A0=C2=A0 PGresult* res; =C2=A0=C2=A0=C2=A0 conn =3D PQconnectdb(""); =C2=A0=C2=A0=C2=A0 PQenterPipelineMode(conn); =C2=A0=C2=A0=C2=A0 PQsendQueryParams(conn, "SET LOCAL work_mem =3D 100;",= 0, NULL, NULL, NULL, NULL, 1); =C2=A0=C2=A0=C2=A0 PQpipelineSync(conn); =C2=A0=C2=A0=C2=A0 PQsendQueryParams(conn, "SHOW work_mem;", 0, NULL, NUL= L, NULL, NULL, 1); =C2=A0=C2=A0=C2=A0 PQpipelineSync(conn); =C2=A0=C2=A0=C2=A0 res =3D PQgetResult(conn); // SET LOCAL =3D> PGRES_COM= MAND_OK =C2=A0=C2=A0=C2=A0 PQclear(res); =C2=A0=C2=A0=C2=A0 PQgetResult(conn); // NULL =C2=A0=C2=A0=C2=A0 res =3D PQgetResult(conn); // PGRES_PIPELINE_SYNC =C2=A0=C2=A0=C2=A0 PQclear(res); =C2=A0=C2=A0=C2=A0 res =3D PQgetResult(conn); // SHOW =3D> PGRES_TUPLES_O= K =C2=A0=C2=A0=C2=A0 fprintf(stdout, "%s\n", PQgetvalue(res, 0, 0)); =C2=A0=C2=A0=C2=A0 PQclear(res); =C2=A0=C2=A0=C2=A0 PQgetResult(conn); // NULL =C2=A0=C2=A0=C2=A0 res =3D PQgetResult(conn); // PGRES_PIPELINE_SYNC =C2=A0=C2=A0=C2=A0 PQclear(res); =C2=A0=C2=A0=C2=A0 PQfinish(conn); =C2=A0=C2=A0=C2=A0 return 0; } This returns: WARNING:=C2=A0 SET LOCAL can only be used in transaction blocks 4MB Which is not surprising at all and completely what I'd expect. What's strange though, is that omitting the sync between the commands changes the result and not the warning. So zero effect is not how omitting the sync between two commands in extended query protocol actually works. It has an effect on the scope of 'SET LOCAL' but it suggests otherwise because doesn't suppress the warning. Regards, Brar