Fixed up the apm parameter stuff to the point where I can at least
register and unregister, and cache values of, global parameters. There's
some really funky code here, I also took the time to have the unregister
code use the unregister API in PL/[pg]SQL rather than roll its own.