Can't check it right now, but since you're at 9.1, you can try:
DO $$ BEGIN execute 'alter database '||current_database()||' set some_var = ''0'''; END; $$
You may need to select current_database () in a variable to make it work.
a_horse_with_no_name
source share