And here's a patch to add savepoint protection for tab completion. It could definitely use some scrutiny to make sure it's not messing up the user's transaction.
I added some error checking for the savepoint creation and the rollback, and then wrapped it in #ifdef NOT_USED (just as the query error checking is) as I wasn't sure how useful it is for normal use. But I do feel that if psql unexpectedly messes up the transaction, it should report it somehow. How can we tell that we've messed it up for the user? Cheers, Edmund
psql-tab-completion-savepoint-v1.patch
Description: Binary data