From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-hackers(at)postgreSQL(dot)org |
Subject: | Unnecessary complexity around CurrentResourceOwner changes? |
Date: | 2017-10-09 16:58:43 |
Message-ID: | 19645.1507568323@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
We have some dozens of places that transiently change CurrentResourceOwner
and then set it back to what it had been. I happened to notice that,
while many of these places have a PG_TRY block to ensure that the restore
happens even if they lose control to an error, not all of them have one.
My initial reaction was that the latter were buggy, since resowner/README
says you should do it with a PG_TRY. On further reflection, though, why
are we paying the rather high price of a PG_TRY block for that? ISTM that
CurrentResourceOwner is much like CurrentMemoryContext, and we certainly
don't worry about protecting transient changes of CurrentMemoryContext
this way. The reason it's safe not to is that the first step in
transaction or subtransaction abort is to reset CurrentMemoryContext to
something sane. But the second step is to reset CurrentResourceOwner
to something sane, so it seems like we have that base covered.
So my inclination is to change the advice in resowner/README and rip out
all the PG_TRY blocks that are used only to force restore of
CurrentResourceOwner. (We might as well leave the code alone in places
where the PG_TRY has to do other things too.)
Thoughts?
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | legrand legrand | 2017-10-09 20:03:09 | Columnar storage support |
Previous Message | Andrey Borodin | 2017-10-09 16:54:17 | Re: On markers of changed data |