Taking the max/min of two columns in PostgreSQL

As part of a database view, I found myself wanting to get Postgres to display values from one of two columns, whichever was the largest.

My first attempt was:

SELECT id, MAX(column1, column2) FROM table1;

which of course didn't work because MAX() is an aggregate function which only takes a single parameter.

What I was looking for instead, is something that was introduced in 8.1:

SELECT id, GREATEST(column1, column2) FROM table1;

where GREATEST() (and its opposite: LEAST()) is a conditional expression.

Manipulating debconf settings on the command line

It's not very easy to find information on how to adjust debconf settings after a package has been installed and configured. Most of the information out there is for Debian developers wanting to add support for debconf in their maintainer scripts.

I ran into the problem of being unable to change a package's configuration options through dpkg-reconfigure and I found the following commands to do it manually:

debconf-show packagename

to show the list of debconf values that a package has stored,

echo "get packagename/pgsql/app-pass" | debconf-communicate

to query the current value of an option in the debconf database, and

echo "set packagename/pgsql/app-pass password1" | debconf-communicate

to change that value.

I'm not convinced that this is the easiest way for system administrators to manually lookup and modify debconf options, but that's the best I could find at the time.