diff options
54 files changed, 2159 insertions, 843 deletions
diff --git a/configure.in b/configure.in index d870bfa4c48..7c0505cb6ac 100644 --- a/configure.in +++ b/configure.in @@ -2401,7 +2401,11 @@ done dnl Always compile latin1 AC_DEFINE(HAVE_CHARSET_latin1) - + +dnl Always compile utf8 +AC_DEFINE(HAVE_CHARSET_utf8) +use_mb=yes + if test "$use_mb" = "yes" then AC_DEFINE(USE_MB) diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index 68a7b940220..12647a32713 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -504,6 +504,7 @@ bool Protocol::net_store_data(const char *from, uint length) return false; } +#if 0 /* The same as Protocol::net_store_data but does the converstion */ bool Protocol::convert_str(const char *from, uint length) @@ -519,3 +520,4 @@ bool Protocol::convert_str(const char *from, uint length) return false; } +#endif diff --git a/myisam/sp_key.c b/myisam/sp_key.c index 82c2b1f8510..f0b53b541b8 100644 --- a/myisam/sp_key.c +++ b/myisam/sp_key.c @@ -47,7 +47,7 @@ uint sp_make_key(register MI_INFO *info, uint keynr, uchar *key, dlen = _mi_calc_blob_length(keyseg->bit_start, pos); memcpy_fixed(&dptr, pos + keyseg->bit_start, sizeof(char*)); - sp_mbr_from_wkb(dptr, dlen, SPDIMS, mbr); + sp_mbr_from_wkb(dptr + 4, dlen - 4, SPDIMS, mbr); /* SRID */ for (i = 0, keyseg = keyinfo->seg; keyseg->type; keyseg++, i++) { diff --git a/mysql-test/r/ctype_collate.result b/mysql-test/r/ctype_collate.result index 21429709d93..07da8c8c75f 100644 --- a/mysql-test/r/ctype_collate.result +++ b/mysql-test/r/ctype_collate.result @@ -523,7 +523,7 @@ Variable_name Value client_collation latin1 SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; charset('a') collation('a') coercibility('a') 'a'='A' -latin1 latin1 2 1 +latin1 latin1 3 1 SET NAMES latin1 COLLATE latin1_bin; SHOW VARIABLES LIKE 'client_collation'; Variable_name Value @@ -538,35 +538,35 @@ Variable_name Value client_collation latin1_bin SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; charset('a') collation('a') coercibility('a') 'a'='A' -latin1 latin1_bin 2 0 +latin1 latin1_bin 3 0 SET NAMES koi8r; SHOW VARIABLES LIKE 'client_collation'; Variable_name Value client_collation koi8r SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; charset('a') collation('a') coercibility('a') 'a'='A' -koi8r koi8r 2 1 +latin1 latin1 3 1 SET COLLATION koi8r_bin; SHOW VARIABLES LIKE 'client_collation'; Variable_name Value client_collation koi8r_bin SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; charset('a') collation('a') coercibility('a') 'a'='A' -koi8r koi8r_bin 2 0 +latin1 latin1 3 1 SET COLLATION DEFAULT; SHOW VARIABLES LIKE 'client_collation'; Variable_name Value client_collation koi8r SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; charset('a') collation('a') coercibility('a') 'a'='A' -koi8r koi8r 2 1 +latin1 latin1 3 1 SET NAMES DEFAULT; SHOW VARIABLES LIKE 'client_collation'; Variable_name Value client_collation latin1 SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; charset('a') collation('a') coercibility('a') 'a'='A' -latin1 latin1 2 1 +latin1 latin1 3 1 SET NAMES latin1 COLLATE koi8r; COLLATION 'koi8r' is not valid for CHARACTER SET 'latin1' SET NAMES 'DEFAULT'; diff --git a/mysql-test/r/ctype_many.result b/mysql-test/r/ctype_many.result index 0bbb0073420..4d31ab6c274 100644 --- a/mysql-test/r/ctype_many.result +++ b/mysql-test/r/ctype_many.result @@ -1,4 +1,5 @@ DROP TABLE IF EXISTS t1; +SET NAMES latin1; CREATE TABLE t1 ( comment CHAR(32) ASCII NOT NULL, koi8_ru_f CHAR(32) CHARACTER SET koi8r NOT NULL @@ -157,8 +158,9 @@ INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ø','CYR CAPIT SOFT SIGN'); INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ü','CYR CAPIT E'); INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'à','CYR CAPIT YU'); INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ñ','CYR CAPIT YA'); -SELECT CONVERT(koi8_ru_f USING utf8),MIN(comment),COUNT(*) FROM t1 GROUP BY 1; -CONVERT(koi8_ru_f USING utf8) MIN(comment) COUNT(*) +SET NAMES utf8; +SELECT koi8_ru_f,MIN(comment),COUNT(*) FROM t1 GROUP BY 1; +koi8_ru_f MIN(comment) COUNT(*) a LAT CAPIT A 2 b LAT CAPIT B 2 c LAT CAPIT C 2 @@ -190,7 +192,8 @@ z LAT CAPIT Z 2 в CYR CAPIT VE 2 г CYR CAPIT GE 2 д CYR CAPIT DE 2 -е CYR CAPIT IE 4 +е CYR CAPIT IE 2 +Ñ‘ CYR CAPIT IO 2 ж CYR CAPIT ZHE 2 з CYR CAPIT ZE 2 и CYR CAPIT I 2 @@ -218,6 +221,7 @@ z LAT CAPIT Z 2 Ñ CYR CAPIT YA 2 ALTER TABLE t1 ADD utf8_f CHAR(32) CHARACTER SET utf8 NOT NULL; UPDATE t1 SET utf8_f=CONVERT(koi8_ru_f USING utf8); +SET NAMES koi8r; SELECT * FROM t1; comment koi8_ru_f utf8_f LAT SMALL A a a @@ -272,70 +276,70 @@ LAT CAPIT W W W LAT CAPIT X X X LAT CAPIT Y Y Y LAT CAPIT Z Z Z -CYR SMALL A Á а -CYR SMALL BE  б -CYR SMALL VE × Ð² -CYR SMALL GE Ç Ð³ -CYR SMALL DE Ä Ð´ -CYR SMALL IE Šе -CYR SMALL IO £ Ñ‘ -CYR SMALL ZHE Ö Ð¶ -CYR SMALL ZE Ú Ð· -CYR SMALL I É Ð¸ -CYR SMALL KA Ë Ðº -CYR SMALL EL Ì Ð» -CYR SMALL EM Í Ð¼ -CYR SMALL EN Πн -CYR SMALL O Ï Ð¾ -CYR SMALL PE Рп -CYR SMALL ER Ò Ñ€ -CYR SMALL ES Ó Ñ -CYR SMALL TE Ô Ñ‚ -CYR SMALL U Õ Ñƒ -CYR SMALL EF Æ Ñ„ -CYR SMALL HA È Ñ… -CYR SMALL TSE à ц -CYR SMALL CHE Þ Ñ‡ -CYR SMALL SHA Û Ñˆ -CYR SMALL SCHA Ý Ñ‰ -CYR SMALL HARD SIGN ß ÑŠ -CYR SMALL YERU Ù Ñ‹ -CYR SMALL SOFT SIGN Ø ÑŒ -CYR SMALL E Ü Ñ -CYR SMALL YU À ÑŽ -CYR SMALL YA Ñ Ñ -CYR CAPIT A á Ð -CYR CAPIT BE â Б -CYR CAPIT VE ÷ Ð’ -CYR CAPIT GE ç Г -CYR CAPIT DE ä Д -CYR CAPIT IE å Е -CYR CAPIT IO ³ Ð -CYR CAPIT ZHE ö Ж -CYR CAPIT ZE ú З -CYR CAPIT I é И -CYR CAPIT KA ë К -CYR CAPIT EL ì Л -CYR CAPIT EM í Ðœ -CYR CAPIT EN î Ð -CYR CAPIT O ï О -CYR CAPIT PE ð П -CYR CAPIT ER ò Ð -CYR CAPIT ES ó С -CYR CAPIT TE ô Т -CYR CAPIT U õ У -CYR CAPIT EF æ Ф -CYR CAPIT HA è Ð¥ -CYR CAPIT TSE ã Ц -CYR CAPIT CHE þ Ч -CYR CAPIT SHA û Ш -CYR CAPIT SCHA ý Щ -CYR CAPIT HARD SIGN ÿ Ъ -CYR CAPIT YERU ù Ы -CYR CAPIT SOFT SIGN ø Ь -CYR CAPIT E ü Ð -CYR CAPIT YU à Ю -CYR CAPIT YA ñ Я +CYR SMALL A Á Á +CYR SMALL BE   +CYR SMALL VE × × +CYR SMALL GE Ç Ç +CYR SMALL DE Ä Ä +CYR SMALL IE Å Å +CYR SMALL IO £ £ +CYR SMALL ZHE Ö Ö +CYR SMALL ZE Ú Ú +CYR SMALL I É É +CYR SMALL KA Ë Ë +CYR SMALL EL Ì Ì +CYR SMALL EM Í Í +CYR SMALL EN Î Î +CYR SMALL O Ï Ï +CYR SMALL PE Ð Ð +CYR SMALL ER Ò Ò +CYR SMALL ES Ó Ó +CYR SMALL TE Ô Ô +CYR SMALL U Õ Õ +CYR SMALL EF Æ Æ +CYR SMALL HA È È +CYR SMALL TSE à à +CYR SMALL CHE Þ Þ +CYR SMALL SHA Û Û +CYR SMALL SCHA Ý Ý +CYR SMALL HARD SIGN ß ß +CYR SMALL YERU Ù Ù +CYR SMALL SOFT SIGN Ø Ø +CYR SMALL E Ü Ü +CYR SMALL YU À À +CYR SMALL YA Ñ Ñ +CYR CAPIT A á á +CYR CAPIT BE â â +CYR CAPIT VE ÷ ÷ +CYR CAPIT GE ç ç +CYR CAPIT DE ä ä +CYR CAPIT IE å å +CYR CAPIT IO ³ ³ +CYR CAPIT ZHE ö ö +CYR CAPIT ZE ú ú +CYR CAPIT I é é +CYR CAPIT KA ë ë +CYR CAPIT EL ì ì +CYR CAPIT EM í í +CYR CAPIT EN î î +CYR CAPIT O ï ï +CYR CAPIT PE ð ð +CYR CAPIT ER ò ò +CYR CAPIT ES ó ó +CYR CAPIT TE ô ô +CYR CAPIT U õ õ +CYR CAPIT EF æ æ +CYR CAPIT HA è è +CYR CAPIT TSE ã ã +CYR CAPIT CHE þ þ +CYR CAPIT SHA û û +CYR CAPIT SCHA ý ý +CYR CAPIT HARD SIGN ÿ ÿ +CYR CAPIT YERU ù ù +CYR CAPIT SOFT SIGN ø ø +CYR CAPIT E ü ü +CYR CAPIT YU à à +CYR CAPIT YA ñ ñ ALTER TABLE t1 ADD bin_f CHAR(32) BYTE NOT NULL; UPDATE t1 SET bin_f=koi8_ru_f; SELECT COUNT(DISTINCT bin_f),COUNT(DISTINCT koi8_ru_f),COUNT(DISTINCT utf8_f) FROM t1; @@ -429,37 +433,37 @@ w LAT CAPIT W x LAT CAPIT X y LAT CAPIT Y z LAT CAPIT Z -а CYR CAPIT A -б CYR CAPIT BE -в CYR CAPIT VE -г CYR CAPIT GE -д CYR CAPIT DE -е CYR CAPIT IE -ж CYR CAPIT ZHE -з CYR CAPIT ZE -и CYR CAPIT I -к CYR CAPIT KA -л CYR CAPIT EL -м CYR CAPIT EM -н CYR CAPIT EN -о CYR CAPIT O -п CYR CAPIT PE -Ñ€ CYR CAPIT ER -Ñ CYR CAPIT ES -Ñ‚ CYR CAPIT TE -у CYR CAPIT U -Ñ„ CYR CAPIT EF -Ñ… CYR CAPIT HA -ц CYR CAPIT TSE -ч CYR CAPIT CHE -ш CYR CAPIT SHA -щ CYR CAPIT SCHA -ÑŠ CYR CAPIT HARD SIGN -Ñ‹ CYR CAPIT YERU -ÑŒ CYR CAPIT SOFT SIGN -Ñ CYR CAPIT E -ÑŽ CYR CAPIT YU -Ñ CYR CAPIT YA +Á CYR CAPIT A + CYR CAPIT BE +× CYR CAPIT VE +Ç CYR CAPIT GE +Ä CYR CAPIT DE +Å CYR CAPIT IE +Ö CYR CAPIT ZHE +Ú CYR CAPIT ZE +É CYR CAPIT I +Ë CYR CAPIT KA +Ì CYR CAPIT EL +Í CYR CAPIT EM +Î CYR CAPIT EN +Ï CYR CAPIT O +Ð CYR CAPIT PE +Ò CYR CAPIT ER +Ó CYR CAPIT ES +Ô CYR CAPIT TE +Õ CYR CAPIT U +Æ CYR CAPIT EF +È CYR CAPIT HA +à CYR CAPIT TSE +Þ CYR CAPIT CHE +Û CYR CAPIT SHA +Ý CYR CAPIT SCHA +ß CYR CAPIT HARD SIGN +Ù CYR CAPIT YERU +Ø CYR CAPIT SOFT SIGN +Ü CYR CAPIT E +À CYR CAPIT YU +Ñ CYR CAPIT YA SELECT DISTINCT koi8_ru_f FROM t1; koi8_ru_f a @@ -548,37 +552,37 @@ w x y z -а -б -в -г -д -е -ж -з -и -к -л -м -н -о -п -Ñ€ -Ñ -Ñ‚ -у -Ñ„ -Ñ… -ц -ч -ш -щ -ÑŠ -Ñ‹ -ÑŒ -Ñ -ÑŽ -Ñ +Á + +× +Ç +Ä +Å +Ö +Ú +É +Ë +Ì +Í +Î +Ï +Ð +Ò +Ó +Ô +Õ +Æ +È +à +Þ +Û +Ý +ß +Ù +Ø +Ü +À +Ñ SELECT lower(koi8_ru_f) FROM t1 ORDER BY 1 DESC; lower(koi8_ru_f) Ñ @@ -699,70 +703,70 @@ a a SELECT lower(utf8_f) FROM t1 ORDER BY 1 DESC; lower(utf8_f) -Ñ -Ñ -ÑŽ -ÑŽ -Ñ -Ñ -ÑŒ -ÑŒ -Ñ‹ -Ñ‹ -ÑŠ -ÑŠ -щ -щ -ш -ш -ч -ч -ц -ц -Ñ… -Ñ… -Ñ„ -Ñ„ -у -у -Ñ‚ -Ñ‚ -Ñ -Ñ -Ñ€ -Ñ€ -п -п -о -о -н -н -м -м -л -л -к -к -и -и -з -з -ж -ж -е -Ñ‘ -е -Ñ‘ -д -д -г -г -в -в -б -б -а -а +Ñ +Ñ +À +À +Ü +Ü +Ø +Ø +Ù +Ù +ß +ß +Ý +Ý +Û +Û +Þ +Þ +à +à +È +È +Æ +Æ +Õ +Õ +Ô +Ô +Ó +Ó +Ò +Ò +Ð +Ð +Ï +Ï +Î +Î +Í +Í +Ì +Ì +Ë +Ë +É +É +Ú +Ú +Ö +Ö +Å +£ +Å +£ +Ä +Ä +Ç +Ç +× +× + + +Á +Á z z y @@ -1296,6 +1300,7 @@ CYR CAPIT YA CYR CAPIT YA CYR CAPIT YA CYR SMALL YA CYR SMALL YA CYR CAPIT YA CYR SMALL YA CYR SMALL YA +SET NAMES utf8; ALTER TABLE t1 ADD ucs2_f CHAR(32) CHARACTER SET ucs2; ALTER TABLE t1 CHANGE ucs2_f ucs2_f CHAR(32) UNICODE NOT NULL; INSERT INTO t1 (ucs2_f,comment) VALUES (0x0391,'GREEK CAPIT ALPHA'); @@ -1322,10 +1327,291 @@ INSERT INTO t1 (ucs2_f,comment) VALUES (0x0565,'ARMENIAN SMALL ECH'); INSERT INTO t1 (ucs2_f,comment) VALUES (0x0566,'ARMENIAN SMALL ZA'); ALTER TABLE t1 ADD armscii8_f CHAR(32) CHARACTER SET armscii8 NOT NULL; ALTER TABLE t1 ADD greek_f CHAR(32) CHARACTER SET greek NOT NULL; -UPDATE t1 SET greek_f=CONVERT(ucs2_f USING greek) WHERE comment LIKE 'GRE%'; -UPDATE t1 SET armscii8_f=CONVERT(ucs2_f USING armscii8) WHERE comment LIKE 'ARM%'; -UPDATE t1 SET utf8_f=CONVERT(ucs2_f USING utf8) WHERE utf8_f=''; -UPDATE t1 SET ucs2_f=CONVERT(utf8_f USING ucs2) WHERE ucs2_f=''; +UPDATE t1 SET greek_f=CONVERT(ucs2_f USING greek) WHERE comment LIKE _latin2'GRE%'; +UPDATE t1 SET armscii8_f=CONVERT(ucs2_f USING armscii8) WHERE comment LIKE _latin2'ARM%'; +UPDATE t1 SET utf8_f=CONVERT(ucs2_f USING utf8) WHERE utf8_f=_utf8''; +UPDATE t1 SET ucs2_f=CONVERT(utf8_f USING ucs2) WHERE ucs2_f=_ucs2''; +SELECT * FROM t1; +comment koi8_ru_f utf8_f bin_f ucs2_f armscii8_f greek_f +LAT SMALL A a a a a +LAT SMALL B b b b b +LAT SMALL C c c c c +LAT SMALL D d d d d +LAT SMALL E e e e e +LAT SMALL F f f f f +LAT SMALL G g g g g +LAT SMALL H h h h h +LAT SMALL I i i i i +LAT SMALL J j j j j +LAT SMALL K k k k k +LAT SMALL L l l l l +LAT SMALL M m m m m +LAT SMALL N n n n n +LAT SMALL O o o o o +LAT SMALL P p p p p +LAT SMALL Q q q q q +LAT SMALL R r r r r +LAT SMALL S s s s s +LAT SMALL T t t t t +LAT SMALL U u u u u +LAT SMALL V v v v v +LAT SMALL W w w w w +LAT SMALL X x x x x +LAT SMALL Y y y y y +LAT SMALL Z z z z z +LAT CAPIT A A A A A +LAT CAPIT B B B B B +LAT CAPIT C C C C C +LAT CAPIT D D D D D +LAT CAPIT E E E E E +LAT CAPIT F F F F F +LAT CAPIT G G G G G +LAT CAPIT H H H H H +LAT CAPIT I I I I I +LAT CAPIT J J J J J +LAT CAPIT K K K K K +LAT CAPIT L L L L L +LAT CAPIT M M M M M +LAT CAPIT N N N N N +LAT CAPIT O O O O O +LAT CAPIT P P P P P +LAT CAPIT Q Q Q Q Q +LAT CAPIT R R R R R +LAT CAPIT S S S S S +LAT CAPIT T T T T T +LAT CAPIT U U U U U +LAT CAPIT V V V V V +LAT CAPIT W W W W W +LAT CAPIT X X X X X +LAT CAPIT Y Y Y Y Y +LAT CAPIT Z Z Z Z Z +CYR SMALL A а а Á а +CYR SMALL BE б б  б +CYR SMALL VE в в × Ð² +CYR SMALL GE г г Ç Ð³ +CYR SMALL DE д д Ä Ð´ +CYR SMALL IE е е Šе +CYR SMALL IO Ñ‘ Ñ‘ £ Ñ‘ +CYR SMALL ZHE ж ж Ö Ð¶ +CYR SMALL ZE з з Ú Ð· +CYR SMALL I и и É Ð¸ +CYR SMALL KA к к Ë Ðº +CYR SMALL EL л л Ì Ð» +CYR SMALL EM м м Í Ð¼ +CYR SMALL EN н н Πн +CYR SMALL O о о Ï Ð¾ +CYR SMALL PE п п Рп +CYR SMALL ER Ñ€ Ñ€ Ò Ñ€ +CYR SMALL ES Ñ Ñ Ó Ñ +CYR SMALL TE Ñ‚ Ñ‚ Ô Ñ‚ +CYR SMALL U у у Õ Ñƒ +CYR SMALL EF Ñ„ Ñ„ Æ Ñ„ +CYR SMALL HA Ñ… Ñ… È Ñ… +CYR SMALL TSE ц ц à ц +CYR SMALL CHE ч ч Þ Ñ‡ +CYR SMALL SHA ш ш Û Ñˆ +CYR SMALL SCHA щ щ Ý Ñ‰ +CYR SMALL HARD SIGN ÑŠ ÑŠ ß ÑŠ +CYR SMALL YERU Ñ‹ Ñ‹ Ù Ñ‹ +CYR SMALL SOFT SIGN ÑŒ ÑŒ Ø ÑŒ +CYR SMALL E Ñ Ñ Ü Ñ +CYR SMALL YU ÑŽ ÑŽ À ÑŽ +CYR SMALL YA Ñ Ñ Ñ Ñ +CYR CAPIT A Ð Ð á Ð +CYR CAPIT BE Б Б â Б +CYR CAPIT VE Ð’ Ð’ ÷ Ð’ +CYR CAPIT GE Г Г ç Г +CYR CAPIT DE Д Д ä Д +CYR CAPIT IE Е Е å Е +CYR CAPIT IO Ð Ð ³ Ð +CYR CAPIT ZHE Ж Ж ö Ж +CYR CAPIT ZE З З ú З +CYR CAPIT I И И é И +CYR CAPIT KA К К ë К +CYR CAPIT EL Л Л ì Л +CYR CAPIT EM Ðœ Ðœ í Ðœ +CYR CAPIT EN Ð Ð î Ð +CYR CAPIT O О О ï О +CYR CAPIT PE П П ð П +CYR CAPIT ER Ð Ð ò +CYR CAPIT ES С С ó С +CYR CAPIT TE Т Т ô Т +CYR CAPIT U У У õ У +CYR CAPIT EF Ф Ф æ Ф +CYR CAPIT HA Ð¥ Ð¥ è Ð¥ +CYR CAPIT TSE Ц Ц ã Ц +CYR CAPIT CHE Ч Ч þ Ч +CYR CAPIT SHA Ш Ш û Ш +CYR CAPIT SCHA Щ Щ ý Щ +CYR CAPIT HARD SIGN Ъ Ъ ÿ Ъ +CYR CAPIT YERU Ы Ы ù Ы +CYR CAPIT SOFT SIGN Ь Ь ø Ь +CYR CAPIT E Ð Ð ü Ð +CYR CAPIT YU Ю Ю à Ю +CYR CAPIT YA Я Я ñ Я +GREEK CAPIT ALPHA Α Α Α +GREEK CAPIT BETA Î’ Î’ Î’ +GREEK CAPIT GAMMA Γ Γ Γ +GREEK CAPIT DELTA Δ Δ Δ +GREEK CAPIT EPSILON Ε Ε Ε +GREEK SMALL ALPHA α α α +GREEK SMALL BETA β β β +GREEK SMALL GAMMA γ γ γ +GREEK SMALL DELTA δ δ δ +GREEK SMALL EPSILON ε ε ε +ARMENIAN CAPIT AYB Ô± Ô± Ô± +ARMENIAN CAPIT BEN Ô² Ô² Ô² +ARMENIAN CAPIT GIM Ô³ Ô³ Ô³ +ARMENIAN CAPIT DA Ô´ Ô´ Ô´ +ARMENIAN CAPIT ECH Ôµ Ôµ Ôµ +ARMENIAN CAPIT ZA Ô¶ Ô¶ Ô¶ +ARMENIAN SMALL YAB Õ¡ Õ¡ Õ¡ +ARMENIAN SMALL BEN Õ¢ Õ¢ Õ¢ +ARMENIAN SMALL GIM Õ£ Õ£ Õ£ +ARMENIAN SMALL DA Õ¤ Õ¤ Õ¤ +ARMENIAN SMALL ECH Õ¥ Õ¥ Õ¥ +ARMENIAN SMALL ZA Õ¦ Õ¦ Õ¦ +SET NAMES 'binary'; +SELECT * FROM t1; +comment koi8_ru_f utf8_f bin_f ucs2_f armscii8_f greek_f +LAT SMALL A a a a +LAT SMALL B b b b +LAT SMALL C c c c +LAT SMALL D d d d +LAT SMALL E e e e +LAT SMALL F f f f +LAT SMALL G g g g +LAT SMALL H h h h +LAT SMALL I i i i +LAT SMALL J j j j +LAT SMALL K k k k +LAT SMALL L l l l +LAT SMALL M m m m +LAT SMALL N n n n +LAT SMALL O o o o +LAT SMALL P p p p +LAT SMALL Q q q q +LAT SMALL R r r r +LAT SMALL S s s s +LAT SMALL T t t t +LAT SMALL U u u u +LAT SMALL V v v v +LAT SMALL W w w w +LAT SMALL X x x x +LAT SMALL Y y y y +LAT SMALL Z z z z +LAT CAPIT A A A A +LAT CAPIT B B B B +LAT CAPIT C C C C +LAT CAPIT D D D D +LAT CAPIT E E E E +LAT CAPIT F F F F +LAT CAPIT G G G G +LAT CAPIT H H H H +LAT CAPIT I I I I +LAT CAPIT J J J J +LAT CAPIT K K K K +LAT CAPIT L L L L +LAT CAPIT M M M M +LAT CAPIT N N N N +LAT CAPIT O O O O +LAT CAPIT P P P P +LAT CAPIT Q Q Q Q +LAT CAPIT R R R R +LAT CAPIT S S S S +LAT CAPIT T T T T +LAT CAPIT U U U U +LAT CAPIT V V V V +LAT CAPIT W W W W +LAT CAPIT X X X X +LAT CAPIT Y Y Y Y +LAT CAPIT Z Z Z Z +CYR SMALL A Á а Á 0 +CYR SMALL BE  б  1 +CYR SMALL VE × Ð² × 2 +CYR SMALL GE Ç Ð³ Ç 3 +CYR SMALL DE Ä Ð´ Ä 4 +CYR SMALL IE Šе Å 5 +CYR SMALL IO £ Ñ‘ £ Q +CYR SMALL ZHE Ö Ð¶ Ö 6 +CYR SMALL ZE Ú Ð· Ú 7 +CYR SMALL I É Ð¸ É 8 +CYR SMALL KA Ë Ðº Ë : +CYR SMALL EL Ì Ð» Ì ; +CYR SMALL EM Í Ð¼ Í < +CYR SMALL EN Πн Î = +CYR SMALL O Ï Ð¾ Ï > +CYR SMALL PE Рп Ð ? +CYR SMALL ER Ò Ñ€ Ò @ +CYR SMALL ES Ó Ñ Ó A +CYR SMALL TE Ô Ñ‚ Ô B +CYR SMALL U Õ Ñƒ Õ C +CYR SMALL EF Æ Ñ„ Æ D +CYR SMALL HA È Ñ… È E +CYR SMALL TSE à ц à F +CYR SMALL CHE Þ Ñ‡ Þ G +CYR SMALL SHA Û Ñˆ Û H +CYR SMALL SCHA Ý Ñ‰ Ý I +CYR SMALL HARD SIGN ß ÑŠ ß J +CYR SMALL YERU Ù Ñ‹ Ù K +CYR SMALL SOFT SIGN Ø ÑŒ Ø L +CYR SMALL E Ü Ñ Ü M +CYR SMALL YU À ÑŽ À N +CYR SMALL YA Ñ Ñ Ñ O +CYR CAPIT A á Ð á +CYR CAPIT BE â Б â +CYR CAPIT VE ÷ Ð’ ÷ +CYR CAPIT GE ç Г ç +CYR CAPIT DE ä Д ä +CYR CAPIT IE å Е å +CYR CAPIT IO ³ Ð ³ +CYR CAPIT ZHE ö Ж ö +CYR CAPIT ZE ú З ú +CYR CAPIT I é И é +CYR CAPIT KA ë К ë +CYR CAPIT EL ì Л ì +CYR CAPIT EM í Ðœ í +CYR CAPIT EN î Ð î +CYR CAPIT O ï О ï +CYR CAPIT PE ð П ð +CYR CAPIT ER ò Ð ò +CYR CAPIT ES ó С ó ! +CYR CAPIT TE ô Т ô " +CYR CAPIT U õ У õ # +CYR CAPIT EF æ Ф æ $ +CYR CAPIT HA è Ð¥ è % +CYR CAPIT TSE ã Ц ã & +CYR CAPIT CHE þ Ч þ ' +CYR CAPIT SHA û Ш û ( +CYR CAPIT SCHA ý Щ ý ) +CYR CAPIT HARD SIGN ÿ Ъ ÿ * +CYR CAPIT YERU ù Ы ù + +CYR CAPIT SOFT SIGN ø Ь ø , +CYR CAPIT E ü Ð ü - +CYR CAPIT YU à Ю à . +CYR CAPIT YA ñ Я ñ / +GREEK CAPIT ALPHA Α ‘ Á +GREEK CAPIT BETA Î’ ’  +GREEK CAPIT GAMMA Γ “ à +GREEK CAPIT DELTA Δ ” Ä +GREEK CAPIT EPSILON Ε • Å +GREEK SMALL ALPHA α ± á +GREEK SMALL BETA β ² â +GREEK SMALL GAMMA γ ³ ã +GREEK SMALL DELTA δ ´ ä +GREEK SMALL EPSILON ε µ å +ARMENIAN CAPIT AYB Ô± 1 ² +ARMENIAN CAPIT BEN Ô² 2 ´ +ARMENIAN CAPIT GIM Ô³ 3 ¶ +ARMENIAN CAPIT DA Ô´ 4 ¸ +ARMENIAN CAPIT ECH Ôµ 5 º +ARMENIAN CAPIT ZA Ô¶ 6 ¼ +ARMENIAN SMALL YAB Õ¡ a ³ +ARMENIAN SMALL BEN Õ¢ b µ +ARMENIAN SMALL GIM Õ£ c · +ARMENIAN SMALL DA Õ¤ d ¹ +ARMENIAN SMALL ECH Õ¥ e » +ARMENIAN SMALL ZA Õ¦ f ½ SELECT min(comment),count(*) FROM t1 GROUP BY ucs2_f; min(comment) count(*) LAT CAPIT A 2 diff --git a/mysql-test/r/ctype_recoding.result b/mysql-test/r/ctype_recoding.result new file mode 100644 index 00000000000..3422595c71f --- /dev/null +++ b/mysql-test/r/ctype_recoding.result @@ -0,0 +1,43 @@ +SET NAMES koi8r; +DROP TABLE IF EXISTS ÔÁÂÌÉÃÁ; +CREATE TABLE ÔÁÂÌÉÃÁ +( +ÐÏÌÅ CHAR(32) CHARACTER SET koi8r NOT NULL +); +SHOW TABLES; +Tables_in_test +ÔÁÂÌÉÃÁ +SHOW CREATE TABLE ÔÁÂÌÉÃÁ; +Table Create Table +ÔÁÂÌÉÃÁ CREATE TABLE `ÔÁÂÌÉÃÁ` ( + `ÐÏÌÅ` char(32) character set koi8r NOT NULL default '' +) TYPE=MyISAM CHARSET=latin1 +SHOW FIELDS FROM ÔÁÂÌÉÃÁ; +Field Type Collation Null Key Default Extra +ÐÏÌÅ char(32) character set koi8r koi8r +SET NAMES cp1251; +SHOW TABLES; +Tables_in_test +òàáëèöà +SHOW CREATE TABLE òàáëèöà; +Table Create Table +òàáëèöà CREATE TABLE `òàáëèöà` ( + `ïîëå` char(32) character set koi8r NOT NULL default '' +) TYPE=MyISAM CHARSET=latin1 +SHOW FIELDS FROM òàáëèöà; +Field Type Collation Null Key Default Extra +ïîëå char(32) character set koi8r koi8r +SET NAMES utf8; +SHOW TABLES; +Tables_in_test +таблица +SHOW CREATE TABLE таблица; +Table Create Table +таблица CREATE TABLE `таблица` ( + `поле` char(32) character set koi8r NOT NULL default '' +) TYPE=MyISAM CHARSET=latin1 +SHOW FIELDS FROM таблица; +Field Type Collation Null Key Default Extra +поле char(32) character set koi8r koi8r +SET NAMES koi8r; +DROP TABLE ÔÁÂÌÉÃÁ; diff --git a/mysql-test/r/func_system.result b/mysql-test/r/func_system.result index 83c2ad6e020..83e78a30396 100644 --- a/mysql-test/r/func_system.result +++ b/mysql-test/r/func_system.result @@ -1,8 +1,8 @@ select database(),user() like "%@%"; database() user() like "%@%" test 1 -select version()>="3.23.29"; -version()>="3.23.29" +select version()>=_utf8"3.23.29"; +version()>=_utf8"3.23.29" 1 select TRUE,FALSE,NULL; TRUE FALSE NULL diff --git a/mysql-test/r/gis-rtree.result b/mysql-test/r/gis-rtree.result new file mode 100644 index 00000000000..173a065adc2 --- /dev/null +++ b/mysql-test/r/gis-rtree.result @@ -0,0 +1,712 @@ +DROP TABLE IF EXISTS t1, t2; +CREATE TABLE t1 ( +fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY, +g GEOMETRY NOT NULL, +SPATIAL KEY(g) +) TYPE=MyISAM; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `fid` int(11) NOT NULL auto_increment, + `g` geometry NOT NULL default '', + PRIMARY KEY (`fid`), + SPATIAL KEY `g` (`g`(32)) +) TYPE=MyISAM CHARSET=latin1 +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(150 150, 150 150)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(149 149, 151 151)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(148 148, 152 152)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(147 147, 153 153)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(146 146, 154 154)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(145 145, 155 155)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(144 144, 156 156)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(143 143, 157 157)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(142 142, 158 158)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(141 141, 159 159)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(140 140, 160 160)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(139 139, 161 161)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(138 138, 162 162)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(137 137, 163 163)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(136 136, 164 164)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(135 135, 165 165)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(134 134, 166 166)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(133 133, 167 167)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(132 132, 168 168)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(131 131, 169 169)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(130 130, 170 170)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(129 129, 171 171)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(128 128, 172 172)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(127 127, 173 173)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(126 126, 174 174)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(125 125, 175 175)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(124 124, 176 176)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(123 123, 177 177)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(122 122, 178 178)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(121 121, 179 179)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(120 120, 180 180)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(119 119, 181 181)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(118 118, 182 182)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(117 117, 183 183)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(116 116, 184 184)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(115 115, 185 185)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(114 114, 186 186)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(113 113, 187 187)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(112 112, 188 188)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(111 111, 189 189)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(110 110, 190 190)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(109 109, 191 191)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(108 108, 192 192)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(107 107, 193 193)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(106 106, 194 194)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(105 105, 195 195)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(104 104, 196 196)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(103 103, 197 197)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(102 102, 198 198)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(101 101, 199 199)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(100 100, 200 200)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(99 99, 201 201)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(98 98, 202 202)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(97 97, 203 203)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(96 96, 204 204)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(95 95, 205 205)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(94 94, 206 206)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(93 93, 207 207)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(92 92, 208 208)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(91 91, 209 209)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(90 90, 210 210)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(89 89, 211 211)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(88 88, 212 212)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(87 87, 213 213)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(86 86, 214 214)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(85 85, 215 215)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(84 84, 216 216)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(83 83, 217 217)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(82 82, 218 218)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(81 81, 219 219)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(80 80, 220 220)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(79 79, 221 221)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(78 78, 222 222)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(77 77, 223 223)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(76 76, 224 224)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(75 75, 225 225)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(74 74, 226 226)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(73 73, 227 227)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(72 72, 228 228)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(71 71, 229 229)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(70 70, 230 230)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(69 69, 231 231)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(68 68, 232 232)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(67 67, 233 233)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(66 66, 234 234)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(65 65, 235 235)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(64 64, 236 236)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(63 63, 237 237)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(62 62, 238 238)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(61 61, 239 239)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(60 60, 240 240)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(59 59, 241 241)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(58 58, 242 242)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(57 57, 243 243)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(56 56, 244 244)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(55 55, 245 245)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(54 54, 246 246)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(53 53, 247 247)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(52 52, 248 248)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(51 51, 249 249)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(50 50, 250 250)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(49 49, 251 251)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(48 48, 252 252)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(47 47, 253 253)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(46 46, 254 254)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(45 45, 255 255)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(44 44, 256 256)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(43 43, 257 257)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(42 42, 258 258)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(41 41, 259 259)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(40 40, 260 260)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(39 39, 261 261)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(38 38, 262 262)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(37 37, 263 263)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(36 36, 264 264)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(35 35, 265 265)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(34 34, 266 266)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(33 33, 267 267)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(32 32, 268 268)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(31 31, 269 269)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(30 30, 270 270)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(29 29, 271 271)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(28 28, 272 272)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(27 27, 273 273)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(26 26, 274 274)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(25 25, 275 275)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(24 24, 276 276)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(23 23, 277 277)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(22 22, 278 278)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(21 21, 279 279)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(20 20, 280 280)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(19 19, 281 281)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(18 18, 282 282)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(17 17, 283 283)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(16 16, 284 284)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(15 15, 285 285)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(14 14, 286 286)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(13 13, 287 287)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(12 12, 288 288)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(11 11, 289 289)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(10 10, 290 290)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(9 9, 291 291)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(8 8, 292 292)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(7 7, 293 293)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(6 6, 294 294)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(5 5, 295 295)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(4 4, 296 296)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(3 3, 297 297)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(2 2, 298 298)')); +INSERT INTO t1 (g) VALUES (GeomFromText('LineString(1 1, 299 299)')); +SELECT count(*) FROM t1; +count(*) +150 +EXPLAIN SELECT fid, AsText(g) FROM t1 WHERE Within(g, GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))')); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range g g 32 NULL 4 Using where +SELECT fid, AsText(g) FROM t1 WHERE Within(g, GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))')); +fid AsText(g) +1 LINESTRING(150 150,150 150) +11 LINESTRING(140 140,160 160) +2 LINESTRING(149 149,151 151) +3 LINESTRING(148 148,152 152) +4 LINESTRING(147 147,153 153) +5 LINESTRING(146 146,154 154) +6 LINESTRING(145 145,155 155) +7 LINESTRING(144 144,156 156) +8 LINESTRING(143 143,157 157) +9 LINESTRING(142 142,158 158) +10 LINESTRING(141 141,159 159) +DROP TABLE t1; +CREATE TABLE t2 ( +fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY, +g GEOMETRY NOT NULL +) TYPE=MyISAM; +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 10 * 10 - 9), Point(10 * 10, 10 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 9 * 10 - 9), Point(10 * 10, 9 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 8 * 10 - 9), Point(10 * 10, 8 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 7 * 10 - 9), Point(10 * 10, 7 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 6 * 10 - 9), Point(10 * 10, 6 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 5 * 10 - 9), Point(10 * 10, 5 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 4 * 10 - 9), Point(10 * 10, 4 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 3 * 10 - 9), Point(10 * 10, 3 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 2 * 10 - 9), Point(10 * 10, 2 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 1 * 10 - 9), Point(10 * 10, 1 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 10 * 10 - 9), Point(9 * 10, 10 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 9 * 10 - 9), Point(9 * 10, 9 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 8 * 10 - 9), Point(9 * 10, 8 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 7 * 10 - 9), Point(9 * 10, 7 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 6 * 10 - 9), Point(9 * 10, 6 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 5 * 10 - 9), Point(9 * 10, 5 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 4 * 10 - 9), Point(9 * 10, 4 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 3 * 10 - 9), Point(9 * 10, 3 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 2 * 10 - 9), Point(9 * 10, 2 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 1 * 10 - 9), Point(9 * 10, 1 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 10 * 10 - 9), Point(8 * 10, 10 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 9 * 10 - 9), Point(8 * 10, 9 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 8 * 10 - 9), Point(8 * 10, 8 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 7 * 10 - 9), Point(8 * 10, 7 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 6 * 10 - 9), Point(8 * 10, 6 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 5 * 10 - 9), Point(8 * 10, 5 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 4 * 10 - 9), Point(8 * 10, 4 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 3 * 10 - 9), Point(8 * 10, 3 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 2 * 10 - 9), Point(8 * 10, 2 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 1 * 10 - 9), Point(8 * 10, 1 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 10 * 10 - 9), Point(7 * 10, 10 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 9 * 10 - 9), Point(7 * 10, 9 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 8 * 10 - 9), Point(7 * 10, 8 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 7 * 10 - 9), Point(7 * 10, 7 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 6 * 10 - 9), Point(7 * 10, 6 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 5 * 10 - 9), Point(7 * 10, 5 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 4 * 10 - 9), Point(7 * 10, 4 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 3 * 10 - 9), Point(7 * 10, 3 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 2 * 10 - 9), Point(7 * 10, 2 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 1 * 10 - 9), Point(7 * 10, 1 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 10 * 10 - 9), Point(6 * 10, 10 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 9 * 10 - 9), Point(6 * 10, 9 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 8 * 10 - 9), Point(6 * 10, 8 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 7 * 10 - 9), Point(6 * 10, 7 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 6 * 10 - 9), Point(6 * 10, 6 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 5 * 10 - 9), Point(6 * 10, 5 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 4 * 10 - 9), Point(6 * 10, 4 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 3 * 10 - 9), Point(6 * 10, 3 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 2 * 10 - 9), Point(6 * 10, 2 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 1 * 10 - 9), Point(6 * 10, 1 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 10 * 10 - 9), Point(5 * 10, 10 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 9 * 10 - 9), Point(5 * 10, 9 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 8 * 10 - 9), Point(5 * 10, 8 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 7 * 10 - 9), Point(5 * 10, 7 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 6 * 10 - 9), Point(5 * 10, 6 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 5 * 10 - 9), Point(5 * 10, 5 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 4 * 10 - 9), Point(5 * 10, 4 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 3 * 10 - 9), Point(5 * 10, 3 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 2 * 10 - 9), Point(5 * 10, 2 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 1 * 10 - 9), Point(5 * 10, 1 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 10 * 10 - 9), Point(4 * 10, 10 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 9 * 10 - 9), Point(4 * 10, 9 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 8 * 10 - 9), Point(4 * 10, 8 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 7 * 10 - 9), Point(4 * 10, 7 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 6 * 10 - 9), Point(4 * 10, 6 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 5 * 10 - 9), Point(4 * 10, 5 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 4 * 10 - 9), Point(4 * 10, 4 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 3 * 10 - 9), Point(4 * 10, 3 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 2 * 10 - 9), Point(4 * 10, 2 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 1 * 10 - 9), Point(4 * 10, 1 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 10 * 10 - 9), Point(3 * 10, 10 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 9 * 10 - 9), Point(3 * 10, 9 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 8 * 10 - 9), Point(3 * 10, 8 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 7 * 10 - 9), Point(3 * 10, 7 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 6 * 10 - 9), Point(3 * 10, 6 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 5 * 10 - 9), Point(3 * 10, 5 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 4 * 10 - 9), Point(3 * 10, 4 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 3 * 10 - 9), Point(3 * 10, 3 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 2 * 10 - 9), Point(3 * 10, 2 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 1 * 10 - 9), Point(3 * 10, 1 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 10 * 10 - 9), Point(2 * 10, 10 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 9 * 10 - 9), Point(2 * 10, 9 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 8 * 10 - 9), Point(2 * 10, 8 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 7 * 10 - 9), Point(2 * 10, 7 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 6 * 10 - 9), Point(2 * 10, 6 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 5 * 10 - 9), Point(2 * 10, 5 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 4 * 10 - 9), Point(2 * 10, 4 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 3 * 10 - 9), Point(2 * 10, 3 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 2 * 10 - 9), Point(2 * 10, 2 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 1 * 10 - 9), Point(2 * 10, 1 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 10 * 10 - 9), Point(1 * 10, 10 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 9 * 10 - 9), Point(1 * 10, 9 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 8 * 10 - 9), Point(1 * 10, 8 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 7 * 10 - 9), Point(1 * 10, 7 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 6 * 10 - 9), Point(1 * 10, 6 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 5 * 10 - 9), Point(1 * 10, 5 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 4 * 10 - 9), Point(1 * 10, 4 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 3 * 10 - 9), Point(1 * 10, 3 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 2 * 10 - 9), Point(1 * 10, 2 * 10)))); +INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 1 * 10 - 9), Point(1 * 10, 1 * 10)))); +ALTER TABLE t2 ADD SPATIAL KEY(g); +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `fid` int(11) NOT NULL auto_increment, + `g` geometry NOT NULL default '', + PRIMARY KEY (`fid`), + SPATIAL KEY `g` (`g`(32)) +) TYPE=MyISAM CHARSET=latin1 +SELECT count(*) FROM t2; +count(*) +100 +EXPLAIN SELECT fid, AsText(g) FROM t2 WHERE Within(g, +GeomFromText('Polygon((40 40,60 40,60 60,40 60,40 40))')); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 range g g 32 NULL 4 Using where +SELECT fid, AsText(g) FROM t2 WHERE Within(g, +GeomFromText('Polygon((40 40,60 40,60 60,40 60,40 40))')); +fid AsText(g) +45 LINESTRING(51 51,60 60) +55 LINESTRING(41 51,50 60) +56 LINESTRING(41 41,50 50) +46 LINESTRING(51 41,60 50) +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 10 * 10 - 9), Point(10 * 10, 10 * 10))))); +SELECT count(*) FROM t2; +count(*) +99 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 9 * 10 - 9), Point(10 * 10, 9 * 10))))); +SELECT count(*) FROM t2; +count(*) +98 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 8 * 10 - 9), Point(10 * 10, 8 * 10))))); +SELECT count(*) FROM t2; +count(*) +97 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 7 * 10 - 9), Point(10 * 10, 7 * 10))))); +SELECT count(*) FROM t2; +count(*) +96 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 6 * 10 - 9), Point(10 * 10, 6 * 10))))); +SELECT count(*) FROM t2; +count(*) +95 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 5 * 10 - 9), Point(10 * 10, 5 * 10))))); +SELECT count(*) FROM t2; +count(*) +94 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 4 * 10 - 9), Point(10 * 10, 4 * 10))))); +SELECT count(*) FROM t2; +count(*) +93 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 3 * 10 - 9), Point(10 * 10, 3 * 10))))); +SELECT count(*) FROM t2; +count(*) +92 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 2 * 10 - 9), Point(10 * 10, 2 * 10))))); +SELECT count(*) FROM t2; +count(*) +91 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 1 * 10 - 9), Point(10 * 10, 1 * 10))))); +SELECT count(*) FROM t2; +count(*) +90 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 10 * 10 - 9), Point(9 * 10, 10 * 10))))); +SELECT count(*) FROM t2; +count(*) +89 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 9 * 10 - 9), Point(9 * 10, 9 * 10))))); +SELECT count(*) FROM t2; +count(*) +88 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 8 * 10 - 9), Point(9 * 10, 8 * 10))))); +SELECT count(*) FROM t2; +count(*) +87 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 7 * 10 - 9), Point(9 * 10, 7 * 10))))); +SELECT count(*) FROM t2; +count(*) +86 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 6 * 10 - 9), Point(9 * 10, 6 * 10))))); +SELECT count(*) FROM t2; +count(*) +85 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 5 * 10 - 9), Point(9 * 10, 5 * 10))))); +SELECT count(*) FROM t2; +count(*) +84 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 4 * 10 - 9), Point(9 * 10, 4 * 10))))); +SELECT count(*) FROM t2; +count(*) +83 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 3 * 10 - 9), Point(9 * 10, 3 * 10))))); +SELECT count(*) FROM t2; +count(*) +82 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 2 * 10 - 9), Point(9 * 10, 2 * 10))))); +SELECT count(*) FROM t2; +count(*) +81 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 1 * 10 - 9), Point(9 * 10, 1 * 10))))); +SELECT count(*) FROM t2; +count(*) +80 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 10 * 10 - 9), Point(8 * 10, 10 * 10))))); +SELECT count(*) FROM t2; +count(*) +79 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 9 * 10 - 9), Point(8 * 10, 9 * 10))))); +SELECT count(*) FROM t2; +count(*) +78 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 8 * 10 - 9), Point(8 * 10, 8 * 10))))); +SELECT count(*) FROM t2; +count(*) +77 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 7 * 10 - 9), Point(8 * 10, 7 * 10))))); +SELECT count(*) FROM t2; +count(*) +76 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 6 * 10 - 9), Point(8 * 10, 6 * 10))))); +SELECT count(*) FROM t2; +count(*) +75 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 5 * 10 - 9), Point(8 * 10, 5 * 10))))); +SELECT count(*) FROM t2; +count(*) +74 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 4 * 10 - 9), Point(8 * 10, 4 * 10))))); +SELECT count(*) FROM t2; +count(*) +73 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 3 * 10 - 9), Point(8 * 10, 3 * 10))))); +SELECT count(*) FROM t2; +count(*) +72 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 2 * 10 - 9), Point(8 * 10, 2 * 10))))); +SELECT count(*) FROM t2; +count(*) +71 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 1 * 10 - 9), Point(8 * 10, 1 * 10))))); +SELECT count(*) FROM t2; +count(*) +70 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 10 * 10 - 9), Point(7 * 10, 10 * 10))))); +SELECT count(*) FROM t2; +count(*) +69 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 9 * 10 - 9), Point(7 * 10, 9 * 10))))); +SELECT count(*) FROM t2; +count(*) +68 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 8 * 10 - 9), Point(7 * 10, 8 * 10))))); +SELECT count(*) FROM t2; +count(*) +67 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 7 * 10 - 9), Point(7 * 10, 7 * 10))))); +SELECT count(*) FROM t2; +count(*) +66 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 6 * 10 - 9), Point(7 * 10, 6 * 10))))); +SELECT count(*) FROM t2; +count(*) +65 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 5 * 10 - 9), Point(7 * 10, 5 * 10))))); +SELECT count(*) FROM t2; +count(*) +64 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 4 * 10 - 9), Point(7 * 10, 4 * 10))))); +SELECT count(*) FROM t2; +count(*) +63 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 3 * 10 - 9), Point(7 * 10, 3 * 10))))); +SELECT count(*) FROM t2; +count(*) +62 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 2 * 10 - 9), Point(7 * 10, 2 * 10))))); +SELECT count(*) FROM t2; +count(*) +61 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 1 * 10 - 9), Point(7 * 10, 1 * 10))))); +SELECT count(*) FROM t2; +count(*) +60 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 10 * 10 - 9), Point(6 * 10, 10 * 10))))); +SELECT count(*) FROM t2; +count(*) +59 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 9 * 10 - 9), Point(6 * 10, 9 * 10))))); +SELECT count(*) FROM t2; +count(*) +58 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 8 * 10 - 9), Point(6 * 10, 8 * 10))))); +SELECT count(*) FROM t2; +count(*) +57 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 7 * 10 - 9), Point(6 * 10, 7 * 10))))); +SELECT count(*) FROM t2; +count(*) +56 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 6 * 10 - 9), Point(6 * 10, 6 * 10))))); +SELECT count(*) FROM t2; +count(*) +55 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 5 * 10 - 9), Point(6 * 10, 5 * 10))))); +SELECT count(*) FROM t2; +count(*) +54 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 4 * 10 - 9), Point(6 * 10, 4 * 10))))); +SELECT count(*) FROM t2; +count(*) +53 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 3 * 10 - 9), Point(6 * 10, 3 * 10))))); +SELECT count(*) FROM t2; +count(*) +52 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 2 * 10 - 9), Point(6 * 10, 2 * 10))))); +SELECT count(*) FROM t2; +count(*) +51 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 1 * 10 - 9), Point(6 * 10, 1 * 10))))); +SELECT count(*) FROM t2; +count(*) +50 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 10 * 10 - 9), Point(5 * 10, 10 * 10))))); +SELECT count(*) FROM t2; +count(*) +49 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 9 * 10 - 9), Point(5 * 10, 9 * 10))))); +SELECT count(*) FROM t2; +count(*) +48 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 8 * 10 - 9), Point(5 * 10, 8 * 10))))); +SELECT count(*) FROM t2; +count(*) +47 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 7 * 10 - 9), Point(5 * 10, 7 * 10))))); +SELECT count(*) FROM t2; +count(*) +46 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 6 * 10 - 9), Point(5 * 10, 6 * 10))))); +SELECT count(*) FROM t2; +count(*) +45 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 5 * 10 - 9), Point(5 * 10, 5 * 10))))); +SELECT count(*) FROM t2; +count(*) +44 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 4 * 10 - 9), Point(5 * 10, 4 * 10))))); +SELECT count(*) FROM t2; +count(*) +43 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 3 * 10 - 9), Point(5 * 10, 3 * 10))))); +SELECT count(*) FROM t2; +count(*) +42 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 2 * 10 - 9), Point(5 * 10, 2 * 10))))); +SELECT count(*) FROM t2; +count(*) +41 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 1 * 10 - 9), Point(5 * 10, 1 * 10))))); +SELECT count(*) FROM t2; +count(*) +40 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 10 * 10 - 9), Point(4 * 10, 10 * 10))))); +SELECT count(*) FROM t2; +count(*) +39 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 9 * 10 - 9), Point(4 * 10, 9 * 10))))); +SELECT count(*) FROM t2; +count(*) +38 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 8 * 10 - 9), Point(4 * 10, 8 * 10))))); +SELECT count(*) FROM t2; +count(*) +37 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 7 * 10 - 9), Point(4 * 10, 7 * 10))))); +SELECT count(*) FROM t2; +count(*) +36 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 6 * 10 - 9), Point(4 * 10, 6 * 10))))); +SELECT count(*) FROM t2; +count(*) +35 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 5 * 10 - 9), Point(4 * 10, 5 * 10))))); +SELECT count(*) FROM t2; +count(*) +34 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 4 * 10 - 9), Point(4 * 10, 4 * 10))))); +SELECT count(*) FROM t2; +count(*) +33 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 3 * 10 - 9), Point(4 * 10, 3 * 10))))); +SELECT count(*) FROM t2; +count(*) +32 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 2 * 10 - 9), Point(4 * 10, 2 * 10))))); +SELECT count(*) FROM t2; +count(*) +31 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 1 * 10 - 9), Point(4 * 10, 1 * 10))))); +SELECT count(*) FROM t2; +count(*) +30 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 10 * 10 - 9), Point(3 * 10, 10 * 10))))); +SELECT count(*) FROM t2; +count(*) +29 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 9 * 10 - 9), Point(3 * 10, 9 * 10))))); +SELECT count(*) FROM t2; +count(*) +28 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 8 * 10 - 9), Point(3 * 10, 8 * 10))))); +SELECT count(*) FROM t2; +count(*) +27 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 7 * 10 - 9), Point(3 * 10, 7 * 10))))); +SELECT count(*) FROM t2; +count(*) +26 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 6 * 10 - 9), Point(3 * 10, 6 * 10))))); +SELECT count(*) FROM t2; +count(*) +25 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 5 * 10 - 9), Point(3 * 10, 5 * 10))))); +SELECT count(*) FROM t2; +count(*) +24 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 4 * 10 - 9), Point(3 * 10, 4 * 10))))); +SELECT count(*) FROM t2; +count(*) +23 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 3 * 10 - 9), Point(3 * 10, 3 * 10))))); +SELECT count(*) FROM t2; +count(*) +22 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 2 * 10 - 9), Point(3 * 10, 2 * 10))))); +SELECT count(*) FROM t2; +count(*) +21 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 1 * 10 - 9), Point(3 * 10, 1 * 10))))); +SELECT count(*) FROM t2; +count(*) +20 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 10 * 10 - 9), Point(2 * 10, 10 * 10))))); +SELECT count(*) FROM t2; +count(*) +19 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 9 * 10 - 9), Point(2 * 10, 9 * 10))))); +SELECT count(*) FROM t2; +count(*) +18 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 8 * 10 - 9), Point(2 * 10, 8 * 10))))); +SELECT count(*) FROM t2; +count(*) +17 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 7 * 10 - 9), Point(2 * 10, 7 * 10))))); +SELECT count(*) FROM t2; +count(*) +16 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 6 * 10 - 9), Point(2 * 10, 6 * 10))))); +SELECT count(*) FROM t2; +count(*) +15 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 5 * 10 - 9), Point(2 * 10, 5 * 10))))); +SELECT count(*) FROM t2; +count(*) +14 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 4 * 10 - 9), Point(2 * 10, 4 * 10))))); +SELECT count(*) FROM t2; +count(*) +13 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 3 * 10 - 9), Point(2 * 10, 3 * 10))))); +SELECT count(*) FROM t2; +count(*) +12 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 2 * 10 - 9), Point(2 * 10, 2 * 10))))); +SELECT count(*) FROM t2; +count(*) +11 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 1 * 10 - 9), Point(2 * 10, 1 * 10))))); +SELECT count(*) FROM t2; +count(*) +10 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 10 * 10 - 9), Point(1 * 10, 10 * 10))))); +SELECT count(*) FROM t2; +count(*) +9 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 9 * 10 - 9), Point(1 * 10, 9 * 10))))); +SELECT count(*) FROM t2; +count(*) +8 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 8 * 10 - 9), Point(1 * 10, 8 * 10))))); +SELECT count(*) FROM t2; +count(*) +7 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 7 * 10 - 9), Point(1 * 10, 7 * 10))))); +SELECT count(*) FROM t2; +count(*) +6 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 6 * 10 - 9), Point(1 * 10, 6 * 10))))); +SELECT count(*) FROM t2; +count(*) +5 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 5 * 10 - 9), Point(1 * 10, 5 * 10))))); +SELECT count(*) FROM t2; +count(*) +4 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 4 * 10 - 9), Point(1 * 10, 4 * 10))))); +SELECT count(*) FROM t2; +count(*) +3 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 3 * 10 - 9), Point(1 * 10, 3 * 10))))); +SELECT count(*) FROM t2; +count(*) +2 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 2 * 10 - 9), Point(1 * 10, 2 * 10))))); +SELECT count(*) FROM t2; +count(*) +1 +DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 1 * 10 - 9), Point(1 * 10, 1 * 10))))); +SELECT count(*) FROM t2; +count(*) +0 +DROP TABLE t2; diff --git a/mysql-test/r/gis.result b/mysql-test/r/gis.result index 25c3d14212b..9118fa8cfed 100644 --- a/mysql-test/r/gis.result +++ b/mysql-test/r/gis.result @@ -15,26 +15,26 @@ INSERT INTO pt VALUES INSERT INTO ls VALUES (105, LineFromText('LINESTRING(0 0,0 10,10 0)')), (106, LineStringFromText('LINESTRING(10 10,20 10,20 20,10 20,10 10)')), -(107, LineString(Point(10, 10), Point(40, 10))); +(107, GeometryFromWKB(LineString(Point(10, 10), Point(40, 10)))); INSERT INTO p VALUES (108, PolygonFromText('POLYGON((10 10,20 10,20 20,10 20,10 10))')), (109, PolyFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))')), -(110, Polygon(LineString(Point(0, 0), Point(30, 0), Point(30, 30), Point(0, 0)))); +(110, GeometryFromWKB(Polygon(LineString(Point(0, 0), Point(30, 0), Point(30, 30), Point(0, 0))))); INSERT INTO mpt VALUES (111, MultiPointFromText('MULTIPOINT(0 0,10 10,10 20,20 20)')), (112, MPointFromText('MULTIPOINT(1 1,11 11,11 21,21 21)')), -(113, MultiPoint(Point(3, 6), Point(4, 10))); +(113, GeometryFromWKB(MultiPoint(Point(3, 6), Point(4, 10)))); INSERT INTO mls VALUES (114, MultiLineStringFromText('MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))')), (115, MLineFromText('MULTILINESTRING((10 48,10 21,10 0))')), -(116, MultiLineString(LineString(Point(1, 2), Point(3, 5)), LineString(Point(2, 5), Point(5, 8), Point(21, 7)))); +(116, GeometryFromWKB(MultiLineString(LineString(Point(1, 2), Point(3, 5)), LineString(Point(2, 5), Point(5, 8), Point(21, 7))))); INSERT INTO mp VALUES (117, MultiPolygonFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')), (118, MPolyFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')), -(119, MultiPolygon(Polygon(LineString(Point(0, 3), Point(3, 3), Point(3, 0), Point(0, 3))))); +(119, GeometryFromWKB(MultiPolygon(Polygon(LineString(Point(0, 3), Point(3, 3), Point(3, 0), Point(0, 3)))))); INSERT INTO gc VALUES (120, GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')), -(121, GeometryCollection(Point(44, 6), LineString(Point(3, 6), Point(7, 9)))); +(121, GeometryFromWKB(GeometryCollection(Point(44, 6), LineString(Point(3, 6), Point(7, 9))))); INSERT into geo SELECT * FROM pt; INSERT into geo SELECT * FROM ls; INSERT into geo SELECT * FROM p; diff --git a/mysql-test/r/query_cache.result b/mysql-test/r/query_cache.result index 30a0cd01c51..00d79ec0b6e 100644 --- a/mysql-test/r/query_cache.result +++ b/mysql-test/r/query_cache.result @@ -377,7 +377,7 @@ a set CHARACTER SET cp1251_koi8; select * from t1; a -À +? set CHARACTER SET DEFAULT; show status like "Qcache_queries_in_cache"; Variable_name Value diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index b66d75e2b3a..822fab5ae47 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -156,17 +156,17 @@ show variables like 'net_buffer_length'; Variable_name Value net_buffer_length 1048576 set GLOBAL character set cp1251_koi8; -show global variables like "convert_character_set"; +show global variables like "client_collation"; Variable_name Value -convert_character_set cp1251_koi8 +client_collation cp1251 set character set cp1251_koi8; -show variables like "convert_character_set"; +show variables like "client_collation"; Variable_name Value -convert_character_set cp1251_koi8 +client_collation cp1251 set global character set default, session character set default; -show variables like "convert_character_set"; +show variables like "client_collation"; Variable_name Value -convert_character_set cp1251_koi8 +client_collation latin1 select @@timestamp>0; @@timestamp>0 1 @@ -193,12 +193,12 @@ set SESSION query_cache_size=10000; Variable 'query_cache_size' is a GLOBAL variable and should be set with SET GLOBAL set GLOBAL table_type=DEFAULT; Variable 'table_type' doesn't have a default value -set convert_character_set=UNKNOWN_CHARACTER_SET; +set client_collation=UNKNOWN_CHARACTER_SET; Unknown character set: 'UNKNOWN_CHARACTER_SET' set character set unknown; Unknown character set: 'unknown' set character set 0; -Wrong argument type to variable 'convert_character_set' +Wrong argument type to variable 'client_collation' set global autocommit=1; Variable 'autocommit' is a LOCAL variable and can't be used with SET GLOBAL select @@global.timestamp; @@ -218,8 +218,8 @@ select @@autocommit, @@big_tables; 1 1 set global binlog_cache_size=100; set bulk_insert_buffer_size=100; -set convert_character_set=cp1251_koi8; -set convert_character_set=default; +set character set cp1251_koi8; +set character set default; set @@global.concurrent_insert=1; set global connect_timeout=100; select @@delay_key_write; diff --git a/mysql-test/t/ctype_many.test b/mysql-test/t/ctype_many.test index 1f9f9cf99cc..05f3687d330 100644 --- a/mysql-test/t/ctype_many.test +++ b/mysql-test/t/ctype_many.test @@ -2,6 +2,8 @@ DROP TABLE IF EXISTS t1; --enable_warnings +SET NAMES latin1; + CREATE TABLE t1 ( comment CHAR(32) ASCII NOT NULL, koi8_ru_f CHAR(32) CHARACTER SET koi8r NOT NULL @@ -135,10 +137,12 @@ INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ü','CYR CAPIT E'); INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'à','CYR CAPIT YU'); INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ñ','CYR CAPIT YA'); -SELECT CONVERT(koi8_ru_f USING utf8),MIN(comment),COUNT(*) FROM t1 GROUP BY 1; +SET NAMES utf8; +SELECT koi8_ru_f,MIN(comment),COUNT(*) FROM t1 GROUP BY 1; ALTER TABLE t1 ADD utf8_f CHAR(32) CHARACTER SET utf8 NOT NULL; UPDATE t1 SET utf8_f=CONVERT(koi8_ru_f USING utf8); +SET NAMES koi8r; SELECT * FROM t1; ALTER TABLE t1 ADD bin_f CHAR(32) BYTE NOT NULL; @@ -161,6 +165,7 @@ FROM t1 t11,t1 t12 WHERE t11.koi8_ru_f=CONVERT(t12.utf8_f USING koi8r) ORDER BY t12.utf8_f,t11.comment,t12.comment; +SET NAMES utf8; ALTER TABLE t1 ADD ucs2_f CHAR(32) CHARACTER SET ucs2; ALTER TABLE t1 CHANGE ucs2_f ucs2_f CHAR(32) UNICODE NOT NULL; @@ -189,9 +194,12 @@ INSERT INTO t1 (ucs2_f,comment) VALUES (0x0566,'ARMENIAN SMALL ZA'); ALTER TABLE t1 ADD armscii8_f CHAR(32) CHARACTER SET armscii8 NOT NULL; ALTER TABLE t1 ADD greek_f CHAR(32) CHARACTER SET greek NOT NULL; -UPDATE t1 SET greek_f=CONVERT(ucs2_f USING greek) WHERE comment LIKE 'GRE%'; -UPDATE t1 SET armscii8_f=CONVERT(ucs2_f USING armscii8) WHERE comment LIKE 'ARM%'; -UPDATE t1 SET utf8_f=CONVERT(ucs2_f USING utf8) WHERE utf8_f=''; -UPDATE t1 SET ucs2_f=CONVERT(utf8_f USING ucs2) WHERE ucs2_f=''; +UPDATE t1 SET greek_f=CONVERT(ucs2_f USING greek) WHERE comment LIKE _latin2'GRE%'; +UPDATE t1 SET armscii8_f=CONVERT(ucs2_f USING armscii8) WHERE comment LIKE _latin2'ARM%'; +UPDATE t1 SET utf8_f=CONVERT(ucs2_f USING utf8) WHERE utf8_f=_utf8''; +UPDATE t1 SET ucs2_f=CONVERT(utf8_f USING ucs2) WHERE ucs2_f=_ucs2''; +SELECT * FROM t1; +SET NAMES 'binary'; +SELECT * FROM t1; SELECT min(comment),count(*) FROM t1 GROUP BY ucs2_f; DROP TABLE t1; diff --git a/mysql-test/t/ctype_recoding.test b/mysql-test/t/ctype_recoding.test new file mode 100644 index 00000000000..c0b7139c791 --- /dev/null +++ b/mysql-test/t/ctype_recoding.test @@ -0,0 +1,28 @@ +SET NAMES koi8r; + +--disable_warnings +DROP TABLE IF EXISTS ÔÁÂÌÉÃÁ; +--enable_warnings + +CREATE TABLE ÔÁÂÌÉÃÁ +( + ÐÏÌÅ CHAR(32) CHARACTER SET koi8r NOT NULL +); + +SHOW TABLES; +SHOW CREATE TABLE ÔÁÂÌÉÃÁ; +SHOW FIELDS FROM ÔÁÂÌÉÃÁ; + +SET NAMES cp1251; +SHOW TABLES; +SHOW CREATE TABLE òàáëèöà; +SHOW FIELDS FROM òàáëèöà; + + +SET NAMES utf8; +SHOW TABLES; +SHOW CREATE TABLE таблица; +SHOW FIELDS FROM таблица; + +SET NAMES koi8r; +DROP TABLE ÔÁÂÌÉÃÁ; diff --git a/mysql-test/t/func_system.test b/mysql-test/t/func_system.test index c69526644f4..db366e3ab49 100644 --- a/mysql-test/t/func_system.test +++ b/mysql-test/t/func_system.test @@ -3,5 +3,5 @@ # select database(),user() like "%@%"; -select version()>="3.23.29"; +select version()>=_utf8"3.23.29"; select TRUE,FALSE,NULL; diff --git a/mysql-test/t/gis-rtree.test b/mysql-test/t/gis-rtree.test new file mode 100644 index 00000000000..0368ddb41cb --- /dev/null +++ b/mysql-test/t/gis-rtree.test @@ -0,0 +1,69 @@ +# +# test of rtree (using with spatial data) +# +--disable_warnings +DROP TABLE IF EXISTS t1, t2; +--enable_warnings + +CREATE TABLE t1 ( + fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + g GEOMETRY NOT NULL, + SPATIAL KEY(g) +) TYPE=MyISAM; + +SHOW CREATE TABLE t1; + +let $1=150; +let $2=150; +while ($1) +{ + eval INSERT INTO t1 (g) VALUES (GeomFromText('LineString($1 $1, $2 $2)')); + dec $1; + inc $2; +} + +SELECT count(*) FROM t1; +EXPLAIN SELECT fid, AsText(g) FROM t1 WHERE Within(g, GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))')); +SELECT fid, AsText(g) FROM t1 WHERE Within(g, GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))')); + +DROP TABLE t1; + +CREATE TABLE t2 ( + fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + g GEOMETRY NOT NULL +) TYPE=MyISAM; + +let $1=10; +while ($1) +{ + let $2=10; + while ($2) + { + eval INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point($1 * 10 - 9, $2 * 10 - 9), Point($1 * 10, $2 * 10)))); + dec $2; + } + dec $1; +} + +ALTER TABLE t2 ADD SPATIAL KEY(g); +SHOW CREATE TABLE t2; +SELECT count(*) FROM t2; +EXPLAIN SELECT fid, AsText(g) FROM t2 WHERE Within(g, + GeomFromText('Polygon((40 40,60 40,60 60,40 60,40 40))')); +SELECT fid, AsText(g) FROM t2 WHERE Within(g, + GeomFromText('Polygon((40 40,60 40,60 60,40 60,40 40))')); + +let $1=10; +while ($1) +{ + let $2=10; + while ($2) + { + eval DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point($1 * 10 - 9, $2 * 10 - 9), Point($1 * 10, $2 * 10))))); + SELECT count(*) FROM t2; + dec $2; + } + dec $1; +} + +DROP TABLE t2; diff --git a/mysql-test/t/gis.test b/mysql-test/t/gis.test index 35bb682f732..f4b6138c86f 100644 --- a/mysql-test/t/gis.test +++ b/mysql-test/t/gis.test @@ -24,32 +24,32 @@ INSERT INTO pt VALUES INSERT INTO ls VALUES (105, LineFromText('LINESTRING(0 0,0 10,10 0)')), (106, LineStringFromText('LINESTRING(10 10,20 10,20 20,10 20,10 10)')), -(107, LineString(Point(10, 10), Point(40, 10))); +(107, GeometryFromWKB(LineString(Point(10, 10), Point(40, 10)))); INSERT INTO p VALUES (108, PolygonFromText('POLYGON((10 10,20 10,20 20,10 20,10 10))')), (109, PolyFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))')), -(110, Polygon(LineString(Point(0, 0), Point(30, 0), Point(30, 30), Point(0, 0)))); +(110, GeometryFromWKB(Polygon(LineString(Point(0, 0), Point(30, 0), Point(30, 30), Point(0, 0))))); INSERT INTO mpt VALUES (111, MultiPointFromText('MULTIPOINT(0 0,10 10,10 20,20 20)')), (112, MPointFromText('MULTIPOINT(1 1,11 11,11 21,21 21)')), -(113, MultiPoint(Point(3, 6), Point(4, 10))); +(113, GeometryFromWKB(MultiPoint(Point(3, 6), Point(4, 10)))); INSERT INTO mls VALUES (114, MultiLineStringFromText('MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))')), (115, MLineFromText('MULTILINESTRING((10 48,10 21,10 0))')), -(116, MultiLineString(LineString(Point(1, 2), Point(3, 5)), LineString(Point(2, 5), Point(5, 8), Point(21, 7)))); +(116, GeometryFromWKB(MultiLineString(LineString(Point(1, 2), Point(3, 5)), LineString(Point(2, 5), Point(5, 8), Point(21, 7))))); INSERT INTO mp VALUES (117, MultiPolygonFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')), (118, MPolyFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')), -(119, MultiPolygon(Polygon(LineString(Point(0, 3), Point(3, 3), Point(3, 0), Point(0, 3))))); +(119, GeometryFromWKB(MultiPolygon(Polygon(LineString(Point(0, 3), Point(3, 3), Point(3, 0), Point(0, 3)))))); INSERT INTO gc VALUES (120, GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')), -(121, GeometryCollection(Point(44, 6), LineString(Point(3, 6), Point(7, 9)))); +(121, GeometryFromWKB(GeometryCollection(Point(44, 6), LineString(Point(3, 6), Point(7, 9))))); INSERT into geo SELECT * FROM pt; INSERT into geo SELECT * FROM ls; diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index 39aa5a20a71..4bde54f868a 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -92,11 +92,11 @@ set net_buffer_length=2000000000; show variables like 'net_buffer_length'; set GLOBAL character set cp1251_koi8; -show global variables like "convert_character_set"; +show global variables like "client_collation"; set character set cp1251_koi8; -show variables like "convert_character_set"; +show variables like "client_collation"; set global character set default, session character set default; -show variables like "convert_character_set"; +show variables like "client_collation"; select @@timestamp>0; set @@rand_seed1=10000000,@@rand_seed2=1000000; @@ -123,7 +123,7 @@ set SESSION query_cache_size=10000; --error 1230 set GLOBAL table_type=DEFAULT; --error 1115 -set convert_character_set=UNKNOWN_CHARACTER_SET; +set client_collation=UNKNOWN_CHARACTER_SET; --error 1115 set character set unknown; --error 1232 @@ -148,8 +148,8 @@ set big_tables=1; select @@autocommit, @@big_tables; set global binlog_cache_size=100; set bulk_insert_buffer_size=100; -set convert_character_set=cp1251_koi8; -set convert_character_set=default; +set character set cp1251_koi8; +set character set default; set @@global.concurrent_insert=1; set global connect_timeout=100; select @@delay_key_write; diff --git a/mysys/charset.c b/mysys/charset.c index 87fb7846553..ce44353b065 100644 --- a/mysys/charset.c +++ b/mysys/charset.c @@ -324,7 +324,7 @@ static int add_collation(CHARSET_INFO *cs) if (cs->primary_number == cs->number) cs->state |= MY_CS_PRIMARY; - if (cs->primary_number == cs->number) + if (cs->binary_number == cs->number) cs->state |= MY_CS_BINSORT; if (!(all_charsets[cs->number]->state & MY_CS_COMPILED)) @@ -341,6 +341,8 @@ static int add_collation(CHARSET_INFO *cs) all_charsets[cs->number]->state |= cs->state; } cs->number= 0; + cs->primary_number= 0; + cs->binary_number= 0; cs->name= NULL; cs->state= 0; cs->sort_order= NULL; diff --git a/sql/convert.cc b/sql/convert.cc index 84003af3922..bfdf49bf42d 100644 --- a/sql/convert.cc +++ b/sql/convert.cc @@ -14,6 +14,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#if 0 /* ** Convert tables between different character sets @@ -460,3 +461,5 @@ bool CONVERT::store(String *packet,const char *from,uint length) packet->length((uint) (store_dest(to, from, length)-packet->ptr())); return 0; } + +#endif diff --git a/sql/field.cc b/sql/field.cc index 0c17209003c..b5ed7885af5 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -4525,7 +4525,7 @@ void Field_blob::get_key_image(char *buff,uint length, MBR mbr; Geometry gobj; - gobj.create_from_wkb(blob,blob_length); + gobj.create_from_wkb(blob + SRID_SIZE, blob_length - SRID_SIZE); gobj.get_mbr(&mbr); float8store(buff, mbr.xmin); float8store(buff+8, mbr.xmax); @@ -4555,35 +4555,6 @@ void Field_blob::set_key_image(char *buff,uint length, CHARSET_INFO *cs) } -void Field_geom::get_key_image(char *buff,uint length,CHARSET_INFO *cs, - imagetype type) -{ - length-=HA_KEY_BLOB_LENGTH; - ulong blob_length=get_length(ptr); - char *blob; - get_ptr(&blob); - - MBR mbr; - Geometry gobj; - gobj.create_from_wkb(blob,blob_length); - gobj.get_mbr(&mbr); - float8store(buff, mbr.xmin); - float8store(buff+8, mbr.xmax); - float8store(buff+16, mbr.ymin); - float8store(buff+24, mbr.ymax); - return; -} - -void Field_geom::set_key_image(char *buff,uint length,CHARSET_INFO *cs) -{ - Field_blob::set_key_image(buff, length, cs); -} - -void Field_geom::sql_type(String &res) const -{ - res.set("geometry", 8, &my_charset_latin1); -} - int Field_blob::key_cmp(const byte *key_ptr, uint max_key_length) { char *blob1; @@ -4776,6 +4747,64 @@ uint Field_blob::max_packed_col_length(uint max_length) return (max_length > 255 ? 2 : 1)+max_length; } + +void Field_geom::get_key_image(char *buff, uint length, CHARSET_INFO *cs, + imagetype type) +{ + length-= HA_KEY_BLOB_LENGTH; + ulong blob_length= get_length(ptr); + char *blob; + get_ptr(&blob); + + MBR mbr; + Geometry gobj; + gobj.create_from_wkb(blob + SRID_SIZE, blob_length - SRID_SIZE); + gobj.get_mbr(&mbr); + float8store(buff, mbr.xmin); + float8store(buff + 8, mbr.xmax); + float8store(buff + 16, mbr.ymin); + float8store(buff + 24, mbr.ymax); + return; +} + + +void Field_geom::set_key_image(char *buff, uint length, CHARSET_INFO *cs) +{ + Field_blob::set_key_image(buff, length, cs); +} + +void Field_geom::sql_type(String &res) const +{ + res.set("geometry", 8, &my_charset_latin1); +} + + +int Field_geom::store(const char *from, uint length, CHARSET_INFO *cs) +{ + if (!length) + { + bzero(ptr, Field_blob::pack_length()); + } + else + { + // Should check given WKB + if (length < 4 + 1 + 4 + 8 + 8) // SRID + WKB_HEADER + X + Y + return 1; + uint32 wkb_type= uint4korr(from + 5); + if (wkb_type < 1 || wkb_type > 7) + return 1; + Field_blob::store_length(length); + if (table->copy_blobs || length <= MAX_FIELD_WIDTH) + { // Must make a copy + value.copy(from, length, cs); + from= value.ptr(); + } + bmove(ptr + packlength, (char*) &from, sizeof(char*)); + } + return 0; +} + + /**************************************************************************** ** enum type. ** This is a string which only can have a selection of different values. diff --git a/sql/field.h b/sql/field.h index 3877068aa0e..aad13508323 100644 --- a/sql/field.h +++ b/sql/field.h @@ -843,9 +843,10 @@ public: class Field_blob :public Field_str { + bool geom_flag; +protected: uint packlength; String value; // For temporaries - bool geom_flag; public: Field_blob(char *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg, enum utype unireg_check_arg, const char *field_name_arg, @@ -855,7 +856,7 @@ public: struct st_table *table_arg, CHARSET_INFO *cs) :Field_str((char*) 0,len_arg, maybe_null_arg ? (uchar*) "": 0,0, NONE, field_name_arg, table_arg, cs), - packlength(3), geom_flag(true) + geom_flag(true), packlength(3) { flags|= BLOB_FLAG; } @@ -940,8 +941,11 @@ public: :Field_blob(len_arg, maybe_null_arg, field_name_arg, table_arg, &my_charset_bin) {} enum ha_base_keytype key_type() const { return HA_KEYTYPE_VARBINARY; } - enum_field_types type() const { return FIELD_TYPE_GEOMETRY;} + enum_field_types type() const { return FIELD_TYPE_GEOMETRY; } void sql_type(String &str) const; + int store(const char *to, uint length, CHARSET_INFO *charset); + int store(double nr) { return 1; } + int store(longlong nr) { return 1; } void get_key_image(char *buff,uint length, CHARSET_INFO *cs,imagetype type); void set_key_image(char *buff,uint length, CHARSET_INFO *cs); diff --git a/sql/item.cc b/sql/item.cc index d362ff9ff40..faf0f245576 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -39,7 +39,7 @@ Item::Item(): { marker= 0; maybe_null=null_value=with_sum_func=unsigned_flag=0; - coercibility=COER_NOCOLL; + coercibility=COER_IMPLICIT; name= 0; decimals= 0; max_length= 0; THD *thd= current_thd; @@ -90,19 +90,23 @@ bool Item::check_cols(uint c) return 0; } -void Item::set_name(const char *str,uint length) +void Item::set_name(const char *str,uint length, CHARSET_INFO *cs) { if (!length) - name= (char*) str; // Used by AS - else + length= str ? strlen(str) : 0; + while (length && !my_isgraph(cs,*str)) + { // Fix problem with yacc + length--; + str++; + } + if (!my_charset_same(cs, system_charset_info)) { - while (length && !my_isgraph(system_charset_info,*str)) - { // Fix problem with yacc - length--; - str++; - } - name=sql_strmake(str,min(length,MAX_FIELD_WIDTH)); + String tmp; + tmp.copy(str, length, cs, system_charset_info); + name=sql_strmake(tmp.ptr(),min(tmp.length(),MAX_FIELD_WIDTH)); } + else + name=sql_strmake(str,min(length,MAX_FIELD_WIDTH)); } /* @@ -168,6 +172,41 @@ CHARSET_INFO * Item::default_charset() const return current_thd->db_charset; } +bool Item::set_charset(CHARSET_INFO *cs1, enum coercion co1, + CHARSET_INFO *cs2, enum coercion co2) +{ + if (cs1 == &my_charset_bin || cs2 == &my_charset_bin) + { + set_charset(&my_charset_bin, COER_NOCOLL); + return 0; + } + + if (!my_charset_same(cs1,cs2)) + return 1; + + if (co1 < co2) + { + set_charset(cs1, co1); + } + else if (co2 < co1) + { + set_charset(cs2, co2); + } + else // co2 == co1 + { + if (cs1 != cs2) + { + CHARSET_INFO *bin= get_charset_by_csname(cs1->csname, MY_CS_BINSORT,MYF(0)); + if (!bin) + return 1; + set_charset(bin, COER_NOCOLL); + } + else + set_charset(cs2, co2); + } + return 0; +} + Item_field::Item_field(Field *f) :Item_ident(NullS,f->table_name,f->field_name) { set_field(f); @@ -191,8 +230,7 @@ void Item_field::set_field(Field *field_par) table_name=field_par->table_name; field_name=field_par->field_name; unsigned_flag=test(field_par->flags & UNSIGNED_FLAG); - set_charset(field_par->charset()); - coercibility= COER_IMPLICIT; + set_charset(field_par->charset(), COER_IMPLICIT); } const char *Item_ident::full_name() const diff --git a/sql/item.h b/sql/item.h index d7ca9bf855a..1b5fafc180f 100644 --- a/sql/item.h +++ b/sql/item.h @@ -39,8 +39,8 @@ public: SUBSELECT_ITEM, ROW_ITEM, CACHE_ITEM}; enum cond_result { COND_UNDEF,COND_OK,COND_TRUE,COND_FALSE }; - enum coercion { COER_NOCOLL=3, COER_COERCIBLE=2, - COER_IMPLICIT=1, COER_EXPLICIT=0 }; + enum coercion { COER_COERCIBLE=3, COER_IMPLICIT=2, + COER_NOCOLL=1, COER_EXPLICIT=0 }; String str_value; /* used to store value */ my_string name; /* Name from select */ @@ -63,7 +63,7 @@ public: */ Item(THD *thd, Item &item); virtual ~Item() { name=0; } /*lint -e1509 */ - void set_name(const char *str,uint length=0); + void set_name(const char *str,uint length, CHARSET_INFO *cs); void init_make_field(Send_field *tmp_field,enum enum_field_types type); virtual void make_field(Send_field *field); virtual bool fix_fields(THD *, struct st_table_list *, Item **); @@ -115,6 +115,13 @@ public: CHARSET_INFO *default_charset() const; CHARSET_INFO *charset() const { return str_value.charset(); }; void set_charset(CHARSET_INFO *cs) { str_value.set_charset(cs); } + void set_charset(CHARSET_INFO *cs, enum coercion coer) + { + str_value.set_charset(cs); + coercibility= coer; + } + bool set_charset(CHARSET_INFO *cs1, enum coercion co1, + CHARSET_INFO *cs2, enum coercion co2); virtual void set_outer_resolving() {} // Row emulation @@ -362,7 +369,7 @@ public: str_value.set(str,length,cs); coercibility= coer; max_length=length; - name=(char*) str_value.ptr(); + set_name(str, length, cs); decimals=NOT_FIXED_DEC; } Item_string(const char *name_par, const char *str, uint length, @@ -371,7 +378,7 @@ public: str_value.set(str,length,cs); coercibility= coer; max_length=length; - name=(char*) name_par; + set_name(name_par,0,cs); decimals=NOT_FIXED_DEC; } ~Item_string() {} diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index a88b269eedd..48fe1a9d470 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -87,6 +87,35 @@ static bool convert_constant_item(Field *field, Item **item) return 0; } +bool Item_bool_func2::set_cmp_charset(CHARSET_INFO *cs1, enum coercion co1, + CHARSET_INFO *cs2, enum coercion co2) +{ + if((cs1 == &my_charset_bin) || (cs2 == &my_charset_bin)) + { + cmp_charset= &my_charset_bin; + return 0; + } + + if ((co1 == COER_NOCOLL) || (co2 == COER_NOCOLL)) + return 1; + + if (!my_charset_same(cs1,cs2)) + return 1; + + if (co1 < co2) + cmp_charset= cs1; + else if (co2 < co1) + cmp_charset= cs2; + else // co1==co2 + { + if (cs1 == cs2) + cmp_charset= cs1; + else + return 1; + } + return 0; +} + void Item_bool_func2::fix_length_and_dec() { max_length= 1; // Function returns 0 or 1 @@ -124,10 +153,13 @@ void Item_bool_func2::fix_length_and_dec() } } } + if (set_cmp_charset(args[0]->charset(), args[0]->coercibility, + args[1]->charset(), args[1]->coercibility)) + { + my_error(ER_WRONG_ARGUMENTS,MYF(0),func_name()); + return; + } set_cmp_func(); - /* QQ: COERCIBILITY */ - cmp_charset= (args[0]->binary() || args[1]->binary()) ? - &my_charset_bin : args[0]->charset(); } @@ -2204,17 +2236,19 @@ longlong Item_cond_xor::val_int() longlong Item_func_spatial_rel::val_int() { - String *res1=args[0]->val_str(&tmp_value1); - String *res2=args[1]->val_str(&tmp_value2); + String *res1= args[0]->val_str(&tmp_value1); + String *res2= args[1]->val_str(&tmp_value2); Geometry g1, g2; - MBR mbr1,mbr2; - - if ((null_value=(args[0]->null_value || - args[1]->null_value || - g1.create_from_wkb(res1->ptr(),res1->length()) || - g2.create_from_wkb(res2->ptr(),res2->length()) || - g1.get_mbr(&mbr1) || - g2.get_mbr(&mbr2)))) + MBR mbr1, mbr2; + + if ((null_value= (args[0]->null_value || + args[1]->null_value || + g1.create_from_wkb(res1->ptr() + SRID_SIZE, + res1->length() - SRID_SIZE) || + g2.create_from_wkb(res2->ptr() + SRID_SIZE, + res2->length() - SRID_SIZE) || + g1.get_mbr(&mbr1) || + g2.get_mbr(&mbr2)))) return 0; switch (spatial_rel) @@ -2264,15 +2298,16 @@ longlong Item_func_issimple::val_int() longlong Item_func_isclosed::val_int() { String tmp; - String *wkb=args[0]->val_str(&tmp); + String *swkb= args[0]->val_str(&tmp); Geometry geom; int isclosed; - null_value= (!wkb || - args[0]->null_value || - geom.create_from_wkb(wkb->ptr(),wkb->length()) || - !GEOM_METHOD_PRESENT(geom,is_closed) || - geom.is_closed(&isclosed)); + null_value= (!swkb || + args[0]->null_value || + geom.create_from_wkb(swkb->ptr() + SRID_SIZE, + swkb->length() - SRID_SIZE) || + !GEOM_METHOD_PRESENT(geom,is_closed) || + geom.is_closed(&isclosed)); return (longlong) isclosed; } diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index b9d8615beb4..e7670755396 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -122,6 +122,8 @@ public: { cmp.set_cmp_func(this, tmp_arg, tmp_arg+1); } + bool set_cmp_charset(CHARSET_INFO *cs1, enum coercion co1, + CHARSET_INFO *cs2, enum coercion co2); optimize_type select_optimize() const { return OPTIMIZE_OP; } virtual enum Functype rev_functype() const { return UNKNOWN_FUNC; } bool have_rev_func() const { return rev_functype() != UNKNOWN_FUNC; } diff --git a/sql/item_create.cc b/sql/item_create.cc index d90c708fc0f..b80327b657a 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -433,7 +433,7 @@ Item *create_func_version(void) { return new Item_string(NullS,server_version, (uint) strlen(server_version), - default_charset_info); + system_charset_info); } Item *create_func_weekday(Item* a) @@ -480,157 +480,157 @@ Item *create_func_quote(Item* a) return new Item_func_quote(a); } -Item *create_func_geometry_from_text(Item* a) +Item *create_func_as_text(Item *a) { - return new Item_func_geometry_from_text(a); + return new Item_func_as_text(a); } -Item *create_func_as_text(Item* a) +Item *create_func_srid(Item *a) { - return new Item_func_as_text(a); + return new Item_func_srid(a); } -Item *create_func_startpoint(Item* a) +Item *create_func_startpoint(Item *a) { return new Item_func_spatial_decomp(a, Item_func::SP_STARTPOINT); } -Item *create_func_endpoint(Item* a) +Item *create_func_endpoint(Item *a) { return new Item_func_spatial_decomp(a, Item_func::SP_ENDPOINT); } -Item *create_func_exteriorring(Item* a) +Item *create_func_exteriorring(Item *a) { return new Item_func_spatial_decomp(a, Item_func::SP_EXTERIORRING); } -Item *create_func_pointn(Item* a, Item* b) +Item *create_func_pointn(Item *a, Item *b) { - return new Item_func_spatial_decomp_n(a,b,Item_func::SP_POINTN); + return new Item_func_spatial_decomp_n(a, b, Item_func::SP_POINTN); } -Item *create_func_interiorringn(Item* a, Item* b) +Item *create_func_interiorringn(Item *a, Item *b) { - return new Item_func_spatial_decomp_n(a,b,Item_func::SP_INTERIORRINGN); + return new Item_func_spatial_decomp_n(a, b, Item_func::SP_INTERIORRINGN); } -Item *create_func_geometryn(Item* a, Item* b) +Item *create_func_geometryn(Item *a, Item *b) { - return new Item_func_spatial_decomp_n(a,b,Item_func::SP_GEOMETRYN); + return new Item_func_spatial_decomp_n(a, b, Item_func::SP_GEOMETRYN); } -Item *create_func_centroid(Item* a) +Item *create_func_centroid(Item *a) { return new Item_func_centroid(a); } -Item *create_func_envelope(Item* a) +Item *create_func_envelope(Item *a) { return new Item_func_envelope(a); } -Item *create_func_equals(Item* a, Item* b) +Item *create_func_equals(Item *a, Item *b) { return new Item_func_spatial_rel(a, b, Item_func::SP_EQUALS_FUNC); } -Item *create_func_disjoint(Item* a, Item* b) +Item *create_func_disjoint(Item *a, Item *b) { return new Item_func_spatial_rel(a, b, Item_func::SP_DISJOINT_FUNC); } -Item *create_func_intersects(Item* a, Item* b) +Item *create_func_intersects(Item *a, Item *b) { return new Item_func_spatial_rel(a, b, Item_func::SP_INTERSECTS_FUNC); } -Item *create_func_touches(Item* a, Item* b) +Item *create_func_touches(Item *a, Item *b) { return new Item_func_spatial_rel(a, b, Item_func::SP_TOUCHES_FUNC); } -Item *create_func_crosses(Item* a, Item* b) +Item *create_func_crosses(Item *a, Item *b) { return new Item_func_spatial_rel(a, b, Item_func::SP_CROSSES_FUNC); } -Item *create_func_within(Item* a, Item* b) +Item *create_func_within(Item *a, Item *b) { return new Item_func_spatial_rel(a, b, Item_func::SP_WITHIN_FUNC); } -Item *create_func_contains(Item* a, Item* b) +Item *create_func_contains(Item *a, Item *b) { return new Item_func_spatial_rel(a, b, Item_func::SP_CONTAINS_FUNC); } -Item *create_func_overlaps(Item* a, Item* b) +Item *create_func_overlaps(Item *a, Item *b) { return new Item_func_spatial_rel(a, b, Item_func::SP_OVERLAPS_FUNC); } -Item *create_func_isempty(Item* a) +Item *create_func_isempty(Item *a) { return new Item_func_isempty(a); } -Item *create_func_issimple(Item* a) +Item *create_func_issimple(Item *a) { return new Item_func_issimple(a); } -Item *create_func_isclosed(Item* a) +Item *create_func_isclosed(Item *a) { return new Item_func_isclosed(a); } -Item *create_func_geometry_type(Item* a) +Item *create_func_geometry_type(Item *a) { return new Item_func_geometry_type(a); } -Item *create_func_dimension(Item* a) +Item *create_func_dimension(Item *a) { return new Item_func_dimension(a); } -Item *create_func_x(Item* a) +Item *create_func_x(Item *a) { return new Item_func_x(a); } -Item *create_func_y(Item* a) +Item *create_func_y(Item *a) { return new Item_func_y(a); } -Item *create_func_numpoints(Item* a) +Item *create_func_numpoints(Item *a) { return new Item_func_numpoints(a); } -Item *create_func_numinteriorring(Item* a) +Item *create_func_numinteriorring(Item *a) { return new Item_func_numinteriorring(a); } -Item *create_func_numgeometries(Item* a) +Item *create_func_numgeometries(Item *a) { return new Item_func_numgeometries(a); } -Item *create_func_area(Item* a) +Item *create_func_area(Item *a) { return new Item_func_area(a); } -Item *create_func_glength(Item* a) +Item *create_func_glength(Item *a) { return new Item_func_glength(a); } -Item *create_func_point(Item* a, Item* b) +Item *create_func_point(Item *a, Item *b) { - return new Item_func_point(a,b); + return new Item_func_point(a, b); } diff --git a/sql/item_create.h b/sql/item_create.h index 135bd6b02c4..14812c47cdc 100644 --- a/sql/item_create.h +++ b/sql/item_create.h @@ -102,40 +102,40 @@ Item *create_load_file(Item* a); Item *create_func_is_free_lock(Item* a); Item *create_func_quote(Item* a); -Item *create_func_geometry_from_text(Item* a); -Item *create_func_as_text(Item* a); -Item *create_func_startpoint(Item* a); -Item *create_func_endpoint(Item* a); -Item *create_func_exteriorring(Item* a); -Item *create_func_centroid(Item* a); -Item *create_func_envelope(Item* a); -Item *create_func_pointn(Item* a, Item* b); -Item *create_func_interiorringn(Item* a, Item* b); -Item *create_func_geometryn(Item* a, Item* b); +Item *create_func_geometry_from_text(Item *a); +Item *create_func_as_text(Item *a); +Item *create_func_srid(Item *a); +Item *create_func_startpoint(Item *a); +Item *create_func_endpoint(Item *a); +Item *create_func_exteriorring(Item *a); +Item *create_func_centroid(Item *a); +Item *create_func_envelope(Item *a); +Item *create_func_pointn(Item *a, Item *b); +Item *create_func_interiorringn(Item *a, Item *b); +Item *create_func_geometryn(Item *a, Item *b); -Item *create_func_equals(Item* a, Item* b); -Item *create_func_disjoint(Item* a, Item* b); -Item *create_func_intersects(Item* a, Item* b); -Item *create_func_touches(Item* a, Item* b); -Item *create_func_crosses(Item* a, Item* b); -Item *create_func_within(Item* a, Item* b); -Item *create_func_contains(Item* a, Item* b); -Item *create_func_overlaps(Item* a, Item* b); +Item *create_func_equals(Item *a, Item *b); +Item *create_func_disjoint(Item *a, Item *b); +Item *create_func_intersects(Item *a, Item *b); +Item *create_func_touches(Item *a, Item *b); +Item *create_func_crosses(Item *a, Item *b); +Item *create_func_within(Item *a, Item *b); +Item *create_func_contains(Item *a, Item *b); +Item *create_func_overlaps(Item *a, Item *b); -Item *create_func_isempty(Item* a); -Item *create_func_issimple(Item* a); -Item *create_func_isclosed(Item* a); +Item *create_func_isempty(Item *a); +Item *create_func_issimple(Item *a); +Item *create_func_isclosed(Item *a); -Item *create_func_geometry_type(Item* a); -Item *create_func_dimension(Item* a); -Item *create_func_x(Item* a); -Item *create_func_y(Item* a); -Item *create_func_area(Item* a); -Item *create_func_glength(Item* a); +Item *create_func_geometry_type(Item *a); +Item *create_func_dimension(Item *a); +Item *create_func_x(Item *a); +Item *create_func_y(Item *a); +Item *create_func_area(Item *a); +Item *create_func_glength(Item *a); -Item *create_func_numpoints(Item* a); -Item *create_func_numinteriorring(Item* a); -Item *create_func_numgeometries(Item* a); - -Item *create_func_point(Item* a,Item* b); +Item *create_func_numpoints(Item *a); +Item *create_func_numinteriorring(Item *a); +Item *create_func_numgeometries(Item *a); +Item *create_func_point(Item *a, Item *b); diff --git a/sql/item_func.cc b/sql/item_func.cc index 9abbb0e290b..8cb63182705 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -107,7 +107,6 @@ Item_func::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) return 0; // Fatal error if flag is set! if (arg_count) { // Print purify happy - bool first_coll= 1; for (arg=args, arg_end=args+arg_count; arg != arg_end ; arg++) { if ((*arg)->fix_fields(thd, tables, arg) || @@ -116,38 +115,6 @@ Item_func::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) if ((*arg)->maybe_null) maybe_null=1; - if ((*arg)->result_type() == STRING_RESULT) - { - /* - Set return character set to first argument if we are returning a - string. - */ - if (first_coll) - { - set_charset((*arg)->charset()); - coercibility= (*args)->coercibility; - first_coll= 0; - } - else if ((*arg)->charset() == &my_charset_bin || - charset() == &my_charset_bin) - { - set_charset(&my_charset_bin); - coercibility= COER_NOCOLL; - } - else if ((*arg)->coercibility < coercibility) - { - if (!my_charset_same(charset(),(*arg)->charset())) - { - set_charset(&my_charset_bin); - coercibility= COER_NOCOLL; - } - else - { - coercibility= (*arg)->coercibility; - set_charset((*arg)->charset()); - } - } - } with_sum_func= with_sum_func || (*arg)->with_sum_func; used_tables_cache|=(*arg)->used_tables(); const_item_cache&= (*arg)->const_item(); @@ -2652,7 +2619,7 @@ Item *get_system_var(enum_var_type var_type, LEX_STRING name) pos=strmov(pos,"global."); memcpy(pos, var->name, var->name_length+1); // set_name() will allocate the name - item->set_name(buff,(uint) (pos-buff)+var->name_length); + item->set_name(buff,(uint) (pos-buff)+var->name_length, system_charset_info); return item; } @@ -2667,9 +2634,9 @@ Item *get_system_var(enum_var_type var_type, const char *var_name, uint length, var= find_sys_var(var_name, length); DBUG_ASSERT(var != 0); if (!(item=var->item(thd, var_type))) - return 0; // Impossible + return 0; // Impossible thd->lex.uncacheable(); - item->set_name(item_name); // Will use original name + item->set_name(item_name, 0, system_charset_info); // Will use original name return item; } @@ -2717,115 +2684,129 @@ longlong Item_func_is_free_lock::val_int() longlong Item_func_dimension::val_int() { uint32 dim; - String *wkb=args[0]->val_str(&value); + String *swkb= args[0]->val_str(&value); Geometry geom; - null_value= (!wkb || - args[0]->null_value || - geom.create_from_wkb(wkb->ptr(),wkb->length()) || - geom.dimension(&dim)); - + null_value= (!swkb || + args[0]->null_value || + geom.create_from_wkb(swkb->ptr() + SRID_SIZE, + swkb->length() - SRID_SIZE) || + geom.dimension(&dim)); return (longlong) dim; } longlong Item_func_numinteriorring::val_int() { uint32 num; - String *wkb=args[0]->val_str(&value); + String *swkb= args[0]->val_str(&value); Geometry geom; - null_value= (!wkb || - geom.create_from_wkb(wkb->ptr(),wkb->length()) || - !GEOM_METHOD_PRESENT(geom,num_interior_ring) || + null_value= (!swkb || + geom.create_from_wkb(swkb->ptr() + SRID_SIZE, + swkb->length() - SRID_SIZE) || + !GEOM_METHOD_PRESENT(geom, num_interior_ring) || geom.num_interior_ring(&num)); - return (longlong) num; } longlong Item_func_numgeometries::val_int() { - uint32 num=0; - String *wkb=args[0]->val_str(&value); + uint32 num= 0; + String *swkb= args[0]->val_str(&value); Geometry geom; - null_value= (!wkb || - geom.create_from_wkb(wkb->ptr(),wkb->length()) || - !GEOM_METHOD_PRESENT(geom,num_geometries) || - geom.num_geometries(&num)); - + null_value= (!swkb || + geom.create_from_wkb(swkb->ptr() + SRID_SIZE, + swkb->length() - SRID_SIZE) || + !GEOM_METHOD_PRESENT(geom, num_geometries) || + geom.num_geometries(&num)); return (longlong) num; } longlong Item_func_numpoints::val_int() { - uint32 num=0; - String *wkb=args[0]->val_str(&value); + uint32 num; + String *swkb= args[0]->val_str(&value); Geometry geom; - null_value= (!wkb || - args[0]->null_value || - geom.create_from_wkb(wkb->ptr(),wkb->length()) || - !GEOM_METHOD_PRESENT(geom,num_points) || - geom.num_points(&num)); - + null_value= (!swkb || + args[0]->null_value || + geom.create_from_wkb(swkb->ptr() + SRID_SIZE, + swkb->length() - SRID_SIZE) || + !GEOM_METHOD_PRESENT(geom, num_points) || + geom.num_points(&num)); return (longlong) num; } double Item_func_x::val() { - double res=0; - String *wkb=args[0]->val_str(&value); + double res; + String *swkb= args[0]->val_str(&value); Geometry geom; - null_value= (!wkb || - geom.create_from_wkb(wkb->ptr(),wkb->length()) || - !GEOM_METHOD_PRESENT(geom,get_x) || - geom.get_x(&res)); - + null_value= (!swkb || + geom.create_from_wkb(swkb->ptr() + SRID_SIZE, + swkb->length() - SRID_SIZE) || + !GEOM_METHOD_PRESENT(geom, get_x) || + geom.get_x(&res)); return res; } double Item_func_y::val() { - double res=0; - String *wkb=args[0]->val_str(&value); + double res; + String *swkb= args[0]->val_str(&value); Geometry geom; - null_value= (!wkb || - geom.create_from_wkb(wkb->ptr(),wkb->length()) || - !GEOM_METHOD_PRESENT(geom,get_y) || - geom.get_y(&res)); - + null_value= (!swkb || + geom.create_from_wkb(swkb->ptr() + SRID_SIZE, + swkb->length() - SRID_SIZE) || + !GEOM_METHOD_PRESENT(geom, get_y) || + geom.get_y(&res)); return res; } double Item_func_area::val() { - double res=0; - String *wkb=args[0]->val_str(&value); + double res; + String *swkb= args[0]->val_str(&value); Geometry geom; - null_value= (!wkb || - geom.create_from_wkb(wkb->ptr(),wkb->length()) || - !GEOM_METHOD_PRESENT(geom,area) || - geom.area(&res)); - + null_value= (!swkb || + geom.create_from_wkb(swkb->ptr() + SRID_SIZE, + swkb->length() - SRID_SIZE) || + !GEOM_METHOD_PRESENT(geom, area) || + geom.area(&res)); return res; } double Item_func_glength::val() { - double res=0; - String *wkb=args[0]->val_str(&value); + double res; + String *swkb= args[0]->val_str(&value); Geometry geom; - null_value= (!wkb || - geom.create_from_wkb(wkb->ptr(),wkb->length()) || - !GEOM_METHOD_PRESENT(geom,length) || - geom.length(&res)); + null_value= (!swkb || + geom.create_from_wkb(swkb->ptr() + SRID_SIZE, + swkb->length() - SRID_SIZE) || + !GEOM_METHOD_PRESENT(geom, length) || + geom.length(&res)); return res; } + + +longlong Item_func_srid::val_int() +{ + String *swkb= args[0]->val_str(&value); + Geometry geom; + + null_value= (!swkb || + geom.create_from_wkb(swkb->ptr() + SRID_SIZE, + swkb->length() - SRID_SIZE)); + uint32 res= uint4korr(swkb->ptr()); + return (longlong) res; +} diff --git a/sql/item_func.h b/sql/item_func.h index 860ddbbbadf..772b90fd38e 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -1112,6 +1112,17 @@ public: }; +class Item_func_srid: public Item_int_func +{ + String value; +public: + Item_func_srid(Item *a): Item_int_func(a) {} + longlong val_int(); + const char *func_name() const { return "srid"; } + void fix_length_and_dec() { max_length= 10; } +}; + + class Item_func_match_nl :public Item_func_match { public: diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 80d85e565e7..d04ed97393d 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -321,9 +321,21 @@ null: void Item_func_concat::fix_length_and_dec() { + bool first_coll= 1; max_length=0; + + set_charset(args[0]->charset(),args[0]->coercibility); for (uint i=0 ; i < arg_count ; i++) + { max_length+=args[i]->max_length; + if (set_charset(charset(), coercibility, + args[i]->charset(), args[i]->coercibility)) + { + my_error(ER_WRONG_ARGUMENTS,MYF(0),func_name()); + break; + } + } + if (max_length > MAX_BLOB_WIDTH) { max_length=MAX_BLOB_WIDTH; @@ -978,6 +990,7 @@ void Item_func_substr::fix_length_and_dec() { max_length=args[0]->max_length; + set_charset(args[0]->charset(), args[0]->coercibility); if (args[1]->const_item()) { int32 start=(int32) args[1]->val_int()-1; @@ -1791,6 +1804,7 @@ inline String* alloc_buffer(String *res,String *str,String *tmp_value, void Item_func_repeat::fix_length_and_dec() { + set_charset(args[0]->charset(), args[0]->coercibility); if (args[1]->const_item()) { max_length=(long) (args[0]->max_length * args[1]->val_int()); @@ -2015,72 +2029,20 @@ String *Item_func_conv::val_str(String *str) String *Item_func_conv_charset::val_str(String *str) { - my_wc_t wc; - int cnvres; - const uchar *s, *se; - uchar *d, *d0, *de; - uint32 dmaxlen; String *arg= args[0]->val_str(str); - CHARSET_INFO *from,*to; - if (!arg) { null_value=1; return 0; } - null_value=0; - - from=arg->charset(); - to=conv_charset; - - s=(const uchar*)arg->ptr(); - se=s+arg->length(); - - dmaxlen=arg->length()*to->mbmaxlen+1; - str->alloc(dmaxlen); - d0=d=(unsigned char*)str->ptr(); - de=d+dmaxlen; - - while (1) - { - cnvres=from->mb_wc(from,&wc,s,se); - if (cnvres>0) - { - s+=cnvres; - } - else if (cnvres==MY_CS_ILSEQ) - { - s++; - wc='?'; - } - else - break; - -outp: - cnvres=to->wc_mb(to,wc,d,de); - if (cnvres>0) - { - d+=cnvres; - } - else if (cnvres==MY_CS_ILUNI && wc!='?') - { - wc='?'; - goto outp; - } - else - break; - }; - - str->length((uint32) (d-d0)); - str->set_charset(to); - return str; + null_value= str->copy(arg->ptr(),arg->length(),arg->charset(),conv_charset); + return null_value ? 0 : str; } void Item_func_conv_charset::fix_length_and_dec() { max_length = args[0]->max_length*conv_charset->mbmaxlen; - coercibility= COER_IMPLICIT; - set_charset(conv_charset); + set_charset(conv_charset, COER_IMPLICIT); } @@ -2222,9 +2184,7 @@ bool Item_func_set_collation::fix_fields(THD *thd,struct st_table_list *tables, set_collation->name,args[0]->charset()->csname); return 1; } - set_charset(set_collation); - - coercibility= COER_EXPLICIT; + set_charset(set_collation, COER_EXPLICIT); with_sum_func= with_sum_func || args[0]->with_sum_func; used_tables_cache=args[0]->used_tables(); const_item_cache=args[0]->const_item(); @@ -2560,10 +2520,19 @@ String *Item_func_geometry_from_text::val_str(String *str) { Geometry geom; String arg_val; - String *wkt = args[0]->val_str(&arg_val); + String *wkt= args[0]->val_str(&arg_val); GTextReadStream trs(wkt->ptr(), wkt->length()); + uint32 srid; + if ((arg_count == 2) && !args[1]->null_value) + srid= args[1]->val_int(); + else + srid= 0; + + if (str->reserve(SRID_SIZE, 512)) + return 0; str->length(0); + str->q_append(srid); if ((null_value=(args[0]->null_value || geom.create_from_wkt(&trs, str, 0)))) return 0; return str; @@ -2576,19 +2545,51 @@ void Item_func_geometry_from_text::fix_length_and_dec() } +String *Item_func_geometry_from_wkb::val_str(String *str) +{ + String arg_val; + String *wkb= args[0]->val_str(&arg_val); + Geometry geom; + uint32 srid; + + if ((arg_count == 2) && !args[1]->null_value) + srid= args[1]->val_int(); + else + srid= 0; + + if (str->reserve(SRID_SIZE, 512)) + return 0; + str->length(0); + str->q_append(srid); + if ((null_value= (args[0]->null_value || + geom.create_from_wkb(wkb->ptr(), wkb->length())))) + return 0; + + str->append(*wkb); + return str; +} + + +void Item_func_geometry_from_wkb::fix_length_and_dec() +{ + max_length=MAX_BLOB_WIDTH; +} + + String *Item_func_as_text::val_str(String *str) { String arg_val; - String *wkt = args[0]->val_str(&arg_val); + String *swkb= args[0]->val_str(&arg_val); Geometry geom; - if ((null_value=(args[0]->null_value || - geom.create_from_wkb(wkt->ptr(),wkt->length())))) + if ((null_value= (args[0]->null_value || + geom.create_from_wkb(swkb->ptr() + SRID_SIZE, + swkb->length() - SRID_SIZE)))) return 0; str->length(0); - if ((null_value=geom.as_wkt(str))) + if ((null_value= geom.as_wkt(str))) return 0; return str; @@ -2601,11 +2602,12 @@ void Item_func_as_text::fix_length_and_dec() String *Item_func_geometry_type::val_str(String *str) { - String *wkt = args[0]->val_str(str); + String *swkb= args[0]->val_str(str); Geometry geom; - if ((null_value=(args[0]->null_value || - geom.create_from_wkb(wkt->ptr(),wkt->length())))) + if ((null_value= (args[0]->null_value || + geom.create_from_wkb(swkb->ptr() + SRID_SIZE, + swkb->length() - SRID_SIZE)))) return 0; str->copy(geom.get_class_info()->m_name, strlen(geom.get_class_info()->m_name), @@ -2616,14 +2618,19 @@ String *Item_func_geometry_type::val_str(String *str) String *Item_func_envelope::val_str(String *str) { - String *res = args[0]->val_str(str); + String *res= args[0]->val_str(str); Geometry geom; - if ((null_value = args[0]->null_value || - geom.create_from_wkb(res->ptr(),res->length()))) + if ((null_value= args[0]->null_value || + geom.create_from_wkb(res->ptr() + SRID_SIZE, + res->length() - SRID_SIZE))) return 0; + uint32 srid= uint4korr(res->ptr()); + if (res->reserve(SRID_SIZE, 512)) + return 0; res->length(0); + res->q_append(srid); return (null_value= geom.envelope(res)) ? 0 : res; } @@ -2631,15 +2638,22 @@ String *Item_func_envelope::val_str(String *str) String *Item_func_centroid::val_str(String *str) { String arg_val; - String *wkb = args[0]->val_str(&arg_val); + String *swkb= args[0]->val_str(&arg_val); Geometry geom; - null_value = args[0]->null_value || - geom.create_from_wkb(wkb->ptr(),wkb->length()) || - !GEOM_METHOD_PRESENT(geom,centroid) || - geom.centroid(str); + if ((null_value= args[0]->null_value || + geom.create_from_wkb(swkb->ptr() + SRID_SIZE, + swkb->length() - SRID_SIZE) || + !GEOM_METHOD_PRESENT(geom, centroid))) + return 0; + + if (str->reserve(SRID_SIZE, 512)) + return 0; + str->length(0); + uint32 srid= uint4korr(swkb->ptr()); + str->q_append(srid); - return null_value ? 0: str; + return (null_value= geom.centroid(str)) ? 0 : str; } @@ -2650,15 +2664,20 @@ String *Item_func_centroid::val_str(String *str) String *Item_func_spatial_decomp::val_str(String *str) { String arg_val; - String *wkb = args[0]->val_str(&arg_val); + String *swkb= args[0]->val_str(&arg_val); Geometry geom; - if ((null_value = (args[0]->null_value || - geom.create_from_wkb(wkb->ptr(),wkb->length())))) + if ((null_value= (args[0]->null_value || + geom.create_from_wkb(swkb->ptr() + SRID_SIZE, + swkb->length() - SRID_SIZE)))) return 0; - null_value=1; + null_value= 1; + if (str->reserve(SRID_SIZE, 512)) + return 0; str->length(0); + uint32 srid= uint4korr(swkb->ptr()); + str->q_append(srid); switch(decomp_func) { case SP_STARTPOINT: @@ -2679,7 +2698,7 @@ String *Item_func_spatial_decomp::val_str(String *str) default: goto ret; } - null_value=0; + null_value= 0; ret: return null_value ? 0 : str; @@ -2689,28 +2708,30 @@ ret: String *Item_func_spatial_decomp_n::val_str(String *str) { String arg_val; - String *wkb = args[0]->val_str(&arg_val); - long n = (long) args[1]->val_int(); + String *swkb= args[0]->val_str(&arg_val); + long n= (long) args[1]->val_int(); Geometry geom; - if ((null_value = (args[0]->null_value || - args[1]->null_value || - geom.create_from_wkb(wkb->ptr(),wkb->length()) ))) + if ((null_value= (args[0]->null_value || args[1]->null_value || + geom.create_from_wkb(swkb->ptr() + SRID_SIZE, + swkb->length() - SRID_SIZE)))) return 0; - null_value=1; - + null_value= 1; + if (str->reserve(SRID_SIZE, 512)) + return 0; + str->length(0); + uint32 srid= uint4korr(swkb->ptr()); + str->q_append(srid); switch(decomp_func_n) { case SP_POINTN: - if (!GEOM_METHOD_PRESENT(geom,point_n) || - geom.point_n(n,str)) + if (!GEOM_METHOD_PRESENT(geom,point_n) || geom.point_n(n,str)) goto ret; break; case SP_GEOMETRYN: - if (!GEOM_METHOD_PRESENT(geom,geometry_n) || - geom.geometry_n(n,str)) + if (!GEOM_METHOD_PRESENT(geom,geometry_n) || geom.geometry_n(n,str)) goto ret; break; @@ -2723,7 +2744,7 @@ String *Item_func_spatial_decomp_n::val_str(String *str) default: goto ret; } - null_value=0; + null_value= 0; ret: return null_value ? 0 : str; @@ -2746,9 +2767,9 @@ String *Item_func_point::val_str(String *str) double x= args[0]->val(); double y= args[1]->val(); - if ( (null_value = (args[0]->null_value || - args[1]->null_value || - str->realloc(1+4+8+8)))) + if ( (null_value= (args[0]->null_value || + args[1]->null_value || + str->realloc(1 + 4 + 8 + 8)))) return 0; str->length(0); @@ -2775,19 +2796,19 @@ String *Item_func_spatial_collection::val_str(String *str) String arg_value; uint i; - null_value=1; + null_value= 1; str->length(0); - if (str->reserve(9,512)) + if (str->reserve(1 + 4 + 4, 512)) return 0; - str->q_append((char)Geometry::wkbNDR); - str->q_append((uint32)coll_type); - str->q_append((uint32)arg_count); + str->q_append((char) Geometry::wkbNDR); + str->q_append((uint32) coll_type); + str->q_append((uint32) arg_count); - for (i = 0; i < arg_count; ++i) + for (i= 0; i < arg_count; ++i) { - String *res = args[i]->val_str(&arg_value); + String *res= args[i]->val_str(&arg_value); if (args[i]->null_value) goto ret; @@ -2798,16 +2819,16 @@ String *Item_func_spatial_collection::val_str(String *str) any checkings for item types, so just copy them into target collection */ - if ((null_value=(str->reserve(res->length(),512)))) + if ((null_value= str->reserve(res->length(), 512))) goto ret; - str->q_append(res->ptr(),res->length()); + str->q_append(res->ptr(), res->length()); } else { enum Geometry::wkbType wkb_type; uint32 len=res->length(); - const char *data=res->ptr()+1; + const char *data= res->ptr() + 1; /* In the case of named collection we must to @@ -2818,8 +2839,8 @@ String *Item_func_spatial_collection::val_str(String *str) if (len < 5) goto ret; wkb_type= (Geometry::wkbType) uint4korr(data); - data+=4; - len-=5; + data+= 4; + len-= 5; if (wkb_type != item_type) goto ret; @@ -2830,17 +2851,17 @@ String *Item_func_spatial_collection::val_str(String *str) if (len < WKB_HEADER_SIZE) goto ret; - data-=WKB_HEADER_SIZE; - len+=WKB_HEADER_SIZE; - if (str->reserve(len,512)) + data-= WKB_HEADER_SIZE; + len+= WKB_HEADER_SIZE; + if (str->reserve(len, 512)) goto ret; - str->q_append(data,len); + str->q_append(data, len); break; case Geometry::wkbLineString: - if (str->reserve(POINT_DATA_SIZE,512)) + if (str->reserve(POINT_DATA_SIZE, 512)) goto ret; - str->q_append(data,POINT_DATA_SIZE); + str->q_append(data, POINT_DATA_SIZE); break; case Geometry::wkbPolygon: @@ -2851,25 +2872,25 @@ String *Item_func_spatial_collection::val_str(String *str) if (len < 4 + 2 * POINT_DATA_SIZE) goto ret; - uint32 llen=len; - const char *ldata=data; + uint32 llen= len; + const char *ldata= data; - n_points=uint4korr(data); - data+=4; - float8get(x1,data); - data+=8; - float8get(y1,data); - data+=8; + n_points= uint4korr(data); + data+= 4; + float8get(x1, data); + data+= 8; + float8get(y1, data); + data+= 8; - data+=(n_points-2) * POINT_DATA_SIZE; + data+= (n_points - 2) * POINT_DATA_SIZE; - float8get(x2,data); - float8get(y2,data+8); + float8get(x2, data); + float8get(y2, data + 8); if ((x1 != x2) || (y1 != y2)) goto ret; - if (str->reserve(llen,512)) + if (str->reserve(llen, 512)) goto ret; str->q_append(ldata, llen); } diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index 8bfa4317698..84653a8315c 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -151,7 +151,11 @@ class Item_str_conv :public Item_str_func { public: Item_str_conv(Item *item) :Item_str_func(item) {} - void fix_length_and_dec() { max_length = args[0]->max_length; } + void fix_length_and_dec() + { + set_charset(args[0]->charset(), args[0]->coercibility); + max_length = args[0]->max_length; + } }; @@ -632,15 +636,28 @@ public: Spatial functions ********************************************************/ +#define SRID_SIZE sizeof(uint32) + class Item_func_geometry_from_text :public Item_str_func { public: Item_func_geometry_from_text(Item *a) :Item_str_func(a) {} + Item_func_geometry_from_text(Item *a, Item *srid) :Item_str_func(a, srid) {} const char *func_name() const { return "geometryfromtext"; } String *val_str(String *); void fix_length_and_dec(); }; +class Item_func_geometry_from_wkb: public Item_str_func +{ +public: + Item_func_geometry_from_wkb(Item *a) :Item_str_func(a) {} + Item_func_geometry_from_wkb(Item *a, Item *srid) :Item_str_func(a, srid) {} + const char *func_name() const { return "geometryfromwkb"; } + String *val_str(String *); + void fix_length_and_dec(); +}; + class Item_func_as_text :public Item_str_func { public: @@ -683,7 +700,8 @@ public: class Item_func_point :public Item_str_func { public: - Item_func_point(Item *a,Item *b) :Item_str_func(a,b) {} + Item_func_point(Item *a, Item *b) :Item_str_func(a, b) {} + Item_func_point(Item *a, Item *b, Item *srid) :Item_str_func(a, b, srid) {} const char *func_name() const { return "point"; } String *val_str(String *); void fix_length_and_dec(){max_length=MAX_BLOB_WIDTH;} diff --git a/sql/lex.h b/sql/lex.h index 5b1cbb58c1e..9156a2d35bb 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -496,7 +496,9 @@ static SYMBOL sql_functions[] = { { "GEOMCOLLFROMTEXT", SYM(GEOMCOLLFROMTEXT),0,0}, { "GEOMFROMTEXT", SYM(GEOMFROMTEXT),0,0}, { "GEOMETRYFROMTEXT", SYM(GEOMFROMTEXT),0,0}, - { "GLENGTH", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_glength)}, + { "GEOMFROMWKB", SYM(GEOMFROMWKB),0,0}, + { "GEOMETRYFROMWKB", SYM(GEOMFROMWKB),0,0}, + { "GLENGTH", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_glength)}, { "GREATEST", SYM(GREATEST_SYM),0,0}, { "GROUP_UNIQUE_USERS", SYM(GROUP_UNIQUE_USERS),0,0}, { "HEX", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_hex)}, @@ -579,6 +581,7 @@ static SYMBOL sql_functions[] = { { "SOUNDEX", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_soundex)}, { "SPACE", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_space)}, { "SQRT", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_sqrt)}, + { "SRID", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_srid)}, { "STARTPOINT", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_startpoint)}, { "STD", SYM(STD_SYM),0,0}, { "STDDEV", SYM(STD_SYM),0,0}, diff --git a/sql/log.cc b/sql/log.cc index 00bd44274f9..cd4c2a38ac8 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1196,6 +1196,7 @@ bool MYSQL_LOG::write(Log_event* event_info) goto err; } } +#if 0 if (thd->variables.convert_set) { char buf[256], *p; @@ -1206,6 +1207,7 @@ bool MYSQL_LOG::write(Log_event* event_info) if (e.write(file)) goto err; } +#endif } event_info->set_log_pos(this); if (event_info->write(file) || diff --git a/sql/log_event.cc b/sql/log_event.cc index b57a691c267..68b897d30ae 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -348,10 +348,10 @@ int Log_event::net_send(Protocol *protocol, const char* log_name, my_off_t pos) log_name = p + 1; protocol->prepare_for_resend(); - protocol->store(log_name, system_charset_info); + protocol->store(log_name, &my_charset_bin); protocol->store((ulonglong) pos); event_type = get_type_str(); - protocol->store(event_type, strlen(event_type), system_charset_info); + protocol->store(event_type, strlen(event_type), &my_charset_bin); protocol->store((uint32) server_id); protocol->store((ulonglong) log_pos); pack_info(protocol); @@ -731,7 +731,7 @@ void Query_log_event::pack_info(Protocol *protocol) memcpy(pos, query, q_len); pos+= q_len; } - protocol->store(buf, pos-buf, system_charset_info); + protocol->store(buf, pos-buf, &my_charset_bin); my_free(buf, MYF(MY_ALLOW_ZERO_PTR)); } #endif @@ -951,7 +951,7 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli) VOID(pthread_mutex_lock(&LOCK_thread_count)); thd->db = thd->query = 0; VOID(pthread_mutex_unlock(&LOCK_thread_count)); - thd->variables.convert_set = 0; + //thd->variables.convert_set = 0; close_thread_tables(thd); free_root(&thd->mem_root,0); return 1; @@ -962,7 +962,7 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli) thd->query= 0; // just to be sure VOID(pthread_mutex_unlock(&LOCK_thread_count)); // assume no convert for next query unless set explictly - thd->variables.convert_set = 0; + //thd->variables.convert_set = 0; close_thread_tables(thd); if (thd->query_error || thd->is_fatal_error) @@ -1000,7 +1000,7 @@ void Start_log_event::pack_info(Protocol *protocol) pos= strmov(pos, server_version); pos= strmov(pos, ", Binlog ver: "); pos=int10_to_str(binlog_version, pos, 10); - protocol->store(buf, pos-buf, system_charset_info); + protocol->store(buf, pos-buf, &my_charset_bin); } #endif @@ -1200,7 +1200,7 @@ void Load_log_event::pack_info(Protocol *protocol) *pos++= ')'; } - protocol->store(buf, pos-buf, system_charset_info); + protocol->store(buf, pos-buf, &my_charset_bin); my_free(buf, MYF(MY_ALLOW_ZERO_PTR)); } #endif @@ -1674,7 +1674,7 @@ void Rotate_log_event::pack_info(Protocol *protocol) b_pos=longlong10_to_str(pos, b_pos, 10); if (flags & LOG_EVENT_FORCED_ROTATE_F) b_pos= strmov(b_pos ,"; forced by master"); - protocol->store(buf, b_pos-buf, system_charset_info); + protocol->store(buf, b_pos-buf, &my_charset_bin); my_free(buf, MYF(MY_ALLOW_ZERO_PTR)); } #endif @@ -1809,7 +1809,7 @@ void Intvar_log_event::pack_info(Protocol *protocol) pos= strmov(buf, get_var_type_name()); *(pos++)='='; pos= longlong10_to_str(val, pos, -10); - protocol->store(buf, pos-buf, system_charset_info); + protocol->store(buf, pos-buf, &my_charset_bin); } #endif @@ -1920,7 +1920,7 @@ void Rand_log_event::pack_info(Protocol *protocol) pos= int10_to_str((long) seed1, pos, 10); pos= strmov(pos, ",rand_seed2="); pos= int10_to_str((long) seed2, pos, 10); - protocol->store(buf1, (uint) (pos-buf1), system_charset_info); + protocol->store(buf1, (uint) (pos-buf1), &my_charset_bin); } #endif @@ -2022,7 +2022,7 @@ void User_var_log_event::pack_info(Protocol* protocol) buf[0]= '@'; buf[1+name_len]= '='; memcpy(buf+1, name, name_len); - protocol->store(buf, event_len, system_charset_info); + protocol->store(buf, event_len, &my_charset_bin); my_free(buf, MYF(MY_ALLOW_ZERO_PTR)); } #endif // !MYSQL_CLIENT @@ -2219,7 +2219,7 @@ void Slave_log_event::pack_info(Protocol *protocol) pos= strmov(pos, master_log); pos= strmov(pos, ",pos="); pos= longlong10_to_str(master_pos, pos, 10); - protocol->store(buf, pos-buf, system_charset_info); + protocol->store(buf, pos-buf, &my_charset_bin); } #endif // !MYSQL_CLIENT @@ -2553,7 +2553,7 @@ void Create_file_log_event::pack_info(Protocol *protocol) pos= int10_to_str((long) file_id, pos, 10); pos= strmov(pos, ";block_len="); pos= int10_to_str((long) block_len, pos, 10); - protocol->store(buf, pos-buf, system_charset_info); + protocol->store(buf, pos-buf, &my_charset_bin); } #endif @@ -2704,7 +2704,7 @@ void Append_block_log_event::pack_info(Protocol *protocol) length= (uint) my_sprintf(buf, (buf, ";file_id=%u;block_len=%u", file_id, block_len)); - protocol->store(buf, (int32) length, system_charset_info); + protocol->store(buf, (int32) length, &my_charset_bin); } #endif @@ -2817,7 +2817,7 @@ void Delete_file_log_event::pack_info(Protocol *protocol) char buf[64]; uint length; length= (uint) my_sprintf(buf, (buf, ";file_id=%u", (uint) file_id)); - protocol->store(buf, (int32) length, system_charset_info); + protocol->store(buf, (int32) length, &my_charset_bin); } #endif @@ -2916,7 +2916,7 @@ void Execute_load_log_event::pack_info(Protocol *protocol) char buf[64]; uint length; length= (uint) my_sprintf(buf, (buf, ";file_id=%u", (uint) file_id)); - protocol->store(buf, (int32) length, system_charset_info); + protocol->store(buf, (int32) length, &my_charset_bin); } /***************************************************************************** diff --git a/sql/mysqld.cc b/sql/mysqld.cc index e9026eb5b00..2298ae7b9ea 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2084,7 +2084,6 @@ static int init_common_variables(const char *conf_file_name, int argc, #endif if (!(default_charset_info= get_charset_by_name(sys_charset.value, MYF(MY_WME)))) return 1; - system_charset_info= default_charset_info; charsets_list= list_charsets(MYF(MY_CS_COMPILED | MY_CS_CONFIG)); if (use_temp_pool && bitmap_init(&temp_pool,1024,1)) diff --git a/sql/protocol.cc b/sql/protocol.cc index c7ce38eadac..af8f966a4b6 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -43,11 +43,6 @@ bool Protocol::net_store_data(const char *from, uint length) packet->length((uint) (to+length-packet->ptr())); return 0; } - -inline bool Protocol::convert_str(const char *from, uint length) -{ - return convert->store(packet, from, length); -} #endif @@ -472,7 +467,6 @@ char *net_store_data(char *to,longlong from) void Protocol::init(THD *thd_arg) { thd=thd_arg; - convert=thd->variables.convert_set; packet= &thd->packet; #ifndef DEBUG_OFF field_types= 0; @@ -487,15 +481,12 @@ void Protocol::init(THD *thd_arg) send_fields() THD Thread data object list List of items to send to client - convert object used to convertation to another character set flag Bit mask with the following functions: 1 send number of rows 2 send default values DESCRIPTION Sum fields has table name empty and field_name. - Uses send_fields_convert() and send_fields() depending on - if we have an active character set convert or not. RETURN VALUES 0 ok @@ -712,9 +703,6 @@ bool Protocol_simple::store(const char *from, uint length, CHARSET_INFO *cs) field_types[field_pos] <= MYSQL_TYPE_GEOMETRY)); field_pos++; #endif - if (convert) - return convert_str(from, length); -#if 0 if (cs != this->thd->charset()) { String tmp; @@ -722,7 +710,6 @@ bool Protocol_simple::store(const char *from, uint length, CHARSET_INFO *cs) return net_store_data(tmp.ptr(), tmp.length()); } else -#endif return net_store_data(from, length); } @@ -813,11 +800,16 @@ bool Protocol_simple::store(Field *field) field_pos++; #endif char buff[MAX_FIELD_WIDTH]; - String tmp(buff,sizeof(buff), &my_charset_bin); - field->val_str(&tmp,&tmp); - if (convert) - return convert_str(tmp.ptr(), tmp.length()); - return net_store_data(tmp.ptr(), tmp.length()); + String tmp1(buff,sizeof(buff), &my_charset_bin); + field->val_str(&tmp1,&tmp1); + if (field->charset() != this->thd->charset()) + { + String tmp; + tmp.copy(tmp1.ptr(), tmp1.length(), tmp1.charset(), this->thd->charset()); + return net_store_data(tmp.ptr(), tmp.length()); + } + else + return net_store_data(tmp1.ptr(), tmp1.length()); } @@ -924,8 +916,6 @@ bool Protocol_prep::store(const char *from,uint length, CHARSET_INFO *cs) field_types[field_pos] <= MYSQL_TYPE_GEOMETRY)); #endif field_pos++; - if (convert) - return convert_str(from, length); return net_store_data(from, length); } diff --git a/sql/protocol.h b/sql/protocol.h index e9df013e81c..71ad5c1302b 100644 --- a/sql/protocol.h +++ b/sql/protocol.h @@ -20,7 +20,6 @@ #define PACKET_BUFFET_EXTRA_ALLOC 1024 -class CONVERT; class i_string; class THD; #ifdef EMBEDDED_LIBRARY @@ -37,15 +36,12 @@ protected: #endif uint field_count; bool net_store_data(const char *from, uint length); - bool convert_str(const char *from, uint length); #ifdef EMBEDDED_LIBRARY char **next_field; MYSQL_FIELD *next_mysql_field; MEM_ROOT *alloc; #endif public: - CONVERT *convert; - Protocol() {} Protocol(THD *thd) { init(thd); } void init(THD* thd); diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc index 82fa87658ed..46791c13219 100644 --- a/sql/repl_failsafe.cc +++ b/sql/repl_failsafe.cc @@ -440,7 +440,7 @@ int show_new_master(THD* thd) if (protocol->send_fields(&field_list, 1)) DBUG_RETURN(-1); protocol->prepare_for_resend(); - protocol->store(lex_mi->log_file_name, system_charset_info); + protocol->store(lex_mi->log_file_name, &my_charset_bin); protocol->store((ulonglong) lex_mi->pos); if (protocol->write()) DBUG_RETURN(-1); @@ -638,11 +638,11 @@ int show_slave_hosts(THD* thd) SLAVE_INFO* si = (SLAVE_INFO*) hash_element(&slave_list, i); protocol->prepare_for_resend(); protocol->store((uint32) si->server_id); - protocol->store(si->host, system_charset_info); + protocol->store(si->host, &my_charset_bin); if (opt_show_slave_auth_info) { - protocol->store(si->user, system_charset_info); - protocol->store(si->password, system_charset_info); + protocol->store(si->user, &my_charset_bin); + protocol->store(si->password, &my_charset_bin); } protocol->store((uint32) si->port); protocol->store((uint32) si->rpl_recovery_rank); diff --git a/sql/set_var.cc b/sql/set_var.cc index 4189543e70e..cb49ad603d9 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -105,7 +105,6 @@ sys_var_str sys_charset("character_set", sys_update_charset, sys_set_default_charset); sys_var_client_collation sys_client_collation("client_collation"); -sys_var_thd_conv_charset sys_convert_charset("convert_character_set"); sys_var_bool_ptr sys_concurrent_insert("concurrent_insert", &myisam_concurrent_insert); sys_var_long_ptr sys_connect_timeout("connect_timeout", @@ -338,7 +337,6 @@ sys_var *sys_variables[]= &sys_client_collation, &sys_concurrent_insert, &sys_connect_timeout, - &sys_convert_charset, &sys_default_week_format, &sys_delay_key_write, &sys_delayed_insert_limit, @@ -447,7 +445,6 @@ struct show_var_st init_vars[]= { {sys_client_collation.name, (char*) &sys_client_collation, SHOW_SYS}, {sys_concurrent_insert.name,(char*) &sys_concurrent_insert, SHOW_SYS}, {sys_connect_timeout.name, (char*) &sys_connect_timeout, SHOW_SYS}, - {sys_convert_charset.name, (char*) &sys_convert_charset, SHOW_SYS}, {"datadir", mysql_real_data_home, SHOW_CHAR}, {"default_week_format", (char*) &sys_default_week_format, SHOW_SYS}, {sys_delay_key_write.name, (char*) &sys_delay_key_write, SHOW_SYS}, @@ -1134,56 +1131,38 @@ byte *sys_var_thd_bit::value_ptr(THD *thd, enum_var_type type) } -bool sys_var_thd_conv_charset::check(THD *thd, set_var *var) -{ - CONVERT *tmp; - char buff[80]; - String str(buff,sizeof(buff), system_charset_info), *res; - - if (!var->value) // Default value - { - var->save_result.convert= (var->type != OPT_GLOBAL ? - global_system_variables.convert_set - : (CONVERT*) 0); - return 0; - } - if (!(res=var->value->val_str(&str))) - res= &empty_string; - - if (!(tmp=get_convert_set(res->c_ptr()))) - { - my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), res->c_ptr()); - return 1; - } - var->save_result.convert=tmp; // Save for update - return 0; -} +typedef struct old_names_map_st { + const char *old_name; + const char *new_name; +} my_old_conv; +static my_old_conv old_conv[]= +{ + { "cp1251_koi8" , "cp1251" }, + { "cp1250_latin2" , "cp1250" }, + { "kam_latin2" , "keybcs2" }, + { "mac_latin2" , "MacRoman" }, + { "macce_latin2" , "MacCE" }, + { "pc2_latin2" , "pclatin2" }, + { "vga_latin2" , "pclatin1" }, + { "koi8_cp1251" , "koi8r" }, + { "win1251ukr_koi8_ukr" , "win1251ukr" }, + { "koi8_ukr_win1251ukr" , "koi8u" }, + { NULL , NULL } +}; -bool sys_var_thd_conv_charset::update(THD *thd, set_var *var) +static CHARSET_INFO *get_old_charset_by_name(const char *name) { - if (var->type == OPT_GLOBAL) - global_system_variables.convert_set= var->save_result.convert; - else + my_old_conv *c; + + for (c= old_conv; c->old_name; c++) { - thd->lex.convert_set= thd->variables.convert_set= - var->save_result.convert; - thd->protocol_simple.init(thd); - thd->protocol_prep.init(thd); + if (!my_strcasecmp(&my_charset_latin1,name,c->old_name)) + return get_charset_by_name(c->new_name,MYF(0)); } - return 0; + return NULL; } - -byte *sys_var_thd_conv_charset::value_ptr(THD *thd, enum_var_type type) -{ - CONVERT *conv= ((type == OPT_GLOBAL) ? - global_system_variables.convert_set : - thd->variables.convert_set); - return conv ? (byte*) conv->name : (byte*) ""; -} - - bool sys_var_client_collation::check(THD *thd, set_var *var) { CHARSET_INFO *tmp; @@ -1201,7 +1180,8 @@ bool sys_var_client_collation::check(THD *thd, set_var *var) if (!(res=var->value->val_str(&str))) res= &empty_string; - if (!(tmp=get_charset_by_name(res->c_ptr(),MYF(0)))) + if (!(tmp=get_charset_by_name(res->c_ptr(),MYF(0))) && + !(tmp=get_old_charset_by_name(res->c_ptr()))) { my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), res->c_ptr()); return 1; diff --git a/sql/set_var.h b/sql/set_var.h index b84e0b888e2..d91b6796d20 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -406,23 +406,6 @@ public: }; -class sys_var_thd_conv_charset :public sys_var_thd -{ -public: - sys_var_thd_conv_charset(const char *name_arg) - :sys_var_thd(name_arg) - {} - bool check(THD *thd, set_var *var); - bool update(THD *thd, set_var *var); - SHOW_TYPE type() { return SHOW_CHAR; } - byte *value_ptr(THD *thd, enum_var_type type); - bool check_update_type(Item_result type) - { - return type != STRING_RESULT; /* Only accept strings */ - } - bool check_default(enum_var_type type) { return 0; } -}; - class sys_var_client_collation :public sys_var_thd { public: @@ -490,7 +473,6 @@ public: union { CHARSET_INFO *charset; - CONVERT *convert; ulong ulong_value; } save_result; diff --git a/sql/slave.cc b/sql/slave.cc index c66f5c307d4..eea523a0260 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1625,22 +1625,22 @@ int show_master_info(THD* thd, MASTER_INFO* mi) pthread_mutex_lock(&mi->data_lock); pthread_mutex_lock(&mi->rli.data_lock); - protocol->store(mi->host, system_charset_info); - protocol->store(mi->user, system_charset_info); + protocol->store(mi->host, &my_charset_bin); + protocol->store(mi->user, &my_charset_bin); protocol->store((uint32) mi->port); protocol->store((uint32) mi->connect_retry); - protocol->store(mi->master_log_name, system_charset_info); + protocol->store(mi->master_log_name, &my_charset_bin); protocol->store((ulonglong) mi->master_log_pos); protocol->store(mi->rli.relay_log_name + - dirname_length(mi->rli.relay_log_name), system_charset_info); + dirname_length(mi->rli.relay_log_name), &my_charset_bin); protocol->store((ulonglong) mi->rli.relay_log_pos); - protocol->store(mi->rli.master_log_name, system_charset_info); - protocol->store(mi->slave_running ? "Yes":"No", system_charset_info); - protocol->store(mi->rli.slave_running ? "Yes":"No", system_charset_info); + protocol->store(mi->rli.master_log_name, &my_charset_bin); + protocol->store(mi->slave_running ? "Yes":"No", &my_charset_bin); + protocol->store(mi->rli.slave_running ? "Yes":"No", &my_charset_bin); protocol->store(&replicate_do_db); protocol->store(&replicate_ignore_db); protocol->store((uint32) mi->rli.last_slave_errno); - protocol->store(mi->rli.last_slave_error, system_charset_info); + protocol->store(mi->rli.last_slave_error, &my_charset_bin); protocol->store((uint32) mi->rli.slave_skip_counter); protocol->store((ulonglong) mi->rli.master_log_pos); protocol->store((ulonglong) mi->rli.log_space_total); diff --git a/sql/spatial.cc b/sql/spatial.cc index 3345c2756e7..df28733782f 100644 --- a/sql/spatial.cc +++ b/sql/spatial.cc @@ -78,17 +78,17 @@ int Geometry::create_from_wkb(const char *data, uint32 data_len) { uint32 geom_type; - if (data_len < 1+4) + if (data_len < 1 + 4) return 1; - data += sizeof(char); - + data++; //FIXME: check byte ordering - geom_type = uint4korr(data); - data += 4; - m_vmt = find_class(geom_type); - if (!m_vmt) return -1; - m_data = data; - m_data_end = data + data_len; + geom_type= uint4korr(data); + data+= 4; + m_vmt= find_class(geom_type); + if (!m_vmt) + return -1; + m_data= data; + m_data_end= data + data_len; return 0; } diff --git a/sql/spatial.h b/sql/spatial.h index 15e4f7353ed..d9c14afbe30 100644 --- a/sql/spatial.h +++ b/sql/spatial.h @@ -225,7 +225,6 @@ public: wkbNDR = 1 /* Little Endian */ }; - class GClassInfo { public: diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index 90fd61ebeb7..bd6d7f83c95 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -778,11 +778,8 @@ void Query_cache::store_query(THD *thd, TABLE_LIST *tables_used) most significant bit - CLIENT_LONG_FLAG, other - charset number (0 no charset convertion) */ - if (thd->variables.convert_set != 0) - { - flags|= (byte) thd->variables.convert_set->number(); - DBUG_ASSERT(thd->variables.convert_set->number() < 128); - } + flags|= (byte) thd->charset()->number; + DBUG_ASSERT(thd->charset()->number < 128); tot_length=thd->query_length+thd->db_length+2; thd->query[tot_length-1] = (char) flags; @@ -935,11 +932,8 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length) Other - charset number (0 no charset convertion) */ flags = (thd->client_capabilities & CLIENT_LONG_FLAG ? 0x80 : 0); - if (thd->variables.convert_set != 0) - { - flags |= (byte) thd->variables.convert_set->number(); - DBUG_ASSERT(thd->variables.convert_set->number() < 128); - } + flags |= (byte) thd->charset()->number; + DBUG_ASSERT(thd->charset()->number < 128); sql[tot_length-1] = (char) flags; query_block = (Query_cache_block *) hash_search(&queries, (byte*) sql, tot_length); diff --git a/sql/sql_class.h b/sql/sql_class.h index af60ea6d466..b832bbffac8 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -172,32 +172,6 @@ public: /* character conversion tables */ -class CONVERT; -CONVERT *get_convert_set(const char *name_ptr); - -class CONVERT -{ - const uchar *from_map,*to_map; - void convert_array(const uchar *mapping,uchar *buff,uint length); -public: - const char *name; - uint numb; - CONVERT(const char *name_par,uchar *from_par,uchar *to_par, uint number) - :from_map(from_par),to_map(to_par),name(name_par),numb(number) {} - friend CONVERT *get_convert_set(const char *name_ptr); - inline void convert(char *a,uint length) - { - convert_array(from_map, (uchar*) a,length); - } - char *store_dest(char *to, const char *from, uint length) - { - for (const char *end=from+length ; from != end ; from++) - *to++= to_map[(uchar) *from]; - return to; - } - bool store(String *, const char *,uint); - inline uint number() { return numb; } -}; typedef struct st_copy_info { ha_rows records; @@ -401,7 +375,6 @@ struct system_variables my_bool low_priority_updates; my_bool new_mode; - CONVERT *convert_set; CHARSET_INFO *thd_charset; }; diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 03ccf88316c..ffa5416eaf5 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -615,7 +615,6 @@ int mysqld_show_create_db(THD *thd, char *dbname, uint db_access; bool found_libchar; HA_CREATE_INFO create; - CONVERT *convert=thd->variables.convert_set; uint create_options = create_info ? create_info->options : 0; Protocol *protocol=thd->protocol; DBUG_ENTER("mysql_show_create_db"); diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 378aa380a3c..da67f5646fc 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -107,6 +107,7 @@ void lex_free(void) LEX *lex_start(THD *thd, uchar *buf,uint length) { LEX *lex= &thd->lex; + lex->thd= thd; lex->next_state=MY_LEX_START; lex->end_of_query=(lex->ptr=buf)+length; lex->yylineno = 1; @@ -117,7 +118,6 @@ LEX *lex_start(THD *thd, uchar *buf,uint length) lex->select_lex.ftfunc_list_alloc.empty(); lex->select_lex.ftfunc_list= &lex->select_lex.ftfunc_list_alloc; lex->current_select= &lex->select_lex; - lex->convert_set= (lex->thd= thd)->variables.convert_set; lex->thd_charset= lex->thd->variables.thd_charset; lex->yacc_yyss=lex->yacc_yyvs=0; lex->ignore_space=test(thd->variables.sql_mode & MODE_IGNORE_SPACE); @@ -520,8 +520,6 @@ int yylex(void *arg, void *yythd) yySkip(); // next state does a unget } yylval->lex_str=get_token(lex,length); - if (lex->convert_set) - lex->convert_set->convert((char*) yylval->lex_str.str,lex->yytoklen); /* Note: "SELECT _bla AS 'alias'" @@ -621,8 +619,6 @@ int yylex(void *arg, void *yythd) case MY_LEX_FOUND_IDENT: // Complete ident yylval->lex_str=get_token(lex,yyLength()); - if (lex->convert_set) - lex->convert_set->convert((char*) yylval->lex_str.str,lex->yytoklen); return(IDENT); case MY_LEX_USER_VARIABLE_DELIMITER: @@ -670,8 +666,6 @@ int yylex(void *arg, void *yythd) else yylval->lex_str=get_token(lex,yyLength()); } - if (lex->convert_set) - lex->convert_set->convert((char*) yylval->lex_str.str,lex->yytoklen); if (c == delim) yySkip(); // Skip end ` return(IDENT); @@ -802,8 +796,6 @@ int yylex(void *arg, void *yythd) break; } yylval->lex_str.length=lex->yytoklen; - if (lex->convert_set) - lex->convert_set->convert((char*) yylval->lex_str.str,lex->yytoklen); return(TEXT_STRING); case MY_LEX_COMMENT: // Comment @@ -940,8 +932,6 @@ int yylex(void *arg, void *yythd) return(tokval); // Was keyword } yylval->lex_str=get_token(lex,length); - if (lex->convert_set) - lex->convert_set->convert((char*) yylval->lex_str.str,lex->yytoklen); return(IDENT); } } diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 7c45e9e5619..d8045dcc556 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -448,7 +448,6 @@ typedef struct st_lex TYPELIB *interval; create_field *last_field; Item *default_value, *comment; - CONVERT *convert_set; CHARSET_INFO *thd_charset; LEX_USER *grant_user; gptr yacc_yyss,yacc_yyvs; diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 98bbd8bbb98..7e9b6aea7b5 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -384,7 +384,7 @@ impossible position"; We need to start a packet with something other than 255 to distiquish it from error */ - packet->set("\0", 1, system_charset_info); + packet->set("\0", 1, &my_charset_bin); // if we are at the start of the log if (pos == BIN_LOG_HEADER_SIZE) @@ -395,7 +395,7 @@ impossible position"; my_errno= ER_MASTER_FATAL_ERROR_READING_BINLOG; goto err; } - packet->set("\0", 1, system_charset_info); + packet->set("\0", 1, &my_charset_bin); } while (!net->error && net->vio != 0 && !thd->killed) @@ -430,7 +430,7 @@ impossible position"; goto err; } } - packet->set("\0", 1, system_charset_info); + packet->set("\0", 1, &my_charset_bin); } /* TODO: now that we are logging the offset, check to make sure @@ -550,7 +550,7 @@ Increase max_allowed_packet on master"; goto err; } } - packet->set("\0", 1, system_charset_info); + packet->set("\0", 1, &my_charset_bin); /* No need to net_flush because we will get to flush later when we hit EOF pretty quick @@ -1109,7 +1109,7 @@ int show_binlog_info(THD* thd) LOG_INFO li; mysql_bin_log.get_current_log(&li); int dir_len = dirname_length(li.log_file_name); - protocol->store(li.log_file_name + dir_len, system_charset_info); + protocol->store(li.log_file_name + dir_len, &my_charset_bin); protocol->store((ulonglong) li.pos); protocol->store(&binlog_do_db); protocol->store(&binlog_ignore_db); @@ -1166,7 +1166,7 @@ int show_binlogs(THD* thd) protocol->prepare_for_resend(); int dir_len = dirname_length(fname); /* The -1 is for removing newline from fname */ - protocol->store(fname + dir_len, length-1-dir_len, system_charset_info); + protocol->store(fname + dir_len, length-1-dir_len, &my_charset_bin); if (protocol->write()) goto err; } diff --git a/sql/sql_show.cc b/sql/sql_show.cc index ba7d7024eaf..122a0171777 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -923,7 +923,7 @@ mysqld_show_keys(THD *thd, TABLE_LIST *table_list) protocol->store((const char*) pos, system_charset_info); protocol->store(table->file->index_type(i), system_charset_info); /* Comment */ - protocol->store("", 0); + protocol->store("", system_charset_info); if (protocol->write()) DBUG_RETURN(1); /* purecov: inspected */ } @@ -979,8 +979,8 @@ mysqld_dump_create_info(THD *thd, TABLE *table, int fd) if (store_create_info(thd, table, packet)) DBUG_RETURN(-1); - if (protocol->convert) - protocol->convert->convert((char*) packet->ptr(), packet->length()); + //if (protocol->convert) + // protocol->convert->convert((char*) packet->ptr(), packet->length()); if (fd < 0) { if (protocol->write()) @@ -1014,12 +1014,12 @@ append_identifier(THD *thd, String *packet, const char *name) if (thd->options & OPTION_QUOTE_SHOW_CREATE) { packet->append(&qtype, 1); - packet->append(name); + packet->append(name, 0, system_charset_info); packet->append(&qtype, 1); } else { - packet->append(name); + packet->append(name, 0, system_charset_info); } } diff --git a/sql/sql_string.cc b/sql/sql_string.cc index d796c53fb52..54a76319be7 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -28,7 +28,7 @@ #include <floatingpoint.h> #endif -CHARSET_INFO *system_charset_info= &my_charset_latin1; +CHARSET_INFO *system_charset_info= &my_charset_utf8; extern gptr sql_alloc(unsigned size); extern void sql_element_free(void *ptr); static uint32 @@ -338,6 +338,34 @@ bool String::append(const char *s,uint32 arg_length) } +/* + Append a string in the given charset to the string + with character set recoding +*/ + + +bool String::append(const char *s,uint32 arg_length, CHARSET_INFO *cs) +{ + if (!arg_length) // Default argument + if (!(arg_length= (uint32) strlen(s))) + return FALSE; + if (str_charset->mbmaxlen > 1) + { + uint32 add_length=arg_length * str_charset->mbmaxlen; + if (realloc(str_length+ add_length)) + return TRUE; + str_length+= copy_and_convert(Ptr+str_length, add_length, str_charset, + s, arg_length, cs); + return FALSE; + } + if (realloc(str_length+arg_length)) + return TRUE; + memcpy(Ptr+str_length,s,arg_length); + str_length+=arg_length; + return FALSE; +} + + #ifdef TO_BE_REMOVED bool String::append(FILE* file, uint32 arg_length, myf my_flags) { diff --git a/sql/sql_string.h b/sql/sql_string.h index 8e0705844ad..469574ca2e4 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -181,6 +181,7 @@ public: CHARSET_INFO *csto); bool append(const String &s); bool append(const char *s,uint32 arg_length=0); + bool append(const char *s,uint32 arg_length, CHARSET_INFO *cs); bool append(IO_CACHE* file, uint32 arg_length); int strstr(const String &search,uint32 offset=0); // Returns offset to substring or -1 int strstr_case(const String &s,uint32 offset=0); diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index e66e896c590..220c0b04d5e 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -459,6 +459,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize); %token FROM_UNIXTIME %token GEOMCOLLFROMTEXT %token GEOMFROMTEXT +%token GEOMFROMWKB %token GEOMETRYCOLLECTION %token GROUP_UNIQUE_USERS %token HOUR_MINUTE_SYM @@ -559,7 +560,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize); %type <lex_str> IDENT TEXT_STRING REAL_NUM FLOAT_NUM NUM LONG_NUM HEX_NUM LEX_HOSTNAME ULONGLONG_NUM field_ident select_alias ident ident_or_text - UNDERSCORE_CHARSET + UNDERSCORE_CHARSET IDENT_sys TEXT_STRING_sys TEXT_STRING_db %type <lex_str_ptr> opt_table_alias @@ -773,22 +774,22 @@ master_defs: | master_defs ',' master_def; master_def: - MASTER_HOST_SYM EQ TEXT_STRING + MASTER_HOST_SYM EQ TEXT_STRING_sys { Lex->mi.host = $3.str; } | - MASTER_USER_SYM EQ TEXT_STRING + MASTER_USER_SYM EQ TEXT_STRING_sys { Lex->mi.user = $3.str; } | - MASTER_PASSWORD_SYM EQ TEXT_STRING + MASTER_PASSWORD_SYM EQ TEXT_STRING_sys { Lex->mi.password = $3.str; } | - MASTER_LOG_FILE_SYM EQ TEXT_STRING + MASTER_LOG_FILE_SYM EQ TEXT_STRING_sys { Lex->mi.log_file_name = $3.str; } @@ -808,7 +809,7 @@ master_def: Lex->mi.connect_retry = $3; } | - RELAY_LOG_FILE_SYM EQ TEXT_STRING + RELAY_LOG_FILE_SYM EQ TEXT_STRING_sys { Lex->mi.relay_log_name = $3.str; } @@ -878,14 +879,14 @@ create: lex->name=$4.str; lex->create_info.options=$3; } - | CREATE udf_func_type UDF_SYM IDENT + | CREATE udf_func_type UDF_SYM IDENT_sys { LEX *lex=Lex; lex->sql_command = SQLCOM_CREATE_FUNCTION; lex->udf.name = $4; lex->udf.type= $2; } - UDF_RETURNS_SYM udf_type UDF_SONAME_SYM TEXT_STRING + UDF_RETURNS_SYM udf_type UDF_SONAME_SYM TEXT_STRING_sys { LEX *lex=Lex; lex->udf.returns=(Item_result) $7; @@ -967,8 +968,8 @@ create_table_option: | MAX_ROWS opt_equal ulonglong_num { Lex->create_info.max_rows= $3; Lex->create_info.used_fields|= HA_CREATE_USED_MAX_ROWS;} | MIN_ROWS opt_equal ulonglong_num { Lex->create_info.min_rows= $3; Lex->create_info.used_fields|= HA_CREATE_USED_MIN_ROWS;} | AVG_ROW_LENGTH opt_equal ULONG_NUM { Lex->create_info.avg_row_length=$3; Lex->create_info.used_fields|= HA_CREATE_USED_AVG_ROW_LENGTH;} - | PASSWORD opt_equal TEXT_STRING { Lex->create_info.password=$3.str; } - | COMMENT_SYM opt_equal TEXT_STRING { Lex->create_info.comment=$3.str; } + | PASSWORD opt_equal TEXT_STRING_sys { Lex->create_info.password=$3.str; } + | COMMENT_SYM opt_equal TEXT_STRING_sys { Lex->create_info.comment=$3.str; } | AUTO_INC opt_equal ulonglong_num { Lex->create_info.auto_increment_value=$3; Lex->create_info.used_fields|= HA_CREATE_USED_AUTO;} | PACK_KEYS_SYM opt_equal ULONG_NUM { Lex->create_info.table_options|= $3 ? HA_OPTION_PACK_KEYS : HA_OPTION_NO_PACK_KEYS; Lex->create_info.used_fields|= HA_CREATE_USED_PACK_KEYS;} | PACK_KEYS_SYM opt_equal DEFAULT { Lex->create_info.table_options&= ~(HA_OPTION_PACK_KEYS | HA_OPTION_NO_PACK_KEYS); Lex->create_info.used_fields|= HA_CREATE_USED_PACK_KEYS;} @@ -1002,8 +1003,9 @@ create_table_option: Lex->create_info.used_fields|= HA_CREATE_USED_CHARSET; } | INSERT_METHOD opt_equal merge_insert_types { Lex->create_info.merge_insert_method= $3; Lex->create_info.used_fields|= HA_CREATE_USED_INSERT_METHOD;} - | DATA_SYM DIRECTORY_SYM opt_equal TEXT_STRING { Lex->create_info.data_file_name= $4.str; } - | INDEX DIRECTORY_SYM opt_equal TEXT_STRING { Lex->create_info.index_file_name= $4.str; }; + | DATA_SYM DIRECTORY_SYM opt_equal TEXT_STRING_sys + { Lex->create_info.data_file_name= $4.str; } + | INDEX DIRECTORY_SYM opt_equal TEXT_STRING_sys { Lex->create_info.index_file_name= $4.str; }; table_types: ISAM_SYM { $$= DB_TYPE_ISAM; } @@ -1312,7 +1314,9 @@ charset_name: net_printf(YYTHD,ER_UNKNOWN_CHARACTER_SET,$1.str); YYABORT; } - }; + } + | BINARY { $$= &my_charset_bin; } + ; charset_name_or_default: charset_name { $$=$1; } @@ -1639,7 +1643,7 @@ restore: { Lex->sql_command = SQLCOM_RESTORE_TABLE; } - table_list FROM TEXT_STRING + table_list FROM TEXT_STRING_sys { Lex->backup_dir = $6.str; }; @@ -1649,7 +1653,7 @@ backup: { Lex->sql_command = SQLCOM_BACKUP_TABLE; } - table_list TO_SYM TEXT_STRING + table_list TO_SYM TEXT_STRING_sys { Lex->backup_dir = $6.str; }; @@ -1899,9 +1903,9 @@ select_item: if (add_item_to_list(YYTHD, $2)) YYABORT; if ($4.str) - $2->set_name($4.str); + $2->set_name($4.str,$4.length,system_charset_info); else if (!$2->name) - $2->set_name($1,(uint) ($3 - $1)); + $2->set_name($1,(uint) ($3 - $1), YYTHD->charset()); }; remember_name: @@ -1915,11 +1919,12 @@ select_item2: | expr { $$=$1; }; select_alias: - { $$.str=0;} - | AS ident { $$=$2; } - | AS TEXT_STRING { $$=$2; } - | ident { $$=$1; } - | TEXT_STRING { $$=$1; }; + /* empty */ { $$.str=0;} + | AS ident { $$=$2; } + | AS TEXT_STRING_sys { $$=$2; } + | ident { $$=$1; } + | TEXT_STRING_sys { $$=$1; } + ; optional_braces: /* empty */ {} @@ -2221,9 +2226,9 @@ simple_expr: Lex->uncacheable();; } | ENCRYPT '(' expr ',' expr ')' { $$= new Item_func_encrypt($3,$5); } - | DECODE_SYM '(' expr ',' TEXT_STRING ')' + | DECODE_SYM '(' expr ',' TEXT_STRING_db ')' { $$= new Item_func_decode($3,$5.str); } - | ENCODE_SYM '(' expr ',' TEXT_STRING ')' + | ENCODE_SYM '(' expr ',' TEXT_STRING_db ')' { $$= new Item_func_encode($3,$5.str); } | DES_DECRYPT_SYM '(' expr ')' { $$= new Item_func_des_decrypt($3); } @@ -2254,7 +2259,11 @@ simple_expr: | GEOMFROMTEXT '(' expr ')' { $$= new Item_func_geometry_from_text($3); } | GEOMFROMTEXT '(' expr ',' expr ')' - { $$= new Item_func_geometry_from_text($3); } + { $$= new Item_func_geometry_from_text($3, $5); } + | GEOMFROMWKB '(' expr ')' + { $$= new Item_func_geometry_from_wkb($3); } + | GEOMFROMWKB '(' expr ',' expr ')' + { $$= new Item_func_geometry_from_wkb($3, $5); } | GEOMETRYCOLLECTION '(' expr_list ')' { $$= new Item_func_spatial_collection(* $3, Geometry::wkbGeometryCollection, @@ -2300,7 +2309,7 @@ simple_expr: | GEOMCOLLFROMTEXT '(' expr ')' { $$= new Item_func_geometry_from_text($3); } | GEOMCOLLFROMTEXT '(' expr ',' expr ')' - { $$= new Item_func_geometry_from_text($3); } + { $$= new Item_func_geometry_from_text($3, $5); } | GREATEST_SYM '(' expr ',' expr_list ')' { $5->push_front($3); $$= new Item_func_max(*$5); } | LEAST_SYM '(' expr ',' expr_list ')' @@ -2312,7 +2321,7 @@ simple_expr: | LINEFROMTEXT '(' expr ')' { $$= new Item_func_geometry_from_text($3); } | LINEFROMTEXT '(' expr ',' expr ')' - { $$= new Item_func_geometry_from_text($3); } + { $$= new Item_func_geometry_from_text($3, $5); } | MASTER_POS_WAIT '(' expr ',' expr ')' { $$= new Item_master_pos_wait($3, $5); @@ -2335,15 +2344,15 @@ simple_expr: | MLINEFROMTEXT '(' expr ')' { $$= new Item_func_geometry_from_text($3); } | MLINEFROMTEXT '(' expr ',' expr ')' - { $$= new Item_func_geometry_from_text($3); } + { $$= new Item_func_geometry_from_text($3, $5); } | MPOINTFROMTEXT '(' expr ')' { $$= new Item_func_geometry_from_text($3); } | MPOINTFROMTEXT '(' expr ',' expr ')' - { $$= new Item_func_geometry_from_text($3); } + { $$= new Item_func_geometry_from_text($3, $5); } | MPOLYFROMTEXT '(' expr ')' { $$= new Item_func_geometry_from_text($3); } | MPOLYFROMTEXT '(' expr ',' expr ')' - { $$= new Item_func_geometry_from_text($3); } + { $$= new Item_func_geometry_from_text($3, $5); } | MULTIPOINT '(' expr_list ')' { $$= new Item_func_spatial_collection(* $3, Geometry::wkbMultiPoint, Geometry::wkbPoint); } @@ -2363,11 +2372,11 @@ simple_expr: | POINTFROMTEXT '(' expr ')' { $$= new Item_func_geometry_from_text($3); } | POINTFROMTEXT '(' expr ',' expr ')' - { $$= new Item_func_geometry_from_text($3); } + { $$= new Item_func_geometry_from_text($3, $5); } | POLYFROMTEXT '(' expr ')' { $$= new Item_func_geometry_from_text($3); } | POLYFROMTEXT '(' expr ',' expr ')' - { $$= new Item_func_geometry_from_text($3); } + { $$= new Item_func_geometry_from_text($3, $5); } | POLYGON '(' expr_list ')' { $$= new Item_func_spatial_collection(* $3, Geometry::wkbPolygon, Geometry::wkbLineString); } @@ -2820,8 +2829,8 @@ having_clause: ; opt_escape: - ESCAPE_SYM TEXT_STRING { $$= $2.str; } - | /* empty */ { $$= (char*) "\\"; }; + ESCAPE_SYM TEXT_STRING_db { $$= $2.str; } + | /* empty */ { $$= (char*) "\\"; }; /* @@ -3017,7 +3026,7 @@ procedure_item: if (add_proc_to_list(lex->thd, $2)) YYABORT; if (!$2->name) - $2->set_name($1,(uint) ((char*) lex->tok_end - $1)); + $2->set_name($1,(uint) ((char*) lex->tok_end - $1), YYTHD->charset()); } ; @@ -3046,7 +3055,7 @@ select_var_ident: '@' ident_or_text ; into: - INTO OUTFILE TEXT_STRING + INTO OUTFILE TEXT_STRING_sys { LEX *lex=Lex; if (!lex->describe) @@ -3058,7 +3067,7 @@ into: } } opt_field_term opt_line_term - | INTO DUMPFILE TEXT_STRING + | INTO DUMPFILE TEXT_STRING_sys { LEX *lex=Lex; if (!lex->describe) @@ -3120,7 +3129,7 @@ drop: lex->drop_if_exists=$3; lex->name=$4.str; } - | DROP UDF_SYM IDENT + | DROP UDF_SYM IDENT_sys { LEX *lex=Lex; lex->sql_command = SQLCOM_DROP_FUNCTION; @@ -3481,7 +3490,7 @@ show_param: YYABORT; } | NEW_SYM MASTER_SYM FOR_SYM SLAVE WITH MASTER_LOG_FILE_SYM EQ - TEXT_STRING AND MASTER_LOG_POS_SYM EQ ulonglong_num + TEXT_STRING_sys AND MASTER_LOG_POS_SYM EQ ulonglong_num AND MASTER_SERVER_ID_SYM EQ ULONG_NUM { @@ -3596,7 +3605,7 @@ from_or_in: binlog_in: /* empty */ { Lex->mi.log_file_name = 0; } - | IN_SYM TEXT_STRING { Lex->mi.log_file_name = $2.str; }; + | IN_SYM TEXT_STRING_sys { Lex->mi.log_file_name = $2.str; }; binlog_from: /* empty */ { Lex->mi.pos = 4; /* skip magic number */ } @@ -3699,7 +3708,7 @@ purge_options: ; purge_option: - TO_SYM TEXT_STRING + TO_SYM TEXT_STRING_sys { Lex->sql_command = SQLCOM_PURGE; Lex->to_log = $2.str; @@ -3743,7 +3752,7 @@ use: USE_SYM ident /* import, export of files */ -load: LOAD DATA_SYM load_data_lock opt_local INFILE TEXT_STRING +load: LOAD DATA_SYM load_data_lock opt_local INFILE TEXT_STRING_sys { LEX *lex=Lex; lex->sql_command= SQLCOM_LOAD; @@ -3827,17 +3836,21 @@ opt_ignore_lines: /* Common definitions */ text_literal: - TEXT_STRING - { $$ = new Item_string($1.str,$1.length, - YYTHD->variables.thd_charset); } + TEXT_STRING_db + { + THD *thd= YYTHD; + CHARSET_INFO *cs= my_charset_same(thd->charset(),thd->db_charset) ? + thd->charset() : thd->db_charset; + $$ = new Item_string($1.str,$1.length,cs); + } | UNDERSCORE_CHARSET TEXT_STRING { $$ = new Item_string($2.str,$2.length,Lex->charset,Item::COER_IMPLICIT); } - | text_literal TEXT_STRING + | text_literal TEXT_STRING_db { ((Item_string*) $1)->append($2.str,$2.length); }; text_string: - TEXT_STRING - { $$= new String($1.str,$1.length,YYTHD->variables.thd_charset); } + TEXT_STRING_db + { $$= new String($1.str,$1.length,YYTHD->db_charset); } | HEX_NUM { Item *tmp = new Item_varbinary($1.str,$1.length); @@ -3960,8 +3973,63 @@ table_ident: | '.' ident { $$=new Table_ident($2);} /* For Delphi */; +IDENT_sys: + IDENT + { + THD *thd= YYTHD; + if (my_charset_same(thd->charset(),system_charset_info)) + { + $$=$1; + } + else + { + String ident; + ident.copy($1.str,$1.length,thd->charset(),system_charset_info); + $$.str= thd->strmake(ident.ptr(),ident.length()); + $$.length= ident.length(); + } + } + ; + +TEXT_STRING_sys: + TEXT_STRING + { + THD *thd= YYTHD; + if (my_charset_same(thd->charset(),system_charset_info)) + { + $$=$1; + } + else + { + String ident; + ident.copy($1.str,$1.length,thd->charset(),system_charset_info); + $$.str= thd->strmake(ident.ptr(),ident.length()); + $$.length= ident.length(); + } + } + ; + +TEXT_STRING_db: + TEXT_STRING + { + THD *thd= YYTHD; + if (my_charset_same(thd->charset(),thd->db_charset)) + { + $$=$1; + } + else + { + String ident; + ident.copy($1.str,$1.length,thd->charset(),thd->db_charset); + $$.str= thd->strmake(ident.ptr(),ident.length()); + $$.length= ident.length(); + } + } + ; + + ident: - IDENT { $$=$1; } + IDENT_sys { $$=$1; } | keyword { LEX *lex= Lex; @@ -3973,9 +4041,9 @@ ident: ; ident_or_text: - ident { $$=$1;} - | TEXT_STRING { $$=$1;} - | LEX_HOSTNAME { $$=$1;}; + ident { $$=$1;} + | TEXT_STRING_sys { $$=$1;} + | LEX_HOSTNAME { $$=$1;}; user: ident_or_text @@ -4242,9 +4310,15 @@ option_value: } | charset opt_equal set_expr_or_default { - LEX *lex=Lex; + THD *thd= YYTHD; + LEX *lex= &thd->lex; + if (!$3) + { + CHARSET_INFO *cl= thd->db_charset; + $3= new Item_string(cl->name, strlen(cl->name), &my_charset_latin1); + } lex->var_list.push_back(new set_var(lex->option_type, - find_sys_var("convert_character_set"), + find_sys_var("client_collation"), $3)); } | NAMES_SYM charset_name_or_default opt_collate diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c index 2db00e64c72..897e2846659 100644 --- a/strings/ctype-utf8.c +++ b/strings/ctype-utf8.c @@ -27,6 +27,10 @@ #define EILSEQ ENOENT #endif +#ifndef HAVE_CHARSET_utf8 +#define HAVE_CHARSET_utf8 +#endif + #ifdef HAVE_CHARSET_utf8 #define HAVE_UNIDATA #endif |