When setting the default client_encoding for another database the validity
of the conversion is checked using the current database's server encoding,
not the targets.
jurka=# create database utf8 with encoding='utf8';
CREATE DATABASE
jurka=# create database win1251 with encoding='win1251';
CREATE DATABASE
jurka=# \c utf8
You are now connected to database "utf8".
utf8=# alter database win1251 set client_encoding to 'mule_internal';
ERROR: conversion between mule_internal and UTF8 is not supported
utf8=# alter database win1251 set client_encoding to 'latin1';
ALTER DATABASE
utf8=# \c win1251
FATAL: conversion between LATIN1 and WIN1251 is not supported
Previous connection kept
Kris Jurka