Ticket 20392

This is not ready to merge yet as some changes should be discussed first.

Also, I couldn't run the whole test suite under Oracle with a single db, let's see what happens here...