First of all: amazing work, as usual. This is clearly something that should be done. The only misgivings I have stem from a mistrust of pre-processor macros that's probably just because I haven't really used them at the level that you're using them in this patch. I'll need to level up a bit in the next few days to understand what you're doing.
Also, do you have a feeling for how portable these changes are? Are they specific to gcc, or are they reasonable to expect in any environment?
Thank you for reviewing! Haha, it's just plain C89, nothing fancy, only multi-pass text substitution. I've just verified that it works with Visual-C++ 2008. Linked against libpq, but without Ruby.
To be honest it was only a try, how far I can come with the preprocessor. But it turned out, that it works quite straightforward (apart maybe from the special treatment of the last function param) and it's reasonably self-explanatory. A code generator written in ruby would be far more flexible, but in this case I don't think it is necessary.