Here is a patch for the following construct, specified in the SQL
standard:
collation for (expr)
returns the collation of the argument. It's similar to pg_typeof.
The SQL standard is not clear on the exact format of the return value.
I went with what ruleutils.c produces, which is useful for human
inspection and also for plugging back into SQL statements.