diff options
author | unknown <monty@mysql.com> | 2005-01-15 14:09:45 +0200 |
---|---|---|
committer | unknown <monty@mysql.com> | 2005-01-15 14:09:45 +0200 |
commit | 0cbd58c52b3810da467ec04e5d578ce3c845f125 (patch) | |
tree | e8856cd37d5a43bd18c06a8834fbfff83c0f4998 /innobase | |
parent | 5168d25f3509cd205b3db8222446b16d34c45781 (diff) | |
parent | 193eae3bece02daa473f0e264d235ea3e407a88d (diff) | |
download | mariadb-git-0cbd58c52b3810da467ec04e5d578ce3c845f125.tar.gz |
Merge with 4.1
BitKeeper/etc/ignore:
auto-union
Build-tools/Do-compile:
Auto merged
client/mysqladmin.cc:
Auto merged
heap/hp_create.c:
Auto merged
heap/hp_write.c:
Auto merged
include/my_sys.h:
Auto merged
innobase/data/data0type.c:
Auto merged
innobase/include/row0mysql.h:
Auto merged
innobase/os/os0file.c:
Auto merged
innobase/rem/rem0cmp.c:
Auto merged
innobase/row/row0sel.c:
Auto merged
innobase/srv/srv0start.c:
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/func_gconcat.result:
Auto merged
mysql-test/r/func_sapdb.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/r/type_timestamp.result:
Auto merged
mysql-test/t/ctype_ucs.test:
Auto merged
mysql-test/t/func_sapdb.test:
Auto merged
mysql-test/t/show_check.test:
Auto merged
mysql-test/t/type_float.test:
Auto merged
mysql-test/t/type_timestamp.test:
Auto merged
mysys/mf_iocache.c:
Auto merged
ndb/src/kernel/vm/Configuration.cpp:
Auto merged
scripts/mysql_install_db.sh:
Auto merged
sql/field.cc:
Auto merged
sql/ha_berkeley.cc:
Auto merged
sql/ha_innodb.cc:
Auto merged
sql/item_sum.h:
Auto merged
sql/sql_base.cc:
Auto merged
sql/sql_class.h:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/sql_prepare.cc:
Auto merged
sql/sql_table.cc:
Auto merged
sql/sql_yacc.yy:
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
configure.in:
Use local values
mysql-test/r/ps_1general.result:
Update results
mysql-test/t/func_gconcat.test:
no changes
mysql-test/t/ps_1general.test:
Use local code
ndb/src/common/util/version.c:
Use local code
sql/filesort.cc:
Empty line changes
sql/ha_heap.cc:
Merge
sql/item_timefunc.cc:
Keep local code
sql/mysql_priv.h:
Update to 5.0
sql/sql_show.cc:
Hand merge
support-files/mysql.spec.sh:
No changes
Diffstat (limited to 'innobase')
-rw-r--r-- | innobase/data/data0type.c | 11 | ||||
-rw-r--r-- | innobase/include/data0type.h | 7 | ||||
-rw-r--r-- | innobase/include/row0mysql.h | 2 | ||||
-rw-r--r-- | innobase/include/row0mysql.ic | 31 | ||||
-rw-r--r-- | innobase/include/srv0start.h | 4 | ||||
-rw-r--r-- | innobase/os/os0file.c | 48 | ||||
-rw-r--r-- | innobase/rem/rem0cmp.c | 16 | ||||
-rw-r--r-- | innobase/row/row0sel.c | 68 | ||||
-rw-r--r-- | innobase/srv/srv0start.c | 27 |
9 files changed, 172 insertions, 42 deletions
diff --git a/innobase/data/data0type.c b/innobase/data/data0type.c index 9b8fb084e33..00048bf6fbb 100644 --- a/innobase/data/data0type.c +++ b/innobase/data/data0type.c @@ -166,6 +166,17 @@ dtype_is_non_binary_string_type( } /************************************************************************* +Gets the MySQL charset-collation code for MySQL string types. */ + +ulint +dtype_get_charset_coll_noninline( +/*=============================*/ + ulint prtype) /* in: precise data type */ +{ + return(dtype_get_charset_coll(prtype)); +} + +/************************************************************************* Forms a precise type from the < 4.1.2 format precise type plus the charset-collation code. */ diff --git a/innobase/include/data0type.h b/innobase/include/data0type.h index c263d2bf613..02c874836fd 100644 --- a/innobase/include/data0type.h +++ b/innobase/include/data0type.h @@ -234,6 +234,13 @@ dtype_get_prtype( dtype_t* type); /************************************************************************* Gets the MySQL charset-collation code for MySQL string types. */ + +ulint +dtype_get_charset_coll_noninline( +/*=============================*/ + ulint prtype);/* in: precise data type */ +/************************************************************************* +Gets the MySQL charset-collation code for MySQL string types. */ UNIV_INLINE ulint dtype_get_charset_coll( diff --git a/innobase/include/row0mysql.h b/innobase/include/row0mysql.h index 575d8ee67bb..f0dc4630475 100644 --- a/innobase/include/row0mysql.h +++ b/innobase/include/row0mysql.h @@ -447,6 +447,8 @@ struct mysql_row_templ_struct { zero if column cannot be NULL */ ulint type; /* column type in Innobase mtype numbers DATA_CHAR... */ + ulint charset; /* MySQL charset-collation code + of the column, or zero */ ulint is_unsigned; /* if a column type is an integer type and this field is != 0, then it is an unsigned integer type */ diff --git a/innobase/include/row0mysql.ic b/innobase/include/row0mysql.ic index 4ecd66e06ec..fc922b52d0a 100644 --- a/innobase/include/row0mysql.ic +++ b/innobase/include/row0mysql.ic @@ -91,12 +91,33 @@ row_mysql_store_col_in_innobase_format( } } else if (type == DATA_VARCHAR || type == DATA_VARMYSQL || type == DATA_BINARY) { + /* Remove trailing spaces. */ + + /* Handle UCS2 strings differently. As no new + collations will be introduced in 4.1, we hardcode the + charset-collation codes here. In 5.0, the logic will + be based on mbminlen. */ + ulint cset = dtype_get_charset_coll( + dtype_get_prtype(dfield_get_type(dfield))); ptr = row_mysql_read_var_ref(&col_len, mysql_data); - - /* Remove trailing spaces */ - while (col_len > 0 && ptr[col_len - 1] == ' ') { - col_len--; - } + if (cset == 35/*ucs2_general_ci*/ + || cset == 90/*ucs2_bin*/ + || (cset >= 128/*ucs2_unicode_ci*/ + && cset <= 144/*ucs2_persian_ci*/)) { + /* space=0x0020 */ + /* Trim "half-chars", just in case. */ + col_len &= ~1; + + while (col_len >= 2 && ptr[col_len - 2] == 0x00 + && ptr[col_len - 1] == 0x20) { + col_len -= 2; + } + } else { + /* space=0x20 */ + while (col_len > 0 && ptr[col_len - 1] == 0x20) { + col_len--; + } + } } else if (type == DATA_BLOB) { ptr = row_mysql_read_blob_ref(&col_len, mysql_data, col_len); } diff --git a/innobase/include/srv0start.h b/innobase/include/srv0start.h index 75af1a212b4..8df0f97c4ff 100644 --- a/innobase/include/srv0start.h +++ b/innobase/include/srv0start.h @@ -75,6 +75,10 @@ extern dulint srv_start_lsn; void set_panic_flag_for_netware(void); #endif +#ifdef HAVE_DARWIN_THREADS +extern ibool srv_have_fullfsync; +#endif + extern ulint srv_sizeof_trx_t_in_ha_innodb_cc; extern ibool srv_is_being_started; diff --git a/innobase/os/os0file.c b/innobase/os/os0file.c index cb9801cbc9a..64d80350275 100644 --- a/innobase/os/os0file.c +++ b/innobase/os/os0file.c @@ -490,7 +490,7 @@ os_io_init_simple(void) } } -#ifndef UNIV_HOTBACKUP +#if !defined(UNIV_HOTBACKUP) && !defined(__NETWARE__) /************************************************************************* Creates a temporary file. This function is defined in ha_innodb.cc. */ @@ -498,7 +498,7 @@ int innobase_mysql_tmpfile(void); /*========================*/ /* out: temporary file descriptor, or < 0 on error */ -#endif /* !UNIV_HOTBACKUP */ +#endif /* !UNIV_HOTBACKUP && !__NETWARE__ */ /*************************************************************************** Creates a temporary file. */ @@ -508,9 +508,12 @@ os_file_create_tmpfile(void) /*========================*/ /* out: temporary file handle, or NULL on error */ { +#ifdef __NETWARE__ + FILE* file = tmpfile(); +#else /* __NETWARE__ */ FILE* file = NULL; int fd = -1; -#ifdef UNIV_HOTBACKUP +# ifdef UNIV_HOTBACKUP int tries; for (tries = 10; tries--; ) { char* name = tempnam(fil_path_to_mysql_datadir, "ib"); @@ -519,15 +522,15 @@ os_file_create_tmpfile(void) } fd = open(name, -# ifdef __WIN__ +# ifdef __WIN__ O_SEQUENTIAL | O_SHORT_LIVED | O_TEMPORARY | -# endif /* __WIN__ */ +# endif /* __WIN__ */ O_CREAT | O_EXCL | O_RDWR, S_IREAD | S_IWRITE); if (fd >= 0) { -# ifndef __WIN__ +# ifndef __WIN__ unlink(name); -# endif /* !__WIN__ */ +# endif /* !__WIN__ */ free(name); break; } @@ -538,22 +541,25 @@ os_file_create_tmpfile(void) name); free(name); } -#else /* UNIV_HOTBACKUP */ +# else /* UNIV_HOTBACKUP */ fd = innobase_mysql_tmpfile(); -#endif /* UNIV_HOTBACKUP */ +# endif /* UNIV_HOTBACKUP */ if (fd >= 0) { file = fdopen(fd, "w+b"); } +#endif /* __NETWARE__ */ if (!file) { ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: Error: unable to create temporary file;" " errno: %d\n", errno); +#ifndef __NETWARE__ if (fd >= 0) { close(fd); } +#endif /* !__NETWARE__ */ } return(file); @@ -1767,19 +1773,31 @@ os_file_flush( #else int ret; -#if defined(HAVE_DARWIN_THREADS) && defined(F_FULLFSYNC) +#if defined(HAVE_DARWIN_THREADS) +# ifndef F_FULLFSYNC + /* The following definition is from the Mac OS X 10.3 <sys/fcntl.h> */ +# define F_FULLFSYNC 51 /* fsync + ask the drive to flush to the media */ +# elif F_FULLFSYNC != 51 +# error "F_FULLFSYNC != 51: ABI incompatibility with Mac OS X 10.3" +# endif /* Apple has disabled fsync() for internal disk drives in OS X. That caused corruption for a user when he tested a power outage. Let us in OS X use a nonstandard flush method recommended by an Apple engineer. */ - ret = fcntl(file, F_FULLFSYNC, NULL); - - if (ret) { - /* If we are not on a file system that supports this, then - fall back to a plain fsync. */ + if (!srv_have_fullfsync) { + /* If we are not on an operating system that supports this, + then fall back to a plain fsync. */ ret = fsync(file); + } else { + ret = fcntl(file, F_FULLFSYNC, NULL); + + if (ret) { + /* If we are not on a file system that supports this, + then fall back to a plain fsync. */ + ret = fsync(file); + } } #elif HAVE_FDATASYNC ret = fdatasync(file); diff --git a/innobase/rem/rem0cmp.c b/innobase/rem/rem0cmp.c index 6473d356ba8..193bda75f24 100644 --- a/innobase/rem/rem0cmp.c +++ b/innobase/rem/rem0cmp.c @@ -262,22 +262,6 @@ cmp_whole_field( "InnoDB: comparison!\n"); } - /* MySQL does not pad the ends of strings with spaces in a - comparison. That would cause a foreign key check to fail for - non-latin1 character sets if we have different length columns. - To prevent that we remove trailing spaces here before doing - the comparison. NOTE that if we in the future map more MySQL - types to DATA_MYSQL or DATA_VARMYSQL, we have to change this - code. */ - - while (a_length > 0 && a[a_length - 1] == ' ') { - a_length--; - } - - while (b_length > 0 && b[b_length - 1] == ' ') { - b_length--; - } - return(innobase_mysql_cmp( (int)(type->prtype & DATA_MYSQL_TYPE_MASK), (uint)dtype_get_charset_coll(type->prtype), 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); + } } } diff --git a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c index 061bdb82d3e..983a8306773 100644 --- a/innobase/srv/srv0start.c +++ b/innobase/srv/srv0start.c @@ -61,6 +61,11 @@ dulint srv_start_lsn; /* Log sequence number at shutdown */ dulint srv_shutdown_lsn; +#ifdef HAVE_DARWIN_THREADS +# include <sys/utsname.h> +ibool srv_have_fullfsync = FALSE; +#endif + ibool srv_start_raw_disk_in_use = FALSE; static ibool srv_start_has_been_called = FALSE; @@ -935,6 +940,28 @@ innobase_start_or_create_for_mysql(void) ulint i; ibool srv_file_per_table_original_value = srv_file_per_table; mtr_t mtr; +#ifdef HAVE_DARWIN_THREADS +# ifdef F_FULLFSYNC + /* This executable has been compiled on Mac OS X 10.3 or later. + Assume that F_FULLFSYNC is available at run-time. */ + srv_have_fullfsync = TRUE; +# else /* F_FULLFSYNC */ + /* This executable has been compiled on Mac OS X 10.2 + or earlier. Determine if the executable is running + on Mac OS X 10.3 or later. */ + struct utsname utsname; + if (uname(&utsname)) { + fputs("InnoDB: cannot determine Mac OS X version!\n", stderr); + } else { + srv_have_fullfsync = strcmp(utsname.release, "7.") >= 0; + } + if (!srv_have_fullfsync) { + fputs( +"InnoDB: On Mac OS X, fsync() may be broken on internal drives,\n" +"InnoDB: making transactions unsafe!\n", stderr); + } +# endif /* F_FULLFSYNC */ +#endif /* HAVE_DARWIN_THREADS */ if (sizeof(ulint) != sizeof(void*)) { fprintf(stderr, |