? src/test/mb/expected/big5.unicode_utf8
? src/test/mb/expected/euc_cn.unicode_utf8
? src/test/mb/expected/euc_jp.unicode_utf8
? src/test/mb/expected/euc_kr.unicode_utf8
? src/test/mb/expected/gb18030.unicode_utf8
? src/test/mb/expected/gbk.unicode_utf8
? src/test/mb/expected/latin8.unicode_utf8
? src/test/mb/expected/uhc.unicode_utf8
? src/test/mb/sql/big5.charset
? src/test/mb/sql/euc_cn.charset
? src/test/mb/sql/euc_jp.charset
? src/test/mb/sql/euc_kr.charset
? src/test/mb/sql/gb18030.charset
? src/test/mb/sql/gbk.charset
? src/test/mb/sql/latin8.charset
? src/test/mb/sql/uhc.charset
Index: src/test/mb/README
===================================================================
RCS file: /projects/cvsroot/pgsql/src/test/mb/README,v
retrieving revision 1.2
diff -c -r1.2 README
*** src/test/mb/README	3 Sep 2002 21:45:44 -0000	1.2
--- src/test/mb/README	8 Jul 2005 16:46:59 -0000
***************
*** 1,8 ****
! README for multibyte regression test
! 							1998/7/22
! 							Tatsuo Ishii
  
! This directory contains a set of tests for multibyte supporting
! extentions for PostgreSQL. To run the test, simply type:
  
! % mbregress.sh
--- 1,54 ----
! README for multibyte regression test.
! CREATED BY Tatsuo Ishii 1998/7/22
! CONTAINS: Set of tests for multibyte supporting extentions for PostgreSQL. 
! LAST UPDATE BY Ayush Parashar 2005/July/7
! ENHANCEMENTS 2005/July/7:
!   1. - Include extensive multi-byte regression tests for copy command.
!      - Uses following complete character sets and encoding types for testing: 
!        "big5 gbk uhc gb18030 euc_cn latin8 euc_kr euc_jp" 
!   2. Include help and usage for various tests.
!   3. Include cleanup function, to remove the log files and database objects that 
!      have been created.
! REQUIREMENTS:
!  - Installed PostgreSQL
!  - The location of bin directory of PostgreSQL should be included in "PATH" variable.
! TESTED ON:
!  - 2.6.10-1.741_FC3.rootsmp GNU/Linux &
!  - 5.10 Generic SunOS
  
! USAGE:
! ./mbregress.sh --help
! ./mbregress.sh test
! ./mbregress.sh clean
  
! MULTI-BYTE CHARACTER SET & CLIENT ENCODING TESTS FOR COPY COMMAND:
! HIGHLIGHT:
! - Uses complete character sets for: big5 gbk uhc gb18030 euc_cn latin8 
!   euc_kr euc_jp
! - Expected output produced using "iconv" command.
! 
! 1. Creates tables in database with unicode encoding.
! 2. Sets client encoding to a particular type.
! 3. Uploads complete character sets to database using "copy from" command.
! 4. Sets client encoding to unicode.
! 5. Download complete character sets from database using "copy to" command.
! 6. Compares this result to expected output. 
! 
! HELP:
! 1. ./mbregress.sh test
!   - Creates database and tables required for the tests.
!       * Databases created: euc_cn, euc_jp, euc_kr, euc_tw, mule_internal, 
!         unicode, unitest
!       * Tables created: big5_ce_copy, euc_cn_ce_copy, euc_jp_ce_copy, 
!         euc_kr_ce_copy, gb18030_ce_copy, gbk_ce_copy,  
!         latin8_ce_copy, uhc_ce_copy [these tables created 
!         in unitest database]
!   - Uses scripts and data in ./sql directory, to produce output that is thrown 
!     in ./results and compared with files in ./expected 
!   - Differences are thrown in regression.diffs file
!   - Logs related to database and table creation present in 
!     file ./results/db_command.log			
! 2. ./mbregress.sh clean
!   - Cleans up the log files
!   - Cleans up the database and tables created during the run 
!     of "./mbregress.sh test" 
Index: src/test/mb/mbregress.sh
===================================================================
RCS file: /projects/cvsroot/pgsql/src/test/mb/mbregress.sh,v
retrieving revision 1.9
diff -c -r1.9 mbregress.sh
*** src/test/mb/mbregress.sh	24 Jun 2005 15:11:59 -0000	1.9
--- src/test/mb/mbregress.sh	8 Jul 2005 16:47:00 -0000
***************
*** 1,60 ****
! #! /bin/sh
! # $PostgreSQL: pgsql/src/test/mb/mbregress.sh,v 1.9 2005/06/24 15:11:59 ishii Exp $
  
  if echo '\c' | grep -s c >/dev/null 2>&1
  then
