pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Brar Piening <brar@gmx.de>
To: Tom Lane <tgl@sss.pgh.pa.us>
To: mike.adelson314@gmail.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #16988: Spurious "SET LOCAL can only be used in transaction blocks" warning using implicit transaction block
Date: Sun, 2 May 2021 00:22:44 +0200
Message-ID: <3a158f8d-708e-ad13-617a-af8349aae4f4@gmx.de> (raw)
In-Reply-To: <3044772.1619712195@sss.pgh.pa.us>
References: <16988-58edba102adb5128@postgresql.org>
	<3044772.1619712195@sss.pgh.pa.us>

Tom Lane wrote:
> PG Bug reporting form <noreply@postgresql.org> writes:
>> I am using SET LOCAL in an Npgsql multi-statement command.
> It seems that whatever Npgsql is doing at the wire protocol level
> doesn't match this, but they'd have to explain what they are doing
> for us to offer much help.
>
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)

You can use the following short libpq program to reproduce it in PG14
(for brevity I've omitted any error checking):

#include  <libpq-fe.h>

int
main(int  argc,char  **argv)
{
     PGconn* conn;
     PGresult* res;

     conn =PQconnectdb("");
     PQenterPipelineMode(conn);
     PQsendQueryParams(conn,"SET LOCAL work_mem = 100;",0,NULL,NULL,NULL,NULL,1);
     PQsendQueryParams(conn,"SHOW work_mem;",0,NULL,NULL,NULL,NULL,1);
     PQpipelineSync(conn);
     res =PQgetResult(conn);// SET LOCAL => PGRES_COMMAND_OK
     PQclear(res);
     PQgetResult(conn);// NULL
     res =PQgetResult(conn);// SHOW => PGRES_TUPLES_OK
     fprintf(stdout,"%s\n",PQgetvalue(res,0,0));
     PQclear(res);
     PQgetResult(conn);// NULL
     res =PQgetResult(conn);// PGRES_PIPELINE_SYNC
     PQclear(res);
     PQfinish(conn);
     return  0;
}

Regards,
Brar







view thread (5+ messages)  latest in thread

Message-ID: <3a158f8d-708e-ad13-617a-af8349aae4f4@gmx.de>
Permalink:  ../3a158f8d-708e-ad13-617a-af8349aae4f4@gmx.de/
Also on:    postgresql.org/message-id/3a158f8d-708e-ad13-617a-af8349aae4f4@gmx.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: brar@gmx.de, tgl@sss.pgh.pa.us, mike.adelson314@gmail.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #16988: Spurious "SET LOCAL can only be used in transaction blocks" warning using implicit transaction block
  In-Reply-To: <3a158f8d-708e-ad13-617a-af8349aae4f4@gmx.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox