[sent this a few days ago, must have gotten lost in "moderation" because
of the original subject]
With the latest master branch:
initdb -D somewhere --locale=C --encoding=LATIN1
Then in psql:
set client_encoding to utf8;
causes a segfault in the backend. The backtrace:
#0 SetClientEncoding (encoding=6) at mbutils.c:227
#1 0x081de584 in assign_client_encoding (newval=0x90f3a70 "UTF8", extra=0x90f3980) at variable.c:822
#2 0x083af296 in set_config_option (name=0x916f640 "client_encoding", value=0x9193d9c "utf8", context=PGC_SUSET,
source=PGC_S_SESSION, action=GUC_ACTION_SET, changeVal=1 '\001') at guc.c:5633
#3 0x083b0f4b in ExecSetVariableStmt (stmt=0x916f6bc) at guc.c:6066
#4 0x082cf758 in PortalRunUtility (portal=0x9191d94, utilityStmt=0x916f6bc, isTopLevel=1 '\001', dest=0x916f890,
completionTag=0xff89e2f4"") at pquery.c:1184
#5 0x082d02de in PortalRunMulti (portal=0x9191d94, isTopLevel=1 '\001', dest=0x916f890, altdest=0x916f890,
completionTag=0xff89e2f4"") at pquery.c:1322
#6 0x082d11b4 in PortalRun (portal=0x9191d94, count=2147483647, isTopLevel=1 '\001', dest=0x916f890,
altdest=0x916f890, completionTag=0xff89e2f4 "") at pquery.c:813
#7 0x082ccb45 in exec_simple_query (argc=2, argv=0x90f4410, username=0x90f4258 "peter") at postgres.c:1018
#8 PostgresMain (argc=2, argv=0x90f4410, username=0x90f4258 "peter") at postgres.c:3919
#9 0x08282c1e in BackendRun (port=0x9110670) at postmaster.c:3590
#10 BackendStartup (port=0x9110670) at postmaster.c:3275
#11 0x0828331a in ServerLoop () at postmaster.c:1449
#12 0x08283e59 in PostmasterMain (argc=3, argv=0x90f2f60) at postmaster.c:1110
#13 0x0821bae0 in main (argc=3, argv=0x90f2f60) at main.c:199
Looks like the conversion table is accessed before it's initialized.