Viktor Dukhovni: > On Tue, Feb 22, 2022 at 01:41:00PM -0800, Nathan Van Ymeren wrote: > > > I have enabled UTF8 in postfix as per the instructions here: > > http://www.postfix.org/SMTPUTF8_README.html#enabling , which you can > > see in the following config info: > > This enables UTF8 in SMTP, but does not presently affect the PgSQL > driver: > > src/global/dict_pgsql.c: > ... > #ifdef SNAPSHOT
There are two #ifdef SNAPSHOT blocks. - The one in dict_pgsql_lookup() returns not found when SMTPUTF8 is enabled, but a query is not valid UTF8. - The one in plpgsql_connect_single() sets the PgSQL client encoding to UTF8, and if SNAPSHOT is not defined, leaves it at LATIN1 encoding which is what was used historically. How do we avoid unexpected breakages in a stable release? I suggest that we leave the encoding at LATIN1 when SMTPUTF8 is disabled. That is historical behavior and that minimizes the risk of breakages. We can then use the UTF8 encoding when SMTPUTF8 is enabled. It is the only encoding that makes sense with SMTPUTF8. And we can ruminiate about what encoding should be used when SMTPUTF8 is disabled. There is no urgent need to change that now in a stable release. Wietse Classical diff, for readability. *** ./src/global/dict_pgsql.c- 2018-08-27 17:54:59.000000000 -0400 --- ./src/global/dict_pgsql.c 2022-02-22 19:03:57.858998431 -0500 *************** *** 348,354 **** /* * Don't frustrate future attempts to make Postfix UTF-8 transparent. */ - #ifdef SNAPSHOT if ((dict->flags & DICT_FLAG_UTF8_ACTIVE) == 0 && !valid_utf8_string(name, strlen(name))) { if (msg_verbose) --- 348,353 ---- *************** *** 356,362 **** myname, dict_pgsql->parser->name, name); return (0); } - #endif /* * Optionally fold the key. --- 355,360 ---- *************** *** 659,685 **** /* * The only legitimate encodings for Internet mail are ASCII and UTF-8. */ ! #ifdef SNAPSHOT ! if (PQsetClientEncoding(host->db, "UTF8") != 0) { ! msg_warn("dict_pgsql: cannot set the encoding to UTF8, skipping %s", ! host->hostname); ! plpgsql_down_host(host); ! return; } - #else /* * XXX Postfix does not send multi-byte characters. The following piece * of code is an explicit statement of this fact, and the database server * should not accept multi-byte information after this point. */ ! if (PQsetClientEncoding(host->db, "LATIN1") != 0) { ! msg_warn("dict_pgsql: cannot set the encoding to LATIN1, skipping %s", ! host->hostname); ! plpgsql_down_host(host); ! return; } - #endif /* Success. */ host->stat = STATACTIVE; } --- 657,684 ---- /* * The only legitimate encodings for Internet mail are ASCII and UTF-8. */ ! if ((dict->flags & DICT_FLAG_UTF8_ACTIVE) != 0) { ! if (PQsetClientEncoding(host->db, "UTF8") != 0) { ! msg_warn("dict_pgsql: cannot set the encoding to UTF8, skipping %s", ! host->hostname); ! plpgsql_down_host(host); ! return; ! } } /* * XXX Postfix does not send multi-byte characters. The following piece * of code is an explicit statement of this fact, and the database server * should not accept multi-byte information after this point. */ ! else { ! if (PQsetClientEncoding(host->db, "LATIN1") != 0) { ! msg_warn("dict_pgsql: cannot set the encoding to LATIN1, skipping %s", ! host->hostname); ! plpgsql_down_host(host); ! return; ! } } /* Success. */ host->stat = STATACTIVE; }