diff options
author | unknown <bar@mysql.com> | 2004-06-10 19:10:21 +0500 |
---|---|---|
committer | unknown <bar@mysql.com> | 2004-06-10 19:10:21 +0500 |
commit | d8f0df52d307ba3d1aea9c3d9a125c9439e22e33 (patch) | |
tree | 6b4077bc259e31398c158a35a49ae7ceaac96b12 | |
parent | 7ece3c749152fd9a5df821398852a4cb02ec13a2 (diff) | |
download | mariadb-git-d8f0df52d307ba3d1aea9c3d9a125c9439e22e33.tar.gz |
Optimization to use less memory.
-rw-r--r-- | include/m_ctype.h | 4 | ||||
-rw-r--r-- | mysys/charset.c | 24 | ||||
-rw-r--r-- | sql/sql_lex.cc | 40 | ||||
-rw-r--r-- | strings/ctype-big5.c | 8 | ||||
-rw-r--r-- | strings/ctype-bin.c | 4 | ||||
-rw-r--r-- | strings/ctype-czech.c | 3 | ||||
-rw-r--r-- | strings/ctype-euc_kr.c | 8 | ||||
-rw-r--r-- | strings/ctype-extra.c | 26 | ||||
-rw-r--r-- | strings/ctype-gb2312.c | 8 | ||||
-rw-r--r-- | strings/ctype-gbk.c | 8 | ||||
-rw-r--r-- | strings/ctype-latin1.c | 10 | ||||
-rw-r--r-- | strings/ctype-sjis.c | 8 | ||||
-rw-r--r-- | strings/ctype-tis620.c | 8 | ||||
-rw-r--r-- | strings/ctype-uca.c | 4 | ||||
-rw-r--r-- | strings/ctype-ucs2.c | 8 | ||||
-rw-r--r-- | strings/ctype-ujis.c | 8 | ||||
-rw-r--r-- | strings/ctype-utf8.c | 8 | ||||
-rw-r--r-- | strings/ctype-win1250ch.c | 3 |
18 files changed, 98 insertions, 92 deletions
diff --git a/include/m_ctype.h b/include/m_ctype.h index 87b45bd4954..002b77b5310 100644 --- a/include/m_ctype.h +++ b/include/m_ctype.h @@ -208,8 +208,8 @@ typedef struct charset_info_st uint16 **sort_order_big; uint16 *tab_to_uni; MY_UNI_IDX *tab_from_uni; - uchar state_map[256]; - uchar ident_map[256]; + uchar *state_map; + uchar *ident_map; uint strxfrm_multiply; uint mbminlen; uint mbmaxlen; diff --git a/mysys/charset.c b/mysys/charset.c index a9c733e25cf..d2d71689d7b 100644 --- a/mysys/charset.c +++ b/mysys/charset.c @@ -406,12 +406,21 @@ static void set_max_sort_char(CHARSET_INFO *cs) } -static void init_state_maps(CHARSET_INFO *cs) +static my_bool init_state_maps(CHARSET_INFO *cs) { uint i; - uchar *state_map= cs->state_map; - uchar *ident_map= cs->ident_map; + uchar *state_map; + uchar *ident_map; + if (!(cs->state_map= (uchar*) my_once_alloc(256, MYF(MY_WME)))) + return 1; + + if (!(cs->ident_map= (uchar*) my_once_alloc(256, MYF(MY_WME)))) + return 1; + + state_map= cs->state_map; + ident_map= cs->ident_map; + /* Fill state_map with states to get a faster parser */ for (i=0; i < 256 ; i++) { @@ -458,6 +467,7 @@ static void init_state_maps(CHARSET_INFO *cs) state_map[(uchar)'x']= state_map[(uchar)'X']= (uchar) MY_LEX_IDENT_OR_HEX; state_map[(uchar)'b']= state_map[(uchar)'b']= (uchar) MY_LEX_IDENT_OR_BIN; state_map[(uchar)'n']= state_map[(uchar)'N']= (uchar) MY_LEX_IDENT_OR_NCHAR; + return 0; } @@ -582,7 +592,8 @@ static int simple_cs_copy_data(CHARSET_INFO *to, CHARSET_INFO *from) MY_CS_CTYPE_TABLE_SIZE, MYF(MY_WME)))) goto err; - init_state_maps(to); + if (init_state_maps(to)) + goto err; } if (from->to_lower) if (!(to->to_lower= (uchar*) my_once_memdup((char*) from->to_lower, @@ -601,6 +612,8 @@ static int simple_cs_copy_data(CHARSET_INFO *to, CHARSET_INFO *from) MY_CS_SORT_ORDER_TABLE_SIZE, MYF(MY_WME)))) goto err; + + set_max_sort_char(to); } if (from->tab_to_uni) @@ -1108,7 +1121,8 @@ static my_bool init_available_charsets(myf myflags) { set_max_sort_char(*cs); if (cs[0]->ctype) - init_state_maps(*cs); + if (init_state_maps(*cs)) + *cs= NULL; } } diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index f98a6b43846..b6cb61fe10e 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -42,13 +42,6 @@ pthread_key(LEX*,THR_LEX); #define TOCK_NAME_LENGTH 24 /* - Map to default keyword characters. This is used to test if an identifer - is 'simple', in which case we don't have to do any character set conversions - on it -*/ -uchar *bin_ident_map= my_charset_bin.ident_map; - -/* The following data is based on the latin1 character set, and is only used when comparing keywords */ @@ -566,13 +559,9 @@ int yylex(void *arg, void *yythd) else #endif { - result_state= bin_ident_map[c] ? IDENT : IDENT_QUOTED; - while (ident_map[c=yyGet()]) - { - /* If not simple character, mark that we must convert it */ - if (!bin_ident_map[c]) - result_state= IDENT_QUOTED; - } + for (result_state= c; ident_map[c= yyGet()]; result_state|= c); + /* If there were non-ASCII characters, mark that we must convert */ + result_state= result_state & 0x80 ? IDENT_QUOTED : IDENT; } length= (uint) (lex->ptr - lex->tok_start)-1; if (lex->ignore_space) @@ -674,12 +663,11 @@ int yylex(void *arg, void *yythd) } else #endif - while (ident_map[c = yyGet()]) - { - /* If not simple character, mark that we must convert it */ - if (!bin_ident_map[c]) - result_state= IDENT_QUOTED; - } + { + for (result_state=0; ident_map[c= yyGet()]; result_state|= c); + /* If there were non-ASCII characters, mark that we must convert */ + result_state= result_state & 0x80 ? IDENT_QUOTED : IDENT; + } if (c == '.' && ident_map[yyPeek()]) lex->next_state=MY_LEX_IDENT_SEP;// Next is '.' @@ -953,13 +941,11 @@ int yylex(void *arg, void *yythd) We should now be able to handle: [(global | local | session) .]variable_name */ - result_state= IDENT; - while (ident_map[c=yyGet()]) - { - /* If not simple character, mark that we must convert it */ - if (!bin_ident_map[c]) - result_state= IDENT_QUOTED; - } + + for (result_state= 0; ident_map[c= yyGet()]; result_state|= c); + /* If there were non-ASCII characters, mark that we must convert */ + result_state= result_state & 0x80 ? IDENT_QUOTED : IDENT; + if (c == '.') lex->next_state=MY_LEX_IDENT_SEP; length= (uint) (lex->ptr - lex->tok_start)-1; diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c index 7a3c4503d74..fb72dec7385 100644 --- a/strings/ctype-big5.c +++ b/strings/ctype-big5.c @@ -6321,8 +6321,8 @@ CHARSET_INFO my_charset_big5_chinese_ci= NULL, /* sort_order_big*/ NULL, /* tab_to_uni */ NULL, /* tab_from_uni */ - "", - "", + NULL, /* state_map */ + NULL, /* ident_map */ 1, /* strxfrm_multiply */ 1, /* mbminlen */ 2, /* mbmaxlen */ @@ -6348,8 +6348,8 @@ CHARSET_INFO my_charset_big5_bin= NULL, /* sort_order_big*/ NULL, /* tab_to_uni */ NULL, /* tab_from_uni */ - "", - "", + NULL, /* state_map */ + NULL, /* ident_map */ 1, /* strxfrm_multiply */ 1, /* mbminlen */ 2, /* mbmaxlen */ diff --git a/strings/ctype-bin.c b/strings/ctype-bin.c index 48323018cca..7b3164bf438 100644 --- a/strings/ctype-bin.c +++ b/strings/ctype-bin.c @@ -386,8 +386,8 @@ CHARSET_INFO my_charset_bin = NULL, /* tab_to_uni */ NULL, /* tab_from_uni */ NULL, /* sort_order_big*/ - "", - "", + NULL, /* state_map */ + NULL, /* ident_map */ 1, /* strxfrm_multiply */ 1, /* mbminlen */ 1, /* mbmaxlen */ diff --git a/strings/ctype-czech.c b/strings/ctype-czech.c index dede737f361..3218fdee673 100644 --- a/strings/ctype-czech.c +++ b/strings/ctype-czech.c @@ -597,7 +597,8 @@ CHARSET_INFO my_charset_latin2_czech_ci = NULL, /* sort_order_big*/ tab_8859_2_uni, /* tab_to_uni */ idx_uni_8859_2, /* tab_from_uni */ - "","", + NULL, /* state_map */ + NULL, /* ident_map */ 4, /* strxfrm_multiply */ 1, /* mbminlen */ 1, /* mbmaxlen */ diff --git a/strings/ctype-euc_kr.c b/strings/ctype-euc_kr.c index 2d4c68978a3..c387246b4c6 100644 --- a/strings/ctype-euc_kr.c +++ b/strings/ctype-euc_kr.c @@ -8689,8 +8689,8 @@ CHARSET_INFO my_charset_euckr_korean_ci= NULL, /* sort_order_big*/ NULL, /* tab_to_uni */ NULL, /* tab_from_uni */ - "", - "", + NULL, /* state_map */ + NULL, /* ident_map */ 1, /* strxfrm_multiply */ 1, /* mbminlen */ 2, /* mbmaxlen */ @@ -8716,8 +8716,8 @@ CHARSET_INFO my_charset_euckr_bin= NULL, /* sort_order_big*/ NULL, /* tab_to_uni */ NULL, /* tab_from_uni */ - "", - "", + NULL, /* state_map */ + NULL, /* ident_map */ 1, /* strxfrm_multiply */ 1, /* mbminlen */ 2, /* mbmaxlen */ diff --git a/strings/ctype-extra.c b/strings/ctype-extra.c index 51a9531fbf5..baf1d319b00 100644 --- a/strings/ctype-extra.c +++ b/strings/ctype-extra.c @@ -24,20 +24,22 @@ CHARSET_INFO compiled_charsets[] = { NullS, /* cs name */ NullS, /* name */ NullS, /* comment */ - NULL, - NULL, - NULL, - NULL, + NULL, /* tailoring */ + NULL, /* ctype */ + NULL, /* to_lower */ + NULL, /* to_upper */ + NULL, /* sort_order */ NULL, /* sort_order_big*/ NULL, /* tab_to_uni */ NULL, /* tab_from_uni */ - "","", - 0, - 0, - 0, - 0, - 0, - NULL, - NULL + NULL, /* state_map */ + NULL, /* ident_map */ + 0, /* strxfrm_mul */ + 0, /* mbminlen */ + 0, /* mbmaxlen */ + 0, /* min_sort_ord */ + 0, /* max_sort_ord */ + NULL, /* cset handler */ + NULL /* coll handler */ } }; diff --git a/strings/ctype-gb2312.c b/strings/ctype-gb2312.c index 49ca736a3c2..fe1f72e7eda 100644 --- a/strings/ctype-gb2312.c +++ b/strings/ctype-gb2312.c @@ -5740,8 +5740,8 @@ CHARSET_INFO my_charset_gb2312_chinese_ci= NULL, /* tab_to_uni */ NULL, /* tab_from_uni */ NULL, /* sort_order_big*/ - "", - "", + NULL, /* state_map */ + NULL, /* ident_map */ 1, /* strxfrm_multiply */ 1, /* mbminlen */ 2, /* mbmaxlen */ @@ -5766,8 +5766,8 @@ CHARSET_INFO my_charset_gb2312_bin= NULL, /* tab_to_uni */ NULL, /* tab_from_uni */ NULL, /* sort_order_big*/ - "", - "", + NULL, /* state_map */ + NULL, /* ident_map */ 1, /* strxfrm_multiply */ 1, /* mbminlen */ 2, /* mbmaxlen */ diff --git a/strings/ctype-gbk.c b/strings/ctype-gbk.c index 0273feb4c2c..8b659cb55f9 100644 --- a/strings/ctype-gbk.c +++ b/strings/ctype-gbk.c @@ -9970,8 +9970,8 @@ CHARSET_INFO my_charset_gbk_chinese_ci= NULL, /* tab_to_uni */ NULL, /* tab_from_uni */ NULL, /* sort_order_big*/ - "", - "", + NULL, /* state_map */ + NULL, /* ident_map */ 1, /* strxfrm_multiply */ 1, /* mbminlen */ 2, /* mbmaxlen */ @@ -9996,8 +9996,8 @@ CHARSET_INFO my_charset_gbk_bin= NULL, /* tab_to_uni */ NULL, /* tab_from_uni */ NULL, /* sort_order_big*/ - "", - "", + NULL, /* state_map */ + NULL, /* ident_map */ 1, /* strxfrm_multiply */ 1, /* mbminlen */ 2, /* mbmaxlen */ diff --git a/strings/ctype-latin1.c b/strings/ctype-latin1.c index fe39303e2ac..03d4e71377b 100644 --- a/strings/ctype-latin1.c +++ b/strings/ctype-latin1.c @@ -420,7 +420,8 @@ CHARSET_INFO my_charset_latin1= NULL, /* sort_order_big*/ cs_to_uni, /* tab_to_uni */ NULL, /* tab_from_uni */ - "","", + NULL, /* state_map */ + NULL, /* ident_map */ 1, /* strxfrm_multiply */ 1, /* mbminlen */ 1, /* mbmaxlen */ @@ -699,7 +700,8 @@ CHARSET_INFO my_charset_latin1_german2_ci= NULL, /* sort_order_big*/ cs_to_uni, /* tab_to_uni */ NULL, /* tab_from_uni */ - "","", + NULL, /* state_map */ + NULL, /* ident_map */ 2, /* strxfrm_multiply */ 1, /* mbminlen */ 1, /* mbmaxlen */ @@ -725,8 +727,8 @@ CHARSET_INFO my_charset_latin1_bin= NULL, /* sort_order_big*/ cs_to_uni, /* tab_to_uni */ NULL, /* tab_from_uni */ - "", - "", + NULL, /* state_map */ + NULL, /* ident_map */ 1, /* strxfrm_multiply */ 1, /* mbminlen */ 1, /* mbmaxlen */ diff --git a/strings/ctype-sjis.c b/strings/ctype-sjis.c index 22c58360348..b4a131d3410 100644 --- a/strings/ctype-sjis.c +++ b/strings/ctype-sjis.c @@ -4587,8 +4587,8 @@ CHARSET_INFO my_charset_sjis_japanese_ci= NULL, /* tab_to_uni */ NULL, /* tab_from_uni */ NULL, /* sort_order_big*/ - "", - "", + NULL, /* state_map */ + NULL, /* ident_map */ 1, /* strxfrm_multiply */ 1, /* mbminlen */ 2, /* mbmaxlen */ @@ -4613,8 +4613,8 @@ CHARSET_INFO my_charset_sjis_bin= NULL, /* tab_to_uni */ NULL, /* tab_from_uni */ NULL, /* sort_order_big*/ - "", - "", + NULL, /* state_map */ + NULL, /* ident_map */ 1, /* strxfrm_multiply */ 1, /* mbminlen */ 2, /* mbmaxlen */ diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c index b2b1ab98352..79ac2079720 100644 --- a/strings/ctype-tis620.c +++ b/strings/ctype-tis620.c @@ -959,8 +959,8 @@ CHARSET_INFO my_charset_tis620_thai_ci= NULL, /* tab_to_uni */ NULL, /* tab_from_uni */ NULL, /* sort_order_big*/ - "", - "", + NULL, /* state_map */ + NULL, /* ident_map */ 4, /* strxfrm_multiply */ 1, /* mbminlen */ 1, /* mbmaxlen */ @@ -985,8 +985,8 @@ CHARSET_INFO my_charset_tis620_bin= NULL, /* tab_to_uni */ NULL, /* tab_from_uni */ NULL, /* sort_order_big*/ - "", - "", + NULL, /* state_map */ + NULL, /* ident_map */ 1, /* strxfrm_multiply */ 1, /* mbminlen */ 1, /* mbmaxlen */ diff --git a/strings/ctype-uca.c b/strings/ctype-uca.c index 75e2c06eec2..e6b68b8c9b2 100644 --- a/strings/ctype-uca.c +++ b/strings/ctype-uca.c @@ -7063,8 +7063,8 @@ CHARSET_INFO my_charset_ucs2_general_uca= uca_weight, /* sort_order_big*/ NULL, /* tab_to_uni */ NULL, /* tab_from_uni */ - "", - "", + NULL, /* state_map */ + NULL, /* ident_map */ 8, /* strxfrm_multiply */ 2, /* mbminlen */ 2, /* mbmaxlen */ diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c index d1ba63b8b84..bdf9b0f9252 100644 --- a/strings/ctype-ucs2.c +++ b/strings/ctype-ucs2.c @@ -1439,8 +1439,8 @@ CHARSET_INFO my_charset_ucs2_general_ci= NULL, /* tab_to_uni */ NULL, /* tab_from_uni */ NULL, /* sort_order_big*/ - "", - "", + NULL, /* state_map */ + NULL, /* ident_map */ 1, /* strxfrm_multiply */ 2, /* mbminlen */ 2, /* mbmaxlen */ @@ -1465,8 +1465,8 @@ CHARSET_INFO my_charset_ucs2_bin= NULL, /* sort_order_big*/ NULL, /* tab_to_uni */ NULL, /* tab_from_uni */ - "", - "", + NULL, /* state_map */ + NULL, /* ident_map */ 1, /* strxfrm_multiply */ 2, /* mbminlen */ 2, /* mbmaxlen */ diff --git a/strings/ctype-ujis.c b/strings/ctype-ujis.c index 668dc7beb8b..f28ea165f80 100644 --- a/strings/ctype-ujis.c +++ b/strings/ctype-ujis.c @@ -8476,8 +8476,8 @@ CHARSET_INFO my_charset_ujis_japanese_ci= NULL, /* tab_to_uni */ NULL, /* tab_from_uni */ NULL, /* sort_order_big*/ - "", - "", + NULL, /* state_map */ + NULL, /* ident_map */ 1, /* strxfrm_multiply */ 1, /* mbminlen */ 3, /* mbmaxlen */ @@ -8503,8 +8503,8 @@ CHARSET_INFO my_charset_ujis_bin= NULL, /* tab_to_uni */ NULL, /* tab_from_uni */ NULL, /* sort_order_big*/ - "", - "", + NULL, /* state_map */ + NULL, /* ident_map */ 1, /* strxfrm_multiply */ 1, /* mbminlen */ 3, /* mbmaxlen */ diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c index 2d0feb1c890..39e9260ffed 100644 --- a/strings/ctype-utf8.c +++ b/strings/ctype-utf8.c @@ -2098,8 +2098,8 @@ CHARSET_INFO my_charset_utf8_general_ci= NULL, /* tab_to_uni */ NULL, /* tab_from_uni */ NULL, /* sort_order_big*/ - "", - "", + NULL, /* state_map */ + NULL, /* ident_map */ 1, /* strxfrm_multiply */ 1, /* mbminlen */ 3, /* mbmaxlen */ @@ -2125,8 +2125,8 @@ CHARSET_INFO my_charset_utf8_bin= NULL, /* tab_to_uni */ NULL, /* tab_from_uni */ NULL, /* sort_order_big*/ - "", - "", + NULL, /* state_map */ + NULL, /* ident_map */ 1, /* strxfrm_multiply */ 1, /* mbminlen */ 3, /* mbmaxlen */ diff --git a/strings/ctype-win1250ch.c b/strings/ctype-win1250ch.c index bb287eb695e..670318a082e 100644 --- a/strings/ctype-win1250ch.c +++ b/strings/ctype-win1250ch.c @@ -631,7 +631,8 @@ CHARSET_INFO my_charset_cp1250_czech_ci = NULL, /* sort_order_big*/ tab_cp1250_uni, /* tab_to_uni */ idx_uni_cp1250, /* tab_from_uni */ - "","", + NULL, /* state_map */ + NULL, /* ident_map */ 2, /* strxfrm_multiply */ 1, /* mbminlen */ 1, /* mbmaxlen */ |