pg_indent'ing all files…
completely avoid usage of strnlen()
avoid usage of snprintf()

We have a nice little abstraction for snprintf with covering the case
that a string is too big for the target buffer – let's use that!
rather big refactoring: use a naming scheme

In the past naming of functions, variables and such didn't really have a
naming scheme. Now they should have.
removed no-longer used variable
no longer use global variable for SQL query buffer
removed old comment