summaryrefslogtreecommitdiff
path: root/innobase
diff options
context:
space:
mode:
Diffstat (limited to 'innobase')
-rw-r--r--innobase/btr/btr0cur.c62
-rw-r--r--innobase/include/btr0cur.h2
-rw-r--r--innobase/include/os0thread.h9
-rw-r--r--innobase/lock/lock0lock.c33
-rw-r--r--innobase/os/os0file.c2
-rw-r--r--innobase/os/os0thread.c4
6 files changed, 100 insertions, 12 deletions
diff --git a/innobase/btr/btr0cur.c b/innobase/btr/btr0cur.c
index e35ff2ca69e..3d6b63def6c 100644
--- a/innobase/btr/btr0cur.c
+++ b/innobase/btr/btr0cur.c
@@ -2531,7 +2531,7 @@ btr_cur_add_path_info(
/***********************************************************************
Estimates the number of rows in a given index range. */
-ulint
+ib_longlong
btr_estimate_n_rows_in_range(
/*=========================*/
/* out: estimated number of rows */
@@ -2547,8 +2547,9 @@ btr_estimate_n_rows_in_range(
btr_path_t* slot1;
btr_path_t* slot2;
ibool diverged;
+ ibool diverged_lot;
ulint divergence_level;
- ulint n_rows;
+ ib_longlong n_rows;
ulint i;
mtr_t mtr;
@@ -2589,10 +2590,13 @@ btr_estimate_n_rows_in_range(
/* We have the path information for the range in path1 and path2 */
n_rows = 1;
- diverged = FALSE;
- divergence_level = 1000000;
-
- for (i = 0; ; i++) {
+ diverged = FALSE; /* This becomes true when the path is not
+ the same any more */
+ diverged_lot = FALSE; /* This becomes true when the paths are
+ not the same or adjacent any more */
+ divergence_level = 1000000; /* This is the level where paths diverged
+ a lot */
+ for (i = 0; ; i++) {
ut_ad(i < BTR_PATH_ARRAY_N_SLOTS);
slot1 = path1 + i;
@@ -2608,13 +2612,36 @@ btr_estimate_n_rows_in_range(
n_rows = n_rows * 2;
}
+
+ /* Do not estimate the number of rows in the range
+ to over 1 / 2 of the estimated rows in the whole
+ table */
+
+ if (n_rows > index->table->stat_n_rows / 2) {
+ n_rows = index->table->stat_n_rows / 2;
+
+ /* If there are just 0 or 1 rows in the table,
+ then we estimate all rows are in the range */
+
+ if (n_rows == 0) {
+ n_rows = index->table->stat_n_rows;
+ }
+ }
+
return(n_rows);
}
if (!diverged && slot1->nth_rec != slot2->nth_rec) {
+ diverged = TRUE;
+
if (slot1->nth_rec < slot2->nth_rec) {
n_rows = slot2->nth_rec - slot1->nth_rec;
+
+ if (n_rows > 1) {
+ diverged_lot = TRUE;
+ divergence_level = i;
+ }
} else {
/* Maybe the tree has changed between
searches */
@@ -2622,10 +2649,27 @@ btr_estimate_n_rows_in_range(
return(10);
}
- divergence_level = i;
+ } else if (diverged && !diverged_lot) {
+
+ if (slot1->nth_rec < slot1->n_recs
+ || slot2->nth_rec > 1) {
+
+ diverged_lot = TRUE;
+ divergence_level = i;
+
+ n_rows = 0;
+
+ if (slot1->nth_rec < slot1->n_recs) {
+ n_rows += slot1->n_recs
+ - slot1->nth_rec;
+ }
+
+ if (slot2->nth_rec > 1) {
+ n_rows += slot2->nth_rec - 1;
+ }
+ }
+ } else if (diverged_lot) {
- diverged = TRUE;
- } else if (diverged) {
n_rows = (n_rows * (slot1->n_recs + slot2->n_recs))
/ 2;
}
diff --git a/innobase/include/btr0cur.h b/innobase/include/btr0cur.h
index b01cbd9a875..7039ceba245 100644
--- a/innobase/include/btr0cur.h
+++ b/innobase/include/btr0cur.h
@@ -417,7 +417,7 @@ btr_cur_parse_del_mark_set_sec_rec(
/***********************************************************************
Estimates the number of rows in a given index range. */
-ulint
+ib_longlong
btr_estimate_n_rows_in_range(
/*=========================*/
/* out: estimated number of rows */
diff --git a/innobase/include/os0thread.h b/innobase/include/os0thread.h
index 9459750719f..8355afa46e9 100644
--- a/innobase/include/os0thread.h
+++ b/innobase/include/os0thread.h
@@ -15,7 +15,16 @@ Created 9/8/1995 Heikki Tuuri
/* Maximum number of threads which can be created in the program;
this is also the size of the wait slot array for MySQL threads which
can wait inside InnoDB */
+#ifdef __WIN__
+/* Windows 95/98/ME seemed to have difficulties creating the all
+the event semaphores for the wait array slots. If the computer had
+<= 64 MB memory, InnoDB startup could take minutes or even crash.
+That is why we set this to only 1000 in Windows. */
+
+#define OS_THREAD_MAX_N 1000
+#else
#define OS_THREAD_MAX_N 10000
+#endif
/* Possible fixed priorities for threads */
#define OS_THREAD_PRIORITY_NONE 100
diff --git a/innobase/lock/lock0lock.c b/innobase/lock/lock0lock.c
index ebd063b6ca5..866fe556af9 100644
--- a/innobase/lock/lock0lock.c
+++ b/innobase/lock/lock0lock.c
@@ -2011,6 +2011,19 @@ lock_grant(
ut_ad(mutex_own(&kernel_mutex));
lock_reset_lock_and_trx_wait(lock);
+
+ if (lock_get_mode(lock) == LOCK_AUTO_INC) {
+
+ if (lock->trx->auto_inc_lock != NULL) {
+ fprintf(stderr,
+ "InnoDB: Error: trx already had an AUTO-INC lock!\n");
+ }
+
+ /* Store pointer to lock to trx so that we know to
+ release it at the end of the SQL statement */
+
+ lock->trx->auto_inc_lock = lock;
+ }
if (lock_print_waits) {
printf("Lock wait for trx %lu ends\n",
@@ -3763,6 +3776,8 @@ lock_print_info(
mtr_t mtr;
if (buf_end - buf < 600) {
+ sprintf(buf, "... output truncated!\n");
+
return;
}
@@ -3787,6 +3802,9 @@ lock_print_info(
if ((ulint)(buf_end - buf)
< 100 + strlen(lock_latest_err_buf)) {
+ lock_mutex_exit_kernel();
+ sprintf(buf, "... output truncated!\n");
+
return;
}
@@ -3794,6 +3812,9 @@ lock_print_info(
}
if (buf_end - buf < 600) {
+ lock_mutex_exit_kernel();
+ sprintf(buf, "... output truncated!\n");
+
return;
}
@@ -3805,6 +3826,9 @@ lock_print_info(
while (trx) {
if (buf_end - buf < 900) {
+ lock_mutex_exit_kernel();
+ sprintf(buf, "... output truncated!\n");
+
return;
}
@@ -3842,6 +3866,9 @@ loop:
}
if (buf_end - buf < 900) {
+ lock_mutex_exit_kernel();
+ sprintf(buf, "... output truncated!\n");
+
return;
}
@@ -3852,6 +3879,9 @@ loop:
buf += strlen(buf);
if (buf_end - buf < 500) {
+ lock_mutex_exit_kernel();
+ sprintf(buf, "... output truncated!\n");
+
return;
}
@@ -3906,6 +3936,9 @@ loop:
}
if (buf_end - buf < 500) {
+ lock_mutex_exit_kernel();
+ sprintf(buf, "... output truncated!\n");
+
return;
}
diff --git a/innobase/os/os0file.c b/innobase/os/os0file.c
index b2881581fc7..098d5b25e89 100644
--- a/innobase/os/os0file.c
+++ b/innobase/os/os0file.c
@@ -1034,6 +1034,8 @@ try_again:
ibool retry;
ssize_t ret;
+ os_bytes_read_since_printout += n;
+
try_again:
ret = os_file_pread(file, buf, n, offset, offset_high);
diff --git a/innobase/os/os0thread.c b/innobase/os/os0thread.c
index 146303b2791..48aea4b8abb 100644
--- a/innobase/os/os0thread.c
+++ b/innobase/os/os0thread.c
@@ -52,8 +52,8 @@ os_thread_pf(
/*=========*/
os_thread_id_t a)
{
-#ifdef UNIV_HPUX
- /* In HP-UX a pthread_t is a struct of 3 fields: field1, field2,
+#ifdef UNIV_HPUX10
+ /* In HP-UX-10.20 a pthread_t is a struct of 3 fields: field1, field2,
field3. We do not know if field1 determines the thread uniquely. */
return((ulint)(a.field1));