diff --git a/src/backend/utils/mb/Makefile b/src/backend/utils/mb/Makefile
index 456dd6c30c2c1db28047f25122fdf5e0ca9fffe2..3f38eb41a976efcd8c2882215cf3307ca6b991db 100644
--- a/src/backend/utils/mb/Makefile
+++ b/src/backend/utils/mb/Makefile
@@ -4,7 +4,7 @@
 #    Makefile for utils/mb
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/backend/utils/mb/Makefile,v 1.8 2000/05/29 05:45:34 tgl Exp $
+#    $Header: /cvsroot/pgsql/src/backend/utils/mb/Makefile,v 1.9 2000/08/27 10:40:48 ishii Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -19,9 +19,22 @@ all: SUBSYS.o
 SUBSYS.o: $(OBJS)
 	$(LD) $(LDREL) $(LDOUT) SUBSYS.o $(OBJS)
 
-sjistest: $(OBJS)
-	$(CC) -c $(CFLAGS) -DDEBUGMAIN conv.c
-	$(CC) -o sjistest conv.o \
+palloc.o: palloc.c
+	$(CC) -c $(CFLAGS) palloc.c
+
+sjistest.o: sjistest.c
+	$(CC) -c $(CFLAGS) sjistest.c
+
+liketest.o: liketest.c
+	$(CC) -c $(CFLAGS) liketest.c
+
+sjistest: $(OBJS) sjistest.o palloc.o
+	$(CC) -o sjistest sjistest.o palloc.o \
+	common.o mbutils.o wchar.o wstrcmp.o wstrncmp.o variable.o \
+       big5.o $(LDFLAGS)
+
+liketest: $(OBJS) liketest.o palloc.o
+	$(CC) -o liketest liketest.o palloc.o conv.o \
 	common.o mbutils.o wchar.o wstrcmp.o wstrncmp.o variable.o \
        big5.o $(LDFLAGS)
 
diff --git a/src/backend/utils/mb/conv.c b/src/backend/utils/mb/conv.c
index af7f5623b547396c5587ce41ddf489a5d83ff0fd..15a5dee25ec0fef8e0d341881e068258d7eadff0 100644
--- a/src/backend/utils/mb/conv.c
+++ b/src/backend/utils/mb/conv.c
@@ -6,7 +6,7 @@
  * WIN1250 client encoding support contributed by Pavel Behal
  * SJIS UDC (NEC selection IBM kanji) support contributed by Eiji Tokuya
  *
- * $Id: conv.c,v 1.16 2000/06/28 03:32:45 tgl Exp $
+ * $Id: conv.c,v 1.17 2000/08/27 10:40:48 ishii Exp $
  *
  *
  */
@@ -1519,70 +1519,3 @@ pg_encoding_conv_tbl pg_conv_tbl[] = {
 	{WIN1250, "WIN1250", 1, win12502mic, mic2win1250},	/* WIN 1250 */
 	{-1, "", 0, 0, 0}			/* end mark */
 };
-
-#ifdef DEBUGMAIN
-#include "postgres.h"
-#include "utils/memutils.h"
-/*
- *	testing for sjis2mic() and mic2sjis()
- */
-
-int
-main()
-{
-	unsigned char eucbuf[1024];
-	unsigned char sjisbuf[1024];
-	unsigned char sjis[] = {0x81, 0x40, 0xa1, 0xf0, 0x40, 0xf0, 0x9e, 0xf5, 0x40, 0xfa, 0x40, 0xfa, 0x54, 0xfa, 0x7b, 0x00};
-
-	int			i;
-
-	sjis2mic(sjis, eucbuf, 1024);
-	for (i = 0; i < 1024; i++)
-	{
-		if (eucbuf[i])
-			printf("%02x ", eucbuf[i]);
-		else
-		{
-			printf("\n");
-			break;
-		}
-	}
-
-	mic2sjis(eucbuf, sjisbuf, 1024);
-	for (i = 0; i < 1024; i++)
-	{
-		if (sjisbuf[i])
-			printf("%02x ", sjisbuf[i]);
-		else
-		{
-			printf("\n");
-			break;
-		}
-	}
-
-	return (0);
-}
-
-void
-elog(int lev, const char *fmt,...)
-{
-}
-
-MemoryContext CurrentMemoryContext;
-
-void *
-MemoryContextAlloc(MemoryContext context, Size size)
-{
-}
-
-void
-pfree(void *pointer)
-{
-}
-
-void *
-repalloc(void *pointer, Size size)
-{
-}
-
-#endif
diff --git a/src/backend/utils/mb/mbutils.c b/src/backend/utils/mb/mbutils.c
index 2e21f4f37aee1cbbc6fae816b68e2b77f561b404..922f1e2fc7677b7a136f6607ea09e37a175ab75a 100644
--- a/src/backend/utils/mb/mbutils.c
+++ b/src/backend/utils/mb/mbutils.c
@@ -3,7 +3,7 @@
  * client encoding and server internal encoding.
  * (currently mule internal code (mic) is used)
  * Tatsuo Ishii
- * $Id: mbutils.c,v 1.10 2000/06/13 07:35:12 tgl Exp $ */
+ * $Id: mbutils.c,v 1.11 2000/08/27 10:40:48 ishii Exp $ */
 
 
 #include "postgres.h"
@@ -173,17 +173,17 @@ pg_server_to_client(unsigned char *s, int len)
 }
 
 /* convert a multi-byte string to a wchar */
-void
+int
 pg_mb2wchar(const unsigned char *from, pg_wchar * to)
 {
-	(*pg_wchar_table[GetDatabaseEncoding()].mb2wchar_with_len) (from, to, strlen(from));
+	return (*pg_wchar_table[GetDatabaseEncoding()].mb2wchar_with_len) (from, to, strlen(from));
 }
 
 /* convert a multi-byte string to a wchar with a limited length */
-void
+int
 pg_mb2wchar_with_len(const unsigned char *from, pg_wchar * to, int len)
 {
-	(*pg_wchar_table[GetDatabaseEncoding()].mb2wchar_with_len) (from, to, len);
+	return (*pg_wchar_table[GetDatabaseEncoding()].mb2wchar_with_len) (from, to, len);
 }
 
 /* returns the byte length of a multi-byte word */
diff --git a/src/backend/utils/mb/wchar.c b/src/backend/utils/mb/wchar.c
index bc576a1789bdedd2fd6b8c85eb7768d6458b578c..404bd1d8174dd1f5cbbdaac274a77aa4fd2bf1b5 100644
--- a/src/backend/utils/mb/wchar.c
+++ b/src/backend/utils/mb/wchar.c
@@ -1,7 +1,7 @@
 /*
  * conversion functions between pg_wchar and multi-byte streams.
  * Tatsuo Ishii
- * $Id: wchar.c,v 1.11 2000/04/12 17:16:06 momjian Exp $
+ * $Id: wchar.c,v 1.12 2000/08/27 10:40:48 ishii Exp $
  *
  * WIN1250 client encoding updated by Pavel Behal
  *
@@ -20,15 +20,19 @@
 /*
  * SQL/ASCII
  */
-static void pg_ascii2wchar_with_len
+static int pg_ascii2wchar_with_len
 			(const unsigned char *from, pg_wchar * to, int len)
 {
+	int cnt = 0;
+
 	while (*from && len > 0)
 	{
 		*to++ = *from++;
 		len--;
+		cnt++;
 	}
 	*to = 0;
+	return(cnt);
 }
 
 static int
@@ -41,9 +45,11 @@ pg_ascii_mblen(const unsigned char *s)
  * EUC
  */
 
-static void pg_euc2wchar_with_len
+static int pg_euc2wchar_with_len
 			(const unsigned char *from, pg_wchar * to, int len)
 {
+	int cnt = 0;
+
 	while (*from && len > 0)
 	{
 		if (*from == SS2)
@@ -72,8 +78,10 @@ static void pg_euc2wchar_with_len
 			len--;
 		}
 		to++;
+		cnt++;
 	}
 	*to = 0;
