From 6732573c3c4d4f372fde875370fa372aceb0246b Mon Sep 17 00:00:00 2001 From: "heikki@donna.mysql.fi" <> Date: Tue, 11 Dec 2001 22:45:32 +0200 Subject: ut0byte.h, ut0byte.c, dict0dict.c: Make column names non-case-sensitive in referential constraints and put table and database names there in lower case in Windows --- innobase/dict/dict0dict.c | 14 +++++++++++--- innobase/include/ut0byte.h | 20 ++++++++++++++++++++ innobase/ut/ut0byte.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 3 deletions(-) (limited to 'innobase') diff --git a/innobase/dict/dict0dict.c b/innobase/dict/dict0dict.c index ba032013baf..bf3e134febb 100644 --- a/innobase/dict/dict0dict.c +++ b/innobase/dict/dict0dict.c @@ -1761,9 +1761,8 @@ dict_scan_col( col = dict_table_get_nth_col(table, i); if (ut_strlen(col->name) == (ulint)(ptr - old_ptr) - && 0 == ut_memcmp(col->name, old_ptr, + && 0 == ut_cmp_in_lower_case(col->name, old_ptr, (ulint)(ptr - old_ptr))) { - /* Found */ *success = TRUE; @@ -1827,11 +1826,20 @@ dict_scan_table_name( break; } } - +#ifdef __WIN__ + ut_cpy_in_lower_case(second_table_name + i, old_ptr, + ptr - old_ptr); +#else ut_memcpy(second_table_name + i, old_ptr, ptr - old_ptr); +#endif second_table_name[i + (ptr - old_ptr)] = '\0'; } else { +#ifdef __WIN__ + ut_cpy_in_lower_case(second_table_name, old_ptr, + ptr - old_ptr); +#else ut_memcpy(second_table_name, old_ptr, ptr - old_ptr); +#endif second_table_name[dot_ptr - old_ptr] = '/'; second_table_name[ptr - old_ptr] = '\0'; } diff --git a/innobase/include/ut0byte.h b/innobase/include/ut0byte.h index 77795ee0708..b45f2160392 100644 --- a/innobase/include/ut0byte.h +++ b/innobase/include/ut0byte.h @@ -220,6 +220,26 @@ ut_bit_set_nth( ulint a, /* in: ulint */ ulint n, /* in: nth bit requested */ ibool val); /* in: value for the bit to set */ +/**************************************************************** +Copies a string to a memory location, setting characters to lower case. */ + +void +ut_cpy_in_lower_case( +/*=================*/ + char* dest, /* in: destination */ + char* source, /* in: source */ + ulint len); /* in: string length */ +/**************************************************************** +Compares two strings when converted to lower case. */ + +int +ut_cmp_in_lower_case( +/*=================*/ + /* out: -1, 0, 1 if str1 < str2, str1 == str2, + str1 > str2, respectively */ + char* str1, /* in: string1 */ + char* str2, /* in: string2 */ + ulint len); /* in: length of both strings */ #ifndef UNIV_NONINL diff --git a/innobase/ut/ut0byte.c b/innobase/ut/ut0byte.c index fa0d904a6a7..02bdf2065ee 100644 --- a/innobase/ut/ut0byte.c +++ b/innobase/ut/ut0byte.c @@ -30,3 +30,46 @@ ut_dulint_sort(dulint* arr, dulint* aux_arr, ulint low, ulint high) ut_dulint_cmp); } +/**************************************************************** +Copies a string to a memory location, setting characters to lower case. */ + +void +ut_cpy_in_lower_case( +/*=================*/ + char* dest, /* in: destination */ + char* source,/* in: source */ + ulint len) /* in: string length */ +{ + ulint i; + + for (i = 0; i < len; i++) { + dest[i] = tolower(source[i]); + } +} + +/**************************************************************** +Compares two strings when converted to lower case. */ + +int +ut_cmp_in_lower_case( +/*=================*/ + /* out: -1, 0, 1 if str1 < str2, str1 == str2, + str1 > str2, respectively */ + char* str1, /* in: string1 */ + char* str2, /* in: string2 */ + ulint len) /* in: length of both strings */ +{ + ulint i; + + for (i = 0; i < len; i++) { + if (tolower(str1[i]) < tolower(str2[i])) { + return(-1); + } + + if (tolower(str1[i]) > tolower(str2[i])) { + return(1); + } + } + + return(0); +} -- cgit v1.2.1 From f08cf9cf61b7c20bcf4b3e2f3b06b5bed2afad97 Mon Sep 17 00:00:00 2001 From: "heikki@donna.mysql.fi" <> Date: Tue, 11 Dec 2001 23:42:31 +0200 Subject: btr0cur.c: Improve table cardinality estimate if there are big BLOBs --- innobase/btr/btr0cur.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 2 deletions(-) (limited to 'innobase') diff --git a/innobase/btr/btr0cur.c b/innobase/btr/btr0cur.c index 70de09f0fd9..da51be11176 100644 --- a/innobase/btr/btr0cur.c +++ b/innobase/btr/btr0cur.c @@ -85,6 +85,15 @@ btr_rec_free_updated_extern_fields( inherited fields */ mtr_t* mtr); /* in: mini-transaction handle which contains an X-latch to record page and to the tree */ +/*************************************************************** +Gets the externally stored size of a record, in units of a database page. */ +static +ulint +btr_rec_get_externally_stored_len( +/*==============================*/ + /* out: externally stored part, in units of a + database page */ + rec_t* rec); /* in: record */ /*==================== B-TREE SEARCH =========================*/ @@ -2540,6 +2549,7 @@ btr_estimate_number_of_different_key_vals( ulint matched_bytes; ulint* n_diff; ulint not_empty_flag = 0; + ulint total_external_size = 0; ulint i; ulint j; mtr_t mtr; @@ -2586,10 +2596,15 @@ btr_estimate_number_of_different_key_vals( for (j = matched_fields + 1; j <= n_cols; j++) { n_diff[j]++; } - + + total_external_size += + btr_rec_get_externally_stored_len(rec); + rec = page_rec_get_next(rec); } + total_external_size += + btr_rec_get_externally_stored_len(rec); mtr_commit(&mtr); } @@ -2597,12 +2612,18 @@ btr_estimate_number_of_different_key_vals( BTR_KEY_VAL_ESTIMATE_N_PAGES leaf pages, we can estimate how many there will be in index->stat_n_leaf_pages */ + /* We must take into account that our sample actually represents + also the pages used for external storage of fields (those pages are + included in index->stat_n_leaf_pages) */ + for (j = 0; j <= n_cols; j++) { index->stat_n_diff_key_vals[j] = (n_diff[j] * index->stat_n_leaf_pages + BTR_KEY_VAL_ESTIMATE_N_PAGES - 1 + + total_external_size + not_empty_flag) - / BTR_KEY_VAL_ESTIMATE_N_PAGES; + / (BTR_KEY_VAL_ESTIMATE_N_PAGES + + total_external_size); } mem_free(n_diff); @@ -2610,6 +2631,48 @@ btr_estimate_number_of_different_key_vals( /*================== EXTERNAL STORAGE OF BIG FIELDS ===================*/ +/*************************************************************** +Gets the externally stored size of a record, in units of a database page. */ +static +ulint +btr_rec_get_externally_stored_len( +/*==============================*/ + /* out: externally stored part, in units of a + database page */ + rec_t* rec) /* in: record */ +{ + ulint n_fields; + byte* data; + ulint local_len; + ulint extern_len; + ulint total_extern_len = 0; + ulint i; + + if (rec_get_data_size(rec) <= REC_1BYTE_OFFS_LIMIT) { + + return(0); + } + + n_fields = rec_get_n_fields(rec); + + for (i = 0; i < n_fields; i++) { + if (rec_get_nth_field_extern_bit(rec, i)) { + + data = rec_get_nth_field(rec, i, &local_len); + + local_len -= BTR_EXTERN_FIELD_REF_SIZE; + + extern_len = mach_read_from_4(data + local_len + + BTR_EXTERN_LEN + 4); + + total_extern_len += ut_calc_align(extern_len, + UNIV_PAGE_SIZE); + } + } + + return(total_extern_len / UNIV_PAGE_SIZE); +} + /*********************************************************************** Sets the ownership bit of an externally stored field in a record. */ static -- cgit v1.2.1 From ab550295e90dcc24db87ba6f1580c46f8ab2d648 Mon Sep 17 00:00:00 2001 From: "heikki@donna.mysql.fi" <> Date: Tue, 11 Dec 2001 23:45:49 +0200 Subject: sync0arr.c: Increase semaphore wait warning threshold to 240 seconds --- innobase/sync/sync0arr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'innobase') diff --git a/innobase/sync/sync0arr.c b/innobase/sync/sync0arr.c index b82c2a4a2df..c41754316d0 100644 --- a/innobase/sync/sync0arr.c +++ b/innobase/sync/sync0arr.c @@ -905,7 +905,7 @@ sync_array_print_long_waits(void) cell = sync_array_get_nth_cell(sync_primary_wait_array, i); if (cell->wait_object != NULL - && difftime(time(NULL), cell->reservation_time) > 120) { + && difftime(time(NULL), cell->reservation_time) > 240) { fprintf(stderr, "InnoDB: Warning: a long semaphore wait:\n"); -- cgit v1.2.1