Based on this answered question regarding pg-promise, when an existing connection/session is returned by request A to the pool and being re-used by a totally diff request B. Would pg-promise automatically do DISCARD so B won't see anything left by A? If not, can I issue it manually using pg-promise?
Thank you.
Would pg-promise automatically do
DISCARD
?
No.
Can I issue it manually using pg-promise?
Yes, but for individual queries it would do you no good, because those control connection by themselves, so you would not even know which session you are discarding.
I can see when this might be of use only inside a task
or tx
methods, but there you can easily add your own DISCARD
query at the end, if needed.
await db.task(async t => {
// do your things here...
// then run discard at the end, if needed:
await t.none('DISCARD $1:value', ['PLANS']);
});