branches/zip: Merge 2367:2384 from branches/5.1.

This commit is contained in:
marko 2008-03-26 17:14:00 +00:00
parent ab7b62e7ae
commit d66321b9cb
10 changed files with 149 additions and 13 deletions

View file

@ -3592,7 +3592,7 @@ loop:
ptr = dict_accept(cs, ptr, "FOREIGN", &success);
if (!success) {
if (!success || !my_isspace(cs, *ptr)) {
goto loop;
}

View file

@ -246,6 +246,7 @@ trx_undo_set_state_at_finish(
/*=========================*/
/* out: undo log segment header page,
x-latched */
trx_rseg_t* rseg, /* in: rollback segment memory object */
trx_t* trx, /* in: transaction */
trx_undo_t* undo, /* in: undo log memory copy */
mtr_t* mtr); /* in: mtr */

View file

@ -0,0 +1,4 @@
f4 f8
xxx zzz
f4 f8
xxx zzz

View file

@ -0,0 +1,30 @@
#
# Bug#34300 Tinyblob & tinytext fields currupted after export/import and alter in 5.1
# http://bugs.mysql.com/34300
#
-- source include/have_innodb.inc
-- disable_query_log
-- disable_result_log
SET @@max_allowed_packet=16777216;
DROP TABLE IF EXISTS bug34300;
CREATE TABLE bug34300 (
f4 TINYTEXT,
f6 MEDIUMTEXT,
f8 TINYBLOB
) ENGINE=InnoDB;
INSERT INTO bug34300 VALUES ('xxx', repeat('a', 8459264), 'zzz');
-- enable_result_log
SELECT f4, f8 FROM bug34300;
ALTER TABLE bug34300 ADD COLUMN (f10 INT);
SELECT f4, f8 FROM bug34300;
DROP TABLE bug34300;

View file

@ -0,0 +1 @@
SET storage_engine=InnoDB;

View file

@ -0,0 +1,16 @@
#
# Bug#35220 ALTER TABLE too picky on reserved word "foreign"
# http://bugs.mysql.com/35220
#
-- source include/have_innodb.inc
SET storage_engine=InnoDB;
# we care only that the following SQL commands do not produce errors
-- disable_query_log
-- disable_result_log
CREATE TABLE bug35220 (foreign_col INT, dummy_cant_delete_all_columns INT);
ALTER TABLE bug35220 DROP foreign_col;
DROP TABLE bug35220;

View file

@ -1797,6 +1797,55 @@ os_file_set_eof(
#endif /* __WIN__ */
}
#ifndef __WIN__
/***************************************************************************
Wrapper to fsync(2) that retries the call on some errors.
Returns the value 0 if successful; otherwise the value -1 is returned and
the global variable errno is set to indicate the error. */
static
int
os_file_fsync(
/*==========*/
/* out: 0 if success, -1 otherwise */
os_file_t file) /* in: handle to a file */
{
int ret;
int failures;
ibool retry;
failures = 0;
do {
ret = fsync(file);
os_n_fsyncs++;
if (ret == -1 && errno == ENOLCK) {
if (failures % 100 == 0) {
ut_print_timestamp(stderr);
fprintf(stderr,
" InnoDB: fsync(): "
"No locks available; retrying\n");
}
os_thread_sleep(200000 /* 0.2 sec */);
failures++;
retry = TRUE;
} else {
retry = FALSE;
}
} while (retry);
return(ret);
}
#endif /* !__WIN__ */
/***************************************************************************
Flushes the write buffers of a given file to the disk. */
UNIV_INTERN
@ -1854,21 +1903,19 @@ os_file_flush(
/* If we are not on an operating system that supports this,
then fall back to a plain fsync. */
ret = fsync(file);
ret = os_file_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);
ret = os_file_fsync(file);
}
}
#else
/* fprintf(stderr, "Flushing to file %p\n", file); */
ret = fsync(file);
ret = os_file_fsync(file);
#endif
os_n_fsyncs++;
if (ret == 0) {
return(TRUE);

View file

@ -2759,6 +2759,25 @@ row_sel_store_mysql_rec(
data = rec_get_nth_field(rec, offsets,
templ->rec_field_no, &len);
if (UNIV_UNLIKELY(templ->type == DATA_BLOB)
&& len != UNIV_SQL_NULL) {
/* It is a BLOB field locally stored in the
InnoDB record: we MUST copy its contents to
prebuilt->blob_heap here because later code
assumes all BLOB values have been copied to a
safe place. */
if (prebuilt->blob_heap == NULL) {
prebuilt->blob_heap = mem_heap_create(
UNIV_PAGE_SIZE);
}
data = memcpy(mem_heap_alloc(
prebuilt->blob_heap, len),
data, len);
}
}
if (len != UNIV_SQL_NULL) {

View file

@ -716,8 +716,8 @@ trx_commit_off_kernel(
mutex_enter(&(rseg->mutex));
if (trx->insert_undo != NULL) {
trx_undo_set_state_at_finish(trx, trx->insert_undo,
&mtr);
trx_undo_set_state_at_finish(
rseg, trx, trx->insert_undo, &mtr);
}
undo = trx->update_undo;
@ -733,7 +733,7 @@ trx_commit_off_kernel(
transaction commit for this transaction. */
update_hdr_page = trx_undo_set_state_at_finish(
trx, undo, &mtr);
rseg, trx, undo, &mtr);
/* We have to do the cleanup for the update log while
holding the rseg mutex because update log headers

View file

@ -1771,6 +1771,7 @@ trx_undo_set_state_at_finish(
/*=========================*/
/* out: undo log segment header page,
x-latched */
trx_rseg_t* rseg, /* in: rollback segment memory object */
trx_t* trx __attribute__((unused)), /* in: transaction */
trx_undo_t* undo, /* in: undo log memory copy */
mtr_t* mtr) /* in: mtr */
@ -1780,7 +1781,10 @@ trx_undo_set_state_at_finish(
page_t* undo_page;
ulint state;
ut_ad(trx && undo && mtr);
ut_ad(trx);
ut_ad(undo);
ut_ad(mtr);
ut_ad(mutex_own(&rseg->mutex));
if (undo->id >= TRX_RSEG_N_SLOTS) {
fprintf(stderr, "InnoDB: Error: undo->id is %lu\n",
@ -1795,9 +1799,23 @@ trx_undo_set_state_at_finish(
seg_hdr = undo_page + TRX_UNDO_SEG_HDR;
page_hdr = undo_page + TRX_UNDO_PAGE_HDR;
if (undo->size == 1 && mach_read_from_2(page_hdr + TRX_UNDO_PAGE_FREE)
< TRX_UNDO_PAGE_REUSE_LIMIT) {
state = TRX_UNDO_CACHED;
if (undo->size == 1
&& mach_read_from_2(page_hdr + TRX_UNDO_PAGE_FREE)
< TRX_UNDO_PAGE_REUSE_LIMIT) {
/* This is a heuristic to avoid the problem of all UNDO
slots ending up in one of the UNDO lists. Previously if
the server crashed with all the slots in one of the lists,
transactions that required the slots of a different type
would fail for lack of slots. */
if (UT_LIST_GET_LEN(rseg->update_undo_list) < 500
&& UT_LIST_GET_LEN(rseg->insert_undo_list) < 500) {
state = TRX_UNDO_CACHED;
} else {
state = TRX_UNDO_TO_FREE;
}
} else if (undo->type == TRX_UNDO_INSERT) {