The problem was simply that wchar.c has an array indexed by server encoding
number. This puts the order back in sync. I don't haven't looked at the
surrounding code enough to know if there aren't more problems like this
lurking or if there's a way to fix it so it isn't such a pain to maintain.

Index: src/backend/utils/mb/wchar.c
===================================================================
RCS file: /home/stark/src/REPOSITORY/pgsql/src/backend/utils/mb/wchar.c,v
retrieving revision 1.64
diff -u -r1.64 wchar.c
--- src/backend/utils/mb/wchar.c        18 Sep 2007 17:41:17 -0000      1.64
+++ src/backend/utils/mb/wchar.c        15 Oct 2007 21:53:06 -0000
@@ -1315,6 +1315,7 @@
        {pg_euccn2wchar_with_len, pg_euccn_mblen, pg_euccn_dsplen, 
pg_euccn_verifier, 2},       /* 2; PG_EUC_CN */
        {pg_euckr2wchar_with_len, pg_euckr_mblen, pg_euckr_dsplen, 
pg_euckr_verifier, 3},       /* 3; PG_EUC_KR */
        {pg_euctw2wchar_with_len, pg_euctw_mblen, pg_euctw_dsplen, 
pg_euctw_verifier, 4},       /* 4; PG_EUC_TW */
+       {pg_eucjp2wchar_with_len, pg_eucjp_mblen, pg_eucjp_dsplen, 
pg_eucjp_verifier, 3},       /* 33; PG_EUC_JIS_2004 */
        {pg_utf2wchar_with_len, pg_utf_mblen, pg_utf_dsplen, pg_utf8_verifier, 
4},      /* 5; PG_UTF8 */
        {pg_mule2wchar_with_len, pg_mule_mblen, pg_mule_dsplen, 
pg_mule_verifier, 4},           /* 6; PG_MULE_INTERNAL */
        {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, 
pg_latin1_verifier, 1},           /* 7; PG_LATIN1 */
@@ -1343,13 +1344,12 @@
        {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, 
pg_latin1_verifier, 1},           /* 30; PG_WIN1254 */
        {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, 
pg_latin1_verifier, 1},           /* 31; PG_WIN1255 */
        {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, 
pg_latin1_verifier, 1},           /* 32; PG_WIN1257 */
-       {pg_eucjp2wchar_with_len, pg_eucjp_mblen, pg_eucjp_dsplen, 
pg_eucjp_verifier, 3},       /* 33; PG_EUC_JIS_2004 */
        {0, pg_sjis_mblen, pg_sjis_dsplen, pg_sjis_verifier, 2},        /* 34; 
PG_SJIS */
        {0, pg_big5_mblen, pg_big5_dsplen, pg_big5_verifier, 2},        /* 35; 
PG_BIG5 */
        {0, pg_gbk_mblen, pg_gbk_dsplen, pg_gbk_verifier, 2},           /* 36; 
PG_GBK */
        {0, pg_uhc_mblen, pg_uhc_dsplen, pg_uhc_verifier, 2},           /* 37; 
PG_UHC */
-       {pg_johab2wchar_with_len, pg_johab_mblen, pg_johab_dsplen, 
pg_johab_verifier, 3},       /* 38; PG_JOHAB */
        {0, pg_gb18030_mblen, pg_gb18030_dsplen, pg_gb18030_verifier, 4},       
/* 39; PG_GB18030 */
+       {pg_johab2wchar_with_len, pg_johab_mblen, pg_johab_dsplen, 
pg_johab_verifier, 3},       /* 38; PG_JOHAB */
        {0, pg_sjis_mblen, pg_sjis_dsplen, pg_sjis_verifier, 2}         /* 40; 
PG_SHIFT_JIS_2004 */
 };
 

-- 
  Gregory Stark
  EnterpriseDB          http://www.enterprisedb.com

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not
       match

Reply via email to