#################################################################################
# Author:  Serge Kozlov                                                         #
# Date:    2005-09-21                                                           #
# Purpose: used by ../t/*_charset.test                                          #
# Require: set $engine_type= [NDB,MyISAM,InnoDB,etc] before calling             #
#                                                                               #
# Last modification:  Matthias Leich                                            #
# Date:    2008-07-02                                                           #
# Purpose: Fix Bug#37160 funcs_2: The tests do not check if optional character  #
#                                 sets exist.                                   #
#          Add checking of prerequisites + minor cleanup                        #
#################################################################################

#
#
#

# Check that all character sets needed are available
# Note(mleich):
#    It is intentional that the common solution with
#    "--source include/have_<character set>.inc"
#    is not applied.
#    - We currently do not have such a prerequisite test for every character set
#      /collation needed.
#    - There is also no real value in mentioning the first missing character set
#      /collation within the "skip message" because it is most probably only
#      one of many.
#      
# Hint: 5 character_set_names per source line if possible
if (`SELECT COUNT(*) <> 36 FROM information_schema.character_sets
    WHERE CHARACTER_SET_NAME IN (
    'armscii8', 'ascii'  , 'big5'   , 'binary' , 'cp1250',
    'cp1251'  , 'cp1256' , 'cp1257' , 'cp850'  , 'cp852' ,
    'cp866'   , 'cp932'  , 'dec8'   , 'eucjpms', 'euckr' ,
    'gb2312'  , 'gbk'    , 'geostd8', 'greek'  , 'hebrew',
    'hp8'     , 'keybcs2', 'koi8r'  , 'koi8u'  , 'latin1',
    'latin2'  , 'latin5' , 'latin7' , 'macce'  , 'macroman',
    'sjis'    , 'swe7'   , 'tis620' , 'ucs2'   , 'ujis',
    'utf8'
    )`)
{
   --skip Not all character sets required for this test are present
}
# Check that all collations needed are available
# Hint: 4 collation_names per source line if possible
if (`SELECT COUNT(*) <> 123 FROM information_schema.collations
WHERE collation_name IN (
'armscii8_bin', 'armscii8_general_ci', 'ascii_bin', 'ascii_general_ci',
'big5_bin', 'big5_chinese_ci', 'cp1250_bin', 'cp1250_croatian_ci',
'cp1250_czech_cs', 'cp1250_general_ci', 'cp1251_bin', 'cp1251_bulgarian_ci',
'cp1251_general_ci', 'cp1251_general_cs', 'cp1251_ukrainian_ci', 'cp1256_bin',
'cp1256_general_ci', 'cp1257_bin', 'cp1257_general_ci', 'cp1257_lithuanian_ci',
'cp850_bin', 'cp850_general_ci', 'cp852_bin', 'cp852_general_ci',
'cp866_bin', 'cp866_general_ci', 'cp932_bin', 'cp932_japanese_ci',
'dec8_bin', 'dec8_swedish_ci', 'eucjpms_bin', 'eucjpms_japanese_ci',
'euckr_bin', 'euckr_korean_ci', 'gb2312_bin', 'gb2312_chinese_ci',
'gbk_bin', 'gbk_chinese_ci', 'geostd8_bin', 'geostd8_general_ci',
'greek_bin', 'greek_general_ci', 'hebrew_bin', 'hebrew_general_ci',
'hp8_bin', 'hp8_english_ci', 'keybcs2_bin', 'keybcs2_general_ci',
'koi8r_bin', 'koi8r_general_ci', 'koi8u_bin', 'koi8u_general_ci',
'latin1_bin', 'latin1_danish_ci', 'latin1_general_ci', 'latin1_general_cs',
'latin1_german1_ci', 'latin1_german2_ci', 'latin1_spanish_ci', 'latin1_swedish_ci',
'latin2_bin', 'latin2_croatian_ci', 'latin2_czech_cs', 'latin2_general_ci',
'latin2_hungarian_ci', 'latin5_bin', 'latin5_turkish_ci', 'latin7_bin',
'latin7_estonian_cs', 'latin7_general_ci', 'latin7_general_cs', 'macce_bin',
'macce_general_ci', 'macroman_bin', 'macroman_general_ci', 'sjis_bin',
'sjis_japanese_ci', 'swe7_bin', 'swe7_swedish_ci', 'tis620_bin',
'tis620_thai_ci', 'ucs2_bin', 'ucs2_czech_ci', 'ucs2_danish_ci',
'ucs2_estonian_ci', 'ucs2_general_ci', 'ucs2_hungarian_ci', 'ucs2_icelandic_ci',
'ucs2_latvian_ci', 'ucs2_lithuanian_ci', 'ucs2_persian_ci', 'ucs2_polish_ci',
'ucs2_roman_ci', 'ucs2_romanian_ci', 'ucs2_slovak_ci', 'ucs2_slovenian_ci',
'ucs2_spanish2_ci', 'ucs2_spanish_ci', 'ucs2_swedish_ci', 'ucs2_turkish_ci',
'ucs2_unicode_ci', 'ujis_bin', 'ujis_japanese_ci', 'utf8_bin',
'utf8_czech_ci', 'utf8_danish_ci', 'utf8_estonian_ci', 'utf8_general_ci',
'utf8_hungarian_ci', 'utf8_icelandic_ci', 'utf8_latvian_ci', 'utf8_lithuanian_ci',
'utf8_persian_ci', 'utf8_polish_ci', 'utf8_roman_ci', 'utf8_romanian_ci',
'utf8_slovak_ci', 'utf8_slovenian_ci', 'utf8_spanish2_ci', 'utf8_spanish_ci',
'utf8_swedish_ci', 'utf8_turkish_ci', 'utf8_unicode_ci'
)`)
{
   --skip Not all collations required for this test are present
}

