summaryrefslogtreecommitdiff
path: root/innobase/row/row0sel.c
diff options
context:
space:
mode:
authorunknown <monty@mysql.com>2005-01-15 14:39:16 +0200
committerunknown <monty@mysql.com>2005-01-15 14:39:16 +0200
commit2f246d2ff62ff284f035208fa9de98f1508d94ec (patch)
tree3df595a961fc92c33db266c4483166ede3f4e127 /innobase/row/row0sel.c
parentcd1715a225931f9c531c0290271e593a1ec454f7 (diff)
parent0cbd58c52b3810da467ec04e5d578ce3c845f125 (diff)
downloadmariadb-git-2f246d2ff62ff284f035208fa9de98f1508d94ec.tar.gz
Merge with global tree
BitKeeper/etc/ignore: auto-union Build-tools/Do-compile: Auto merged configure.in: Auto merged innobase/include/row0mysql.h: Auto merged innobase/os/os0file.c: Auto merged mysql-test/mysql-test-run.sh: Auto merged mysql-test/r/ctype_latin1_de.result: Auto merged mysql-test/r/ctype_tis620.result: Auto merged mysql-test/r/ctype_ucs.result: Auto merged mysql-test/r/ctype_ujis.result: Auto merged mysql-test/r/ctype_utf8.result: Auto merged mysql-test/r/ps_1general.result: Auto merged mysql-test/r/show_check.result: Auto merged mysql-test/r/type_float.result.es: Auto merged mysql-test/r/type_float.result: Auto merged mysql-test/t/ctype_ucs.test: Auto merged mysql-test/t/ps_1general.test: Auto merged mysql-test/t/show_check.test: Auto merged ndb/src/kernel/vm/Configuration.cpp: Auto merged scripts/mysql_install_db.sh: Auto merged sql/field.cc: Auto merged sql/filesort.cc: Auto merged sql/ha_berkeley.cc: Auto merged sql/ha_innodb.cc: Auto merged strings/ctype-big5.c: Auto merged strings/ctype-bin.c: Auto merged strings/ctype-czech.c: Auto merged strings/ctype-gbk.c: Auto merged strings/ctype-latin1.c: Auto merged strings/ctype-mb.c: Auto merged strings/ctype-simple.c: Auto merged strings/ctype-sjis.c: Auto merged strings/ctype-tis620.c: Auto merged strings/ctype-uca.c: Auto merged strings/ctype-ucs2.c: Auto merged strings/ctype-utf8.c: Auto merged strings/ctype-win1250ch.c: Auto merged sql/sql_show.cc: No changes strings/ctype-cp932.c: No changes support-files/mysql.spec.sh: No changes
Diffstat (limited to 'innobase/row/row0sel.c')
-rw-r--r--innobase/row/row0sel.c68
1 files changed, 62 insertions, 6 deletions
diff --git a/innobase/row/row0sel.c b/innobase/row/row0sel.c
index f3a5f911171..8512e796a72 100644
--- a/innobase/row/row0sel.c
+++ b/innobase/row/row0sel.c
@@ -2271,9 +2271,6 @@ row_sel_field_store_in_mysql_format(
dest = row_mysql_store_var_len(dest, len);
ut_memcpy(dest, data, len);
- /* Pad with trailing spaces */
- memset(dest + len, ' ', col_len - len);
-
/* ut_ad(col_len >= len + 2); No real var implemented in
MySQL yet! */
@@ -2406,7 +2403,45 @@ row_sel_store_mysql_rec(
mysql_rec + templ->mysql_col_offset,
templ->mysql_col_len, data, len,
templ->type, templ->is_unsigned);
-
+
+ if (templ->type == DATA_VARCHAR
+ || templ->type == DATA_VARMYSQL
+ || templ->type == DATA_BINARY) {
+ /* Pad with trailing spaces */
+ data = mysql_rec + templ->mysql_col_offset;
+
+ /* Handle UCS2 strings differently. As no new
+ collations will be introduced in 4.1, we
+ hardcode the charset-collation codes here.
+ 5.0 will use a different approach. */
+ if (templ->charset == 35
+ || templ->charset == 90
+ || (templ->charset >= 128
+ && templ->charset <= 144)) {
+ /* space=0x0020 */
+ ulint col_len = templ->mysql_col_len;
+
+ ut_a(!(col_len & 1));
+ if (len & 1) {
+ /* A 0x20 has been stripped
+ from the column.
+ Pad it back. */
+ goto pad_0x20;
+ }
+ /* Pad the rest of the string
+ with 0x0020 */
+ while (len < col_len) {
+ data[len++] = 0x00;
+ pad_0x20:
+ data[len++] = 0x20;
+ }
+ } else {
+ /* space=0x20 */
+ memset(data + len, 0x20,
+ templ->mysql_col_len - len);
+ }
+ }
+
/* Cleanup */
if (extern_field_heap) {
mem_heap_free(extern_field_heap);
@@ -2442,8 +2477,29 @@ row_sel_store_mysql_rec(
pad_char = '\0';
}
- memset(mysql_rec + templ->mysql_col_offset, pad_char,
- templ->mysql_col_len);
+ /* Handle UCS2 strings differently. As no new
+ collations will be introduced in 4.1,
+ we hardcode the charset-collation codes here.
+ 5.0 will use a different approach. */
+ if (templ->charset == 35
+ || templ->charset == 90
+ || (templ->charset >= 128
+ && templ->charset <= 144)) {
+ /* There are two bytes per char, so the length
+ has to be an even number. */
+ ut_a(!(templ->mysql_col_len & 1));
+ data = mysql_rec + templ->mysql_col_offset;
+ len = templ->mysql_col_len;
+ /* Pad with 0x0020. */
+ while (len >= 2) {
+ *data++ = 0x00;
+ *data++ = 0x20;
+ len -= 2;
+ }
+ } else {
+ memset(mysql_rec + templ->mysql_col_offset,
+ pad_char, templ->mysql_col_len);
+ }
}
}