Thanks Vinod, that answers a bunch of questions (like does playing rugby in your twenties ruin your short term memory in your thirties - apparently not too badly!).
The patch looks basically like a standalone solution to what I was asking about - I think that side by side with the 10-database-procs.tcl and database-init.tcl might answer entirely what I was looking for.
I think based on what Andrew said earlier that there might be a few niggling dependencies, but it doesn't seem as odious now that I see the code in question.