################################
let $check_std_csets= 1;
let $check_ucs2_csets= 1;
let $check_utf8_csets= 1;

# Bug#32784: Timeout in test "innodb_charset": InnoDB much slower 
#            than other handlers
# NOTE:  We turn autocommit off to improve the performance of the innodb variant
#        of this test.  Per Innobase's recommendation.

--disable_query_log
SET autocommit=0;
--enable_query_log

#
# Check all charsets/collation combinations
#

################################
let $check_std_csets= 1;
let $check_ucs2_csets= 1;
let $check_utf8_csets= 1;

#
# Check all charsets/collation combinations
#

if ($check_std_csets)
{

# armscii8

let $cset= armscii8;
let $coll= armscii8_bin;
--source suite/funcs_2/include/check_charset.inc

let $cset= armscii8;
let $coll= armscii8_general_ci;
--source suite/funcs_2/include/check_charset.inc

# ascii

let $cset= ascii;
let $coll= ascii_bin;
--source suite/funcs_2/include/check_charset.inc

let $cset= ascii;
let $coll= ascii_general_ci;
--source suite/funcs_2/include/check_charset.inc
 
# big5

let $cset= big5;
let $coll= big5_bin;
--source suite/funcs_2/include/check_charset.inc

let $cset= big5;
let $coll= big5_chinese_ci;
--source suite/funcs_2/include/check_charset.inc

# binary

let $cset= binary;
let $coll= ;
let $bin_cset= 1;
--source suite/funcs_2/include/check_charset.inc

# cp1250

let $cset= cp1250;
let $coll= cp1250_bin;
--source suite/funcs_2/include/check_charset.inc

let $cset= cp1250;
let $coll= cp1250_croatian_ci;
--source suite/funcs_2/include/check_charset.inc


let $cset= cp1250;
let $coll= cp1250_czech_cs;
--source suite/funcs_2/include/check_charset.inc


let $cset= cp1250;
let $coll= cp1250_general_ci;
--source suite/funcs_2/include/check_charset.inc

# cp1251

let $cset= cp1251;
let $coll= cp1251_bin;
--source suite/funcs_2/include/check_charset.inc

let $cset= cp1251;
let $coll= cp1251_bulgarian_ci;
--source suite/funcs_2/include/check_charset.inc

let $cset= cp1251;
let $coll= cp1251_general_ci;
--source suite/funcs_2/include/check_charset.inc

let $cset= cp1251;
let $coll= cp1251_general_cs;
--source suite/funcs_2/include/check_charset.inc

let $cset= cp1251;
let $coll= cp1251_ukrainian_ci; 
--source suite/funcs_2/include/check_charset.inc

# cp1256

let $cset= cp1256;
let $coll= cp1256_bin; 
--source suite/funcs_2/include/check_charset.inc

let $cset= cp1256;
let $coll= cp1256_general_ci; 
--source suite/funcs_2/include/check_charset.inc

# cp1257

let $cset= cp1257;
let $coll= cp1257_bin; 
--source suite/funcs_2/include/check_charset.inc

let $cset= cp1257;
let $coll= cp1257_general_ci; 
--source suite/funcs_2/include/check_charset.inc

let $cset= cp1257;
let $coll= cp1257_lithuanian_ci; 
--source suite/funcs_2/include/check_charset.inc

# cp850

let $cset= cp850;
let $coll= cp850_bin; 
--source suite/funcs_2/include/check_charset.inc

let $cset= cp850;
let $coll= cp850_general_ci;
--source suite/funcs_2/include/check_charset.inc

# cp852

let $cset= cp852;
let $coll= cp852_bin; 
--source suite/funcs_2/include/check_charset.inc

let $cset= cp852;
let $coll= cp852_general_ci;
--source suite/funcs_2/include/check_charset.inc

# cp866

let $cset= cp866;
let $coll= cp866_bin; 
--source suite/funcs_2/include/check_charset.inc

let $cset= cp866;
let $coll= cp866_general_ci;
--source suite/funcs_2/include/check_charset.inc
 
# cp932

let $cset= cp932;
let $coll= cp932_bin; 
--source suite/funcs_2/include/check_charset.inc

let $cset= cp932;
let $coll= cp932_japanese_ci;
--source suite/funcs_2/include/check_charset.inc
 
# dec8

let $cset= dec8;
let $coll= dec8_bin; 
--source suite/funcs_2/include/check_charset.inc

let $cset= dec8;
let $coll= dec8_swedish_ci; 
--source suite/funcs_2/include/check_charset.inc

# eucjpms

let $cset= eucjpms;
let $coll= eucjpms_bin; 
--source suite/funcs_2/include/check_charset.inc

let $cset= eucjpms;
let $coll= eucjpms_japanese_ci; 
--source suite/funcs_2/include/check_charset.inc

# euckr

let $cset= euckr;
let $coll= euckr_bin; 
--source suite/funcs_2/include/check_charset.inc

let $cset= euckr;
let $coll= euckr_korean_ci; 
--source suite/funcs_2/include/check_charset.inc
 
# gb2312

let $cset= gb2312;
let $coll= gb2312_bin;
--source suite/funcs_2/include/check_charset.inc

let $cset= gb2312;
let $coll= gb2312_chinese_ci;
--source suite/funcs_2/include/check_charset.inc

# gbk

let $cset= gbk;
let $coll= gbk_bin;
--source suite/funcs_2/include/check_charset.inc

let $cset= gbk;
let $coll= gbk_chinese_ci;
--source suite/funcs_2/include/check_charset.inc

# geostd8

let $cset= geostd8;
let $coll= geostd8_bin; 
--source suite/funcs_2/include/check_charset.inc

let $cset= geostd8;
let $coll= geostd8_general_ci;
--source suite/funcs_2/include/check_charset.inc

# greek

let $cset= greek;
let $coll= greek_bin; 
--source suite/funcs_2/include/check_charset.inc

let $cset= greek;
let $coll= greek_general_ci;
--source suite/funcs_2/include/check_charset.inc

# hebrew

let $cset= hebrew;
let $coll= hebrew_bin; 
--source suite/funcs_2/include/check_charset.inc

let $cset= hebrew;
let $coll= hebrew_general_ci;
--source suite/funcs_2/include/check_charset.inc

# hp8

let $cset= hp8;
let $coll= hp8_bin; 
--source suite/funcs_2/include/check_charset.inc

let $cset= hp8;
let $coll= hp8_english_ci;
--source suite/funcs_2/include/check_charset.inc

# keybcs2

let $cset= keybcs2;
let $coll= keybcs2_bin; 
--source suite/funcs_2/include/check_charset.inc

let $cset= keybcs2;
let $coll= keybcs2_general_ci;
--source suite/funcs_2/include/check_charset.inc

# koi8r

let $cset= koi8r;
let $coll= koi8r_bin; 
--source suite/funcs_2/include/check_charset.inc

let $cset= koi8r;
let $coll= koi8r_general_ci;
--source suite/funcs_2/include/check_charset.inc

# koi8u

let $cset= koi8u;
let $coll= koi8u_bin; 
--source suite/funcs_2/include/check_charset.inc

let $cset= koi8u;
let $coll= koi8u_general_ci;
--source suite/funcs_2/include/check_charset.inc

# latin1

let $cset= latin1;
let $coll= latin1_bin; 
--source suite/funcs_2/include/check_charset.inc

let $cset= latin1;
let $coll= latin1_danish_ci; 
--source suite/funcs_2/include/check_charset.inc

let $cset= latin1;
let $coll= latin1_general_ci;
--source suite/funcs_2/include/check_charset.inc

let $cset= latin1;
let $coll= latin1_general_cs;
--source suite/funcs_2/include/check_charset.inc


let $cset= latin1;
let $coll= latin1_german1_ci;
--source suite/funcs_2/include/check_charset.inc

let $cset= latin1;
let $coll= latin1_german2_ci;
--source suite/funcs_2/include/check_charset.inc

let $cset= latin1;
let $coll= latin1_spanish_ci;
--source suite/funcs_2/include/check_charset.inc

let $cset= latin1;
let $coll= latin1_swedish_ci;
--source suite/funcs_2/include/check_charset.inc

# latin2

let $cset= latin2;
let $coll= latin2_bin;
--source suite/funcs_2/include/check_charset.inc

let $cset= latin2;
let $coll= latin2_croatian_ci;
--source suite/funcs_2/include/check_charset.inc

let $cset= latin2;
let $coll= latin2_czech_cs; 
--source suite/funcs_2/include/check_charset.inc

let $cset= latin2;
let $coll= latin2_general_ci; 
--source suite/funcs_2/include/check_charset.inc

let $cset= latin2;
let $coll= latin2_hungarian_ci; 
--source suite/funcs_2/include/check_charset.inc

# latin5

let $cset= latin5;
let $coll= latin5_bin;
--source suite/funcs_2/include/check_charset.inc

let $cset= latin5;
let $coll= latin5_turkish_ci;
--source suite/funcs_2/include/check_charset.inc

# latin7

let $cset= latin7;
let $coll= latin7_bin;
--source suite/funcs_2/include/check_charset.inc

let $cset= latin7;
let $coll= latin7_estonian_cs;
--source suite/funcs_2/include/check_charset.inc

let $cset= latin7;
let $coll= latin7_general_ci;
--source suite/funcs_2/include/check_charset.inc

let $cset= latin7;
let $coll= latin7_general_cs;
--source suite/funcs_2/include/check_charset.inc

# macce

let $cset= macce;
let $coll= macce_bin; 
--source suite/funcs_2/include/check_charset.inc

let $cset= macce;
let $coll= macce_general_ci;
--source suite/funcs_2/include/check_charset.inc

# macroman

let $cset= macroman;
let $coll= macroman_bin; 
--source suite/funcs_2/include/check_charset.inc

let $cset= macroman;
let $coll= macroman_general_ci;
--source suite/funcs_2/include/check_charset.inc

# sjis

let $cset= sjis;
let $coll= sjis_bin; 
--source suite/funcs_2/include/check_charset.inc

let $cset= sjis;
let $coll= sjis_japanese_ci;
--source suite/funcs_2/include/check_charset.inc

# swe7

let $cset= swe7;
let $coll= swe7_bin; 
--source suite/funcs_2/include/check_charset.inc

let $cset= swe7;
let $coll= swe7_swedish_ci;
--source suite/funcs_2/include/check_charset.inc

# tis620

let $cset= tis620;
let $coll= tis620_bin; 
--source suite/funcs_2/include/check_charset.inc

let $cset= tis620;
let $coll= tis620_thai_ci;
--source suite/funcs_2/include/check_charset.inc

# ujis

let $cset= ujis;
let $coll= ujis_bin; 
--source suite/funcs_2/include/check_charset.inc

let $cset= ujis;
let $coll= ujis_japanese_ci; 
--source suite/funcs_2/include/check_charset.inc

}

