Hi, I see that you pushed this patch. I'm unfortunately unhappy with the approach taken. As previously said, handling a lot of this from exec_* is a mistake in my opinion. Pretty much the same problem exists for parametrized query execution from other contexts, e.g. for queries executed inside plpgsql. By putting the responsibility to manage error contexts etc from with exec_*, we'd need to add a copy of that to pretty much every place executing queries. This should all be in the portal code, with an optimization for computing the parameter values from strings inside postgres.c, when the input is text.
Greetings, Andres Freund