+	return(cnt);
 }
 
 static int
@@ -95,10 +103,10 @@ pg_euc_mblen(const unsigned char *s)
 /*
  * EUC_JP
  */
-static void pg_eucjp2wchar_with_len
+static int pg_eucjp2wchar_with_len
 			(const unsigned char *from, pg_wchar * to, int len)
 {
-	pg_euc2wchar_with_len(from, to, len);
+	return(pg_euc2wchar_with_len(from, to, len));
 }
 
 static int
@@ -110,10 +118,10 @@ pg_eucjp_mblen(const unsigned char *s)
 /*
  * EUC_KR
  */
-static void pg_euckr2wchar_with_len
+static int pg_euckr2wchar_with_len
 			(const unsigned char *from, pg_wchar * to, int len)
 {
-	pg_euc2wchar_with_len(from, to, len);
+	return(pg_euc2wchar_with_len(from, to, len));
 }
 
 static int
@@ -125,9 +133,11 @@ pg_euckr_mblen(const unsigned char *s)
 /*
  * EUC_CN
  */
-static void pg_euccn2wchar_with_len
+static int pg_euccn2wchar_with_len
 			(const unsigned char *from, pg_wchar * to, int len)
 {
+	int cnt = 0;
+
 	while (*from && len > 0)
 	{
 		if (*from == SS2)
@@ -157,8 +167,10 @@ static void pg_euccn2wchar_with_len
 			len--;
 		}
 		to++;
+		cnt++;
 	}
 	*to = 0;
+	return(cnt);
 }
 
 static int
@@ -176,9 +188,11 @@ pg_euccn_mblen(const unsigned char *s)
 /*
  * EUC_TW
  */
-static void pg_euctw2wchar_with_len
+static int pg_euctw2wchar_with_len
 			(const unsigned char *from, pg_wchar * to, int len)
 {
+	int cnt = 0;
+
 	while (*from && len > 0)
 	{
 		if (*from == SS2)
@@ -209,8 +223,10 @@ static void pg_euctw2wchar_with_len
 			len--;
 		}
 		to++;
+		cnt++;
 	}
 	*to = 0;
+	return(cnt);
 }
 
 static int
@@ -235,12 +251,13 @@ pg_euctw_mblen(const unsigned char *s)
  * len: length of from.
  * "from" not necessarily null terminated.
  */
-static void
+static int
 pg_utf2wchar_with_len(const unsigned char *from, pg_wchar * to, int len)
 {
 	unsigned char c1,
 				c2,
 				c3;
+	int cnt = 0;
 
 	while (*from && len > 0)
 	{
@@ -273,8 +290,10 @@ pg_utf2wchar_with_len(const unsigned char *from, pg_wchar * to, int len)
 			len--;
 		}
 		to++;
+		cnt++;
 	}
 	*to = 0;
+	return(cnt);
 }
 
 static int
@@ -297,9 +316,11 @@ pg_utf_mblen(const unsigned char *s)
  * len: length of from.
  * "from" not necessarily null terminated.
  */
-static void
+static int
 pg_mule2wchar_with_len(const unsigned char *from, pg_wchar * to, int len)
 {
+	int cnt = 0;
+
 	while (*from && len > 0)
 	{
 		if (IS_LC1(*from))
@@ -336,8 +357,10 @@ pg_mule2wchar_with_len(const unsigned char *from, pg_wchar * to, int len)
 			len--;
 		}
 		to++;
+		cnt++;
 	}
 	*to = 0;
+	return(cnt);
 }
 
 int
@@ -363,12 +386,18 @@ pg_mule_mblen(const unsigned char *s)
 /*
  * ISO8859-1
  */
-static void
+static int
 pg_latin12wchar_with_len(const unsigned char *from, pg_wchar * to, int len)
 {
+	int cnt = 0;
+
 	while (*from && len-- > 0)
+	{
 		*to++ = *from++;
+		cnt++;
+	}
 	*to = 0;
+	return(cnt);
 }
 
 static int