if ($check_ucs2_csets)
{

# ucs2

let $cset= ucs2;
let $coll= ucs2_bin;
--source suite/funcs_2/include/check_charset_ucs2.inc

let $cset= ucs2;
let $coll= ucs2_czech_ci;
--source suite/funcs_2/include/check_charset_ucs2.inc

let $cset= ucs2;
let $coll= ucs2_danish_ci;
--source suite/funcs_2/include/check_charset_ucs2.inc

let $cset= ucs2;
let $coll= ucs2_estonian_ci;
--source suite/funcs_2/include/check_charset_ucs2.inc

let $cset= ucs2;
let $coll= ucs2_general_ci; 
--source suite/funcs_2/include/check_charset_ucs2.inc

let $cset= ucs2;
let $coll= ucs2_hungarian_ci; 
--source suite/funcs_2/include/check_charset_ucs2.inc

let $cset= ucs2;
let $coll= ucs2_icelandic_ci; 
--source suite/funcs_2/include/check_charset_ucs2.inc

let $cset= ucs2;
let $coll= ucs2_latvian_ci; 
--source suite/funcs_2/include/check_charset_ucs2.inc

let $cset= ucs2;
let $coll= ucs2_lithuanian_ci; 
--source suite/funcs_2/include/check_charset_ucs2.inc

let $cset= ucs2;
let $coll= ucs2_persian_ci; 
--source suite/funcs_2/include/check_charset_ucs2.inc

let $cset= ucs2;
let $coll= ucs2_polish_ci; 
--source suite/funcs_2/include/check_charset_ucs2.inc

let $cset= ucs2;
let $coll= ucs2_roman_ci; 
--source suite/funcs_2/include/check_charset_ucs2.inc

let $cset= ucs2;
let $coll= ucs2_romanian_ci; 
--source suite/funcs_2/include/check_charset_ucs2.inc

let $cset= ucs2;
let $coll= ucs2_slovak_ci; 
--source suite/funcs_2/include/check_charset_ucs2.inc

let $cset= ucs2;
let $coll= ucs2_slovenian_ci; 
--source suite/funcs_2/include/check_charset_ucs2.inc

let $cset= ucs2;
let $coll= ucs2_spanish2_ci; 
--source suite/funcs_2/include/check_charset_ucs2.inc

let $cset= ucs2;
let $coll= ucs2_spanish_ci; 
--source suite/funcs_2/include/check_charset_ucs2.inc

let $cset= ucs2;
let $coll= ucs2_swedish_ci; 
--source suite/funcs_2/include/check_charset_ucs2.inc

let $cset= ucs2;
let $coll= ucs2_turkish_ci; 
--source suite/funcs_2/include/check_charset_ucs2.inc

let $cset= ucs2;
let $coll= ucs2_unicode_ci; 
--source suite/funcs_2/include/check_charset_ucs2.inc

}

if ($check_utf8_csets)
{

# utf8

let $cset= utf8;
let $coll= utf8_bin; 
--source suite/funcs_2/include/check_charset_utf8.inc

let $cset= utf8;
let $coll= utf8_czech_ci; 
--source suite/funcs_2/include/check_charset_utf8.inc

let $cset= utf8;
let $coll= utf8_danish_ci; 
--source suite/funcs_2/include/check_charset_utf8.inc

let $cset= utf8;
let $coll= utf8_estonian_ci; 
--source suite/funcs_2/include/check_charset_utf8.inc

let $cset= utf8;
let $coll= utf8_general_ci; 
--source suite/funcs_2/include/check_charset_utf8.inc

let $cset= utf8;
let $coll= utf8_hungarian_ci; 
--source suite/funcs_2/include/check_charset_utf8.inc

let $cset= utf8;
let $coll= utf8_icelandic_ci; 
--source suite/funcs_2/include/check_charset_utf8.inc

let $cset= utf8;
let $coll= utf8_latvian_ci; 
--source suite/funcs_2/include/check_charset_utf8.inc

let $cset= utf8;
let $coll= utf8_lithuanian_ci; 
--source suite/funcs_2/include/check_charset_utf8.inc

let $cset= utf8;
let $coll= utf8_persian_ci; 
--source suite/funcs_2/include/check_charset_utf8.inc

let $cset= utf8;
let $coll= utf8_polish_ci; 
--source suite/funcs_2/include/check_charset_utf8.inc

let $cset= utf8;
let $coll= utf8_roman_ci; 
--source suite/funcs_2/include/check_charset_utf8.inc

let $cset= utf8;
let $coll= utf8_romanian_ci; 
--source suite/funcs_2/include/check_charset_utf8.inc

let $cset= utf8;
let $coll= utf8_slovak_ci; 
--source suite/funcs_2/include/check_charset_utf8.inc

let $cset= utf8;
let $coll= utf8_slovenian_ci; 
--source suite/funcs_2/include/check_charset_utf8.inc

let $cset= utf8;
let $coll= utf8_spanish2_ci; 
--source suite/funcs_2/include/check_charset_utf8.inc

let $cset= utf8;
let $coll= utf8_spanish_ci; 
--source suite/funcs_2/include/check_charset_utf8.inc

let $cset= utf8;
let $coll= utf8_swedish_ci; 
--source suite/funcs_2/include/check_charset_utf8.inc

let $cset= utf8;
let $coll= utf8_turkish_ci; 
--source suite/funcs_2/include/check_charset_utf8.inc

let $cset= utf8;
let $coll= utf8_unicode_ci; 
--source suite/funcs_2/include/check_charset_utf8.inc

}