! 	ECHO_N="echo -n"
! 	ECHO_C=""
  else
! 	ECHO_N="echo"
! 	ECHO_C='\c'
! fi
! 
! if [ ! -d results ];then
!     mkdir results
  fi
  
! dropdb utf8
! createdb -E UTF8 utf8
  
  PSQL="psql -n -e -q"
! tests="euc_jp sjis euc_kr euc_cn euc_tw big5 utf8 mule_internal"
  unset PGCLIENTENCODING
  for i in $tests
  do
! 	$ECHO_N "${i} .. " $ECHO_C
! 
! 	if [ $i = sjis ];then
! 		PGCLIENTENCODING=SJIS
! 		export PGCLIENTENCODING
! 		$PSQL euc_jp < sql/sjis.sql > results/sjis.out 2>&1
! 		unset PGCLIENTENCODING
!         elif [ $i = big5 ];then
! 		PGCLIENTENCODING=BIG5
! 		export PGCLIENTENCODING
! 		$PSQL euc_tw < sql/big5.sql > results/big5.out 2>&1
! 		unset PGCLIENTENCODING
! 	else
! 		dropdb $i >/dev/null 2>&1
! 		createdb -E `echo $i | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` $i >/dev/null
! 		$PSQL $i < sql/${i}.sql > results/${i}.out 2>&1
! 	fi
! 
! 	if [ -f expected/${i}-${SYSTEM}.out ]
! 	then
! 		EXPECTED="expected/${i}-${SYSTEM}.out"
! 	else
! 		EXPECTED="expected/${i}.out"
! 	fi
    
! 	if [ `diff ${EXPECTED} results/${i}.out | wc -l` -ne 0 ]
! 	then
! 		( diff -wC3 ${EXPECTED} results/${i}.out; \
! 		echo "";  \
! 		echo "----------------------"; \
! 		echo "" ) >> regression.diffs
! 		echo failed
! 	else
! 		echo ok
! 	fi
  done
--- 1,170 ----
! #! /bin/bash
! # $PostgreSQL: pgsql/src/test/mb/mbregress.sh,v 1.7 2003/11/29 19:52:14 pgsql Exp $
! # CREATED BY Tatsuo Ishii 1998/7/22
! # CONTAINS: Set of tests for multibyte supporting extentions for PostgreSQL. 
! # LAST UPDATE BY Ayush Parashar 2005/July/7
! # ENHANCEMENTS:
! #   1. - Include extensive multi-byte regression tests for copy command.
! #      - Uses following complete character sets and encoding types for testing: 
! #        "big5 gbk uhc gb18030 euc_cn latin8 euc_kr euc_jp" 
! #   2. Include help and usage for various tests.
! #   3. Include cleanup function, to remove the log files and database objects that have been created.
! # REQUIREMENTS:
! #  - Installed PostgreSQL
! #  - The location of bin directory of PostgreSQL should be included in "PATH" variable. 
! 
! usage()
! {
!   echo "Usage:"
!   echo "$0 --help"
!   echo "$0 test"
!   echo "$0 clean"
!   exit 1 
! }
! 
! help_mbregress()
! {
!   echo "mbregress.sh HELP:"
!   echo "$0 --help"
!   echo "  - Help for mbregress.sh"
!   echo "$0 test"
!   echo "  - Creates necessary database and tables"
!   echo "  - Tests multi-byte character sets & client encoding for create table, insert & select statements"
!   echo "  - Tests multi-byte character sets & client encoding for copy command using complete character sets"
!   echo "  - If some test fails, output thrown in regression.diffs"
!   echo "$0 clean"
!   echo "  - Cleans up the log files"
!   echo "  - Cleans up the database and tables created during the run of \"./mbregress.sh test\" "	
!   echo "mbregress.sh REQUIREMENTS:"
!   echo "  - PostgreSQL installation (with database cluster already initialized using initdb)"
!   echo "  - The location of bin directory of PostgreSQL should be included in \"PATH\" variable."
!   exit 0	
! }
! 
! clean()
! {
!   echo "Cleaning up.."
!   \rm ./regression.diffs >> ./results/db_commands.log 2>&1
!   \rm ./expected/*.od >> ./results/db_commands.log 2>&1
!   \rm ./results/*.od >> ./results/db_commands.log 2>&1 
!   \rm ./results/*unicode_utf8 >> ./results/db_commands.log 2>&1
!   dropdb unitest >> ./results/db_commands.log 2>&1
!   dropdb euc_cn >> ./results/db_commands.log 2>&1
!   dropdb euc_jp >> ./results/db_commands.log 2>&1
!   dropdb euc_kr >> ./results/db_commands.log 2>&1
!   dropdb euc_tw >> ./results/db_commands.log 2>&1
!   dropdb mule_internal >> ./results/db_commands.log 2>&1
!   dropdb unicode >> ./results/db_commands.log 2>&1
!   echo "done."
!   exit 0
! }
! 
! if [ ! -d results ];then
!   mkdir results
! fi
! 
! if [ $# -ne 1 ]; then
!   usage
! else 
!   if [ $1 == "--help" ]; then
!     help_mbregress
!   else
!     if [ $1 == "clean" ]; then
!       clean
!     else
!       if [ $1 != "test" ]; then
!         usage
!       fi
!     fi
!   fi
! fi
  
  if echo '\c' | grep -s c >/dev/null 2>&1
  then
!   ECHO_N="echo -n"
!   ECHO_C=""
  else
!   ECHO_N="echo"
!   ECHO_C='\c'
  fi
  
! \rm ./results/db_commands.log  > /dev/null 2>&1
! dropdb unitest >> ./results/db_commands.log 2>&1 
! createdb -E UNICODE unitest >> ./results/db_commands.log 2>&1
  
  PSQL="psql -n -e -q"
! 
! # STARTING THE MULTI-BYTE TESTS FOR CREATE TABLE, CREATE INDEX, INSERT, SELECT
! echo "---------------------------------------------"
! echo "Starting multi-byte tests for create table, create index, insert, and select statements"
! tests="euc_jp sjis euc_kr euc_cn euc_tw big5 mule_internal"
  unset PGCLIENTENCODING
  for i in $tests
  do
!   $ECHO_N "${i} .. " $ECHO_C
!   if [ $i = sjis ];then
!     PGCLIENTENCODING=SJIS
!     export PGCLIENTENCODING
!     $PSQL euc_jp < sql/sjis.sql > results/sjis.out 2>&1
!     unset PGCLIENTENCODING
!   elif [ $i = big5 ];then
!     PGCLIENTENCODING=BIG5
!     export PGCLIENTENCODING
!     $PSQL euc_tw < sql/big5.sql > results/big5.out 2>&1
!     unset PGCLIENTENCODING
!   else
!     dropdb $i >/dev/null 2>&1
!     createdb -E `echo $i | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` $i >/dev/null
!     $PSQL $i < sql/${i}.sql > results/${i}.out 2>&1
!   fi
! 
!   if [ -f expected/${i}-${SYSTEM}.out ]
!   then
!     EXPECTED="expected/${i}-${SYSTEM}.out"
!   else
!     EXPECTED="expected/${i}.out"
!   fi
    
!   if [ `diff ${EXPECTED} results/${i}.out | wc -l` -ne 0 ]
!   then
!     ( diff -wC3 ${EXPECTED} results/${i}.out; \
!     echo "";  \
!     echo "----------------------"; \
!     echo "" ) >> regression.diffs
!     echo failed
!   else
!     echo ok
!   fi
  done
+ 
+ # STARTING THE CHARACTER ENCODING/ CLIENT ENCODING TESTS FOR COPY COMMAND
+ echo "---------------------------------------------"
+ #copy_command=copy
+ copy_command="\copy"
+ echo "Starting multi-byte character encoding tests for copy command" 
+ copy_tests="big5 gbk uhc gb18030 euc_cn latin8 euc_kr euc_jp"
+ CWD=`pwd`
+ unset PGCLIENTENCODING
+ for j in $copy_tests
+ do
+   $PSQL unitest -c "create table ${j}_ce_copy(c1 varchar)" >> ./results/db_commands.log 2>&1 
+   PGCLIENTENCODING=${j}
+   export PGCLIENTENCODING
+   $PSQL unitest -c "$copy_command ${j}_ce_copy from '$CWD/sql/${j}.charset' " >> ./results/db_commands.log 2>&1
+   unset PGCLIENTENCODING
+   $PSQL unitest -c "$copy_command ${j}_ce_copy to '$CWD/results/${j}.unicode_utf8' " >> ./results/db_commands.log 2>&1
+   od -d $CWD/expected/${j}.unicode_utf8 > $CWD/expected/${j}.unicode_utf8.od
+   od -d $CWD/results/${j}.unicode_utf8 > $CWD/results/${j}.unicode_utf8.od
+   if [ `diff $CWD/expected/${j}.unicode_utf8.od $CWD/results/${j}.unicode_utf8.od | wc -l` -ne 0 ]
+   then
+     ( diff $CWD/expected/${j}.unicode_utf8.od $CWD/results/${j}.unicode_utf8.od; \
+     echo ""; \
+     echo "----------------------"; \
+     echo "" ) >> regression.diffs
+     echo ${j} failed
+   else
+     echo ${j} .. ok 
+   fi	
+ done
+ echo "---------------------------------------------"
+ 
