Re: BUG #16519: SET SESSION ROLE in plpgsql requires string literal. - Mailing list pgsql-bugs

From David G. Johnston
Subject Re: BUG #16519: SET SESSION ROLE in plpgsql requires string literal.
Date
Msg-id CAKFQuwZByEvyM9KUtRn0yjT81dGuVaFKpHzBjhVsEAd7WPgasA@mail.gmail.com
Whole thread Raw
In response to BUG #16519: SET SESSION ROLE in plpgsql requires string literal.  (PG Bug reporting form <noreply@postgresql.org>)
Responses Re: BUG #16519: SET SESSION ROLE in plpgsql requires string literal.  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
On Tuesday, June 30, 2020, PG Bug reporting form <noreply@postgresql.org> wrote:
The following bug has been logged on the website:

Bug reference:      16519
Logged by:          Marianne B. Wiese
Email address:      mbwiese@gmail.com
PostgreSQL version: 10.12
Operating system:   Ubuntu 18.04
Description:       

However, the loop in below function gives me an error:
[22023] ERROR: role "inuser" does not exist Where: SQL statement "SET
SESSION ROLE TO InUser" PL/pgSQL function change_user(name) line 8 at SQL
statement.

                    SET SESSION ROLE TO InUser;


The SET command cannot be parameterized so using variables in the statement is not supported and the attempt to do so is treated as writing an identifier.  You will need to use the format function and the execute plpgsql command to create and execute the statement.

David J.

pgsql-bugs by date:

Previous
From: Michael Meskes
Date:
Subject: Re: [BUG][PATCH] ecpg crash with bytea type and cursors
Next
From: Jehan-Guillaume de Rorthais
Date:
Subject: Re: [BUG][PATCH] ecpg crash with bytea type and cursors