Re: BUG #16988: Spurious "SET LOCAL can only be used in transaction blocks" warning using implicit transaction block

From: Brar Piening <brar(at)gmx(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, mike(dot)adelson314(at)gmail(dot)com
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #16988: Spurious "SET LOCAL can only be used in transaction blocks" warning using implicit transaction block
Date: 2021-05-01 22:22:44
Message-ID: 3a158f8d-708e-ad13-617a-af8349aae4f4@gmx.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Tom Lane wrote:
> PG Bug reporting form <noreply(at)postgresql(dot)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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2021-05-01 23:35:55 Re: BUG #16988: Spurious "SET LOCAL can only be used in transaction blocks" warning using implicit transaction block
Previous Message Bruce Momjian 2021-05-01 14:55:41 Re: BUG #16939: Plural interval for negative singular