From 4edc7584de56a162a343c4166a06f74916bd80ff Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Fri, 5 Mar 2004 18:09:32 +0100 Subject: [PATCH 1/5] comment clarified --- mysys/mf_soundex.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mysys/mf_soundex.c b/mysys/mf_soundex.c index 4f7aa7da601..6409caa356d 100644 --- a/mysys/mf_soundex.c +++ b/mysys/mf_soundex.c @@ -28,6 +28,10 @@ * * * As an extension if remove_garbage is set then all non- * * alpha characters are skipped * +* * +* Note, that this implementation corresponds to the * +* original version of the algorithm, not to the more * +* popular "enhanced" version, described by Knuth. * ****************************************************************/ #include "mysys_priv.h" From b4577bc43a8b82cdf9071ee3dd4c2dbd53850c5b Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Fri, 19 Mar 2004 17:19:33 +0100 Subject: [PATCH 2/5] typo in mysql_install_db fixed --- scripts/mysql_install_db.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh index 0c1502823af..012725265a1 100644 --- a/scripts/mysql_install_db.sh +++ b/scripts/mysql_install_db.sh @@ -118,7 +118,7 @@ then if [ $? -ne 0 ] then resolved=`$bindir/resolveip localhost 2>&1` - if [ $? -eq 0 ] + if [ $? -ne 0 ] then echo "Neither host '$hostname' and 'localhost' could not be looked up with" echo "$bindir/resolveip" From 8c5d7e54904bfb171fdf26d5d4421277fd72672e Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Fri, 19 Mar 2004 18:49:14 +0100 Subject: [PATCH 3/5] - Do-pkg: PGK and DMG names now include the full arch name (e.g. "-apple-darwin7.3.0-powerpc") - this is needed as we now will provide Mac OS X 10.2.x and Mac OS X 10.3.x PGKs (and it's more in line of how we name all other packages) --- Build-tools/Do-pkg | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Build-tools/Do-pkg b/Build-tools/Do-pkg index 4d0f120c6e3..2fd1946ed0e 100755 --- a/Build-tools/Do-pkg +++ b/Build-tools/Do-pkg @@ -61,6 +61,12 @@ else } $PM= "/Developer/Applications/PackageMaker.app/Contents/MacOS/PackageMaker"; +# Try another location on 10.3.3 +unless (-e "$PM") +{ + $PM= "/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker"; +} + $TMP= $ENV{TMPDIR}; $TMP eq "" ? $TMP= $TMP . "/PKGBUILD.$$": $TMP= "/tmp/PKGBUILD.$$"; $PKGROOT= "$TMP/PMROOT"; @@ -79,6 +85,9 @@ $BUILDDIR= "$PWD/$HOST"; $SRCBASEDIR= <$BUILDDIR/mysql*-$VERSION>; $SUPFILEDIR= <$SRCBASEDIR/support-files/MacOSX>; $TAR= <$BUILDDIR/$NAME-apple-darwin*-powerpc.tar.gz>; +$TAR =~ /.*\/$NAME(.*)\.tar\.gz$/; +$ARCH= $1; +$NAME= $NAME . $ARCH; $INFO= <$SUPFILEDIR/Info.plist>; $DESC= <$SUPFILEDIR/Description.plist>; $SI_INFO= <$SUPFILEDIR/StartupItem.Info.plist>; @@ -167,7 +176,7 @@ unless (-f "$RESOURCE_DIR/License.txt"); &logger("Extracting $TAR to $PKGROOT"); &run_command("gnutar zxf $TAR -C $PKGROOT", "Unable to extract $TAR!"); &run_command("cd $PKGROOT ; ln -s mysql* ./mysql", "Unable to create symlink!"); -&run_command("chown -R root.wheel $PKGROOT/*", "Cannot chown $PKGROOT!"); +&run_command("chown -R root:wheel $PKGROOT/*", "Cannot chown $PKGROOT!"); # Now build the PGK using PackageMaker # The "|| true" is a nasty hack to work around a problem with Package Maker @@ -196,7 +205,7 @@ unless ($opt_skip_si) copy("$SI_PARAMS", "$PKGROOT/MySQL/") or &abort("Error copying $SI_PARAMS!"); chmod(0644, "$PKGROOT/MySQL/" . basename("$SI_PARAMS")); - &run_command("chown -R root.wheel $PKGROOT/*", "Cannot chown $PKGROOT!"); + &run_command("chown -R root:wheel $PKGROOT/*", "Cannot chown $PKGROOT!"); copy("$SI_POST", "$RESOURCE_DIR/postinstall") or &abort("Error copying $SI_POST!"); chmod(0644, "$RESOURCE_DIR/postinstall"); From c9bbc83d11b56831658b03475b23306e3d48acca Mon Sep 17 00:00:00 2001 From: "heikki@hundin.mysql.fi" <> Date: Fri, 19 Mar 2004 22:51:25 +0200 Subject: [PATCH 4/5] btr0btr.c: Improve space utilization if we have 3 kB - 8 kB rows to insert in the order of the primary key btr0cur.c: Fix bug: The row count and key cardinality estimate was grossly too small if each clustered index page only contained one record --- innobase/btr/btr0btr.c | 59 ++++++++++++++++++++---------------------- innobase/btr/btr0cur.c | 24 ++++++++++++++--- 2 files changed, 48 insertions(+), 35 deletions(-) diff --git a/innobase/btr/btr0btr.c b/innobase/btr/btr0btr.c index 71be6d81d7c..1c3e033a8d7 100644 --- a/innobase/btr/btr0btr.c +++ b/innobase/btr/btr0btr.c @@ -76,9 +76,6 @@ make them consecutive on disk if possible. From the other file segment we allocate pages for the non-leaf levels of the tree. */ -/* If this many inserts occur sequentially, it affects page split */ -#define BTR_PAGE_SEQ_INSERT_LIMIT 5 - /****************************************************************** Creates a new index page to the tree (not the root, and also not used in page reorganization). */ @@ -1086,18 +1083,18 @@ btr_page_get_split_rec_to_left( page = btr_cur_get_page(cursor); insert_point = btr_cur_get_rec(cursor); - if ((page_header_get_ptr(page, PAGE_LAST_INSERT) - == page_rec_get_next(insert_point)) - && (page_header_get_field(page, PAGE_DIRECTION) == PAGE_LEFT) - && ((page_header_get_field(page, PAGE_N_DIRECTION) - >= BTR_PAGE_SEQ_INSERT_LIMIT) - || (page_header_get_field(page, PAGE_N_DIRECTION) + 1 - >= page_get_n_recs(page)))) { + if (page_header_get_ptr(page, PAGE_LAST_INSERT) + == page_rec_get_next(insert_point)) { infimum = page_get_infimum_rec(page); - - if ((infimum != insert_point) - && (page_rec_get_next(infimum) != insert_point)) { + + /* If the convergence is in the middle of a page, include also + the record immediately before the new insert to the upper + page. Otherwise, we could repeatedly move from page to page + lots of records smaller than the convergence point. */ + + if (infimum != insert_point + && page_rec_get_next(infimum) != insert_point) { *split_rec = insert_point; } else { @@ -1131,29 +1128,29 @@ btr_page_get_split_rec_to_right( page = btr_cur_get_page(cursor); insert_point = btr_cur_get_rec(cursor); - if ((page_header_get_ptr(page, PAGE_LAST_INSERT) == insert_point) - && (page_header_get_field(page, PAGE_DIRECTION) == PAGE_RIGHT) - && ((page_header_get_field(page, PAGE_N_DIRECTION) - >= BTR_PAGE_SEQ_INSERT_LIMIT) - || (page_header_get_field(page, PAGE_N_DIRECTION) + 1 - >= page_get_n_recs(page)))) { + /* We use eager heuristics: if the new insert would be right after + the previous insert on the same page, we assume that there is a + pattern of sequential inserts here. */ + + if (page_header_get_ptr(page, PAGE_LAST_INSERT) == insert_point) { supremum = page_get_supremum_rec(page); - if ((page_rec_get_next(insert_point) != supremum) - && (page_rec_get_next(page_rec_get_next(insert_point)) - != supremum) - && (page_rec_get_next(page_rec_get_next( - page_rec_get_next(insert_point))) - != supremum)) { + if (page_rec_get_next(insert_point) != supremum + && page_rec_get_next(page_rec_get_next(insert_point)) + != supremum) { - /* If there are >= 3 user records up from the insert - point, split all but 2 off */ - - *split_rec = page_rec_get_next(page_rec_get_next( - page_rec_get_next(insert_point))); + /* If there are >= 2 user records up from the insert + point, split all but 1 off. We want to keep one because + then sequential inserts can use the adaptive hash + index, as they can do the necessary checks of the right + search position just by looking at the records on this + page. */ + + *split_rec = page_rec_get_next( + page_rec_get_next(insert_point)); } else { - /* Else split at inserted record */ + /* Else split at the new record to insert */ *split_rec = NULL; } diff --git a/innobase/btr/btr0cur.c b/innobase/btr/btr0cur.c index a9f92dbc181..e5c8762bdb9 100644 --- a/innobase/btr/btr0cur.c +++ b/innobase/btr/btr0cur.c @@ -2671,10 +2671,11 @@ btr_estimate_number_of_different_key_vals( btr_cur_open_at_rnd_pos(index, BTR_SEARCH_LEAF, &cursor, &mtr); - /* Count the number of different key values minus one - for each prefix of the key on this index page: we subtract - one because otherwise our algorithm would give a wrong - estimate for an index where there is just one key value */ + /* Count the number of different key values for each prefix of + the key on this index page. If the prefix does not determine + the index record uniquely in te B-tree, then we subtract one + because otherwise our algorithm would give a wrong estimate + for an index where there is just one key value. */ page = btr_cur_get_page(&cursor); @@ -2696,6 +2697,9 @@ btr_estimate_number_of_different_key_vals( &matched_bytes); for (j = matched_fields + 1; j <= n_cols; j++) { + /* We add one if this index record has + a different prefix from the previous */ + n_diff[j]++; } @@ -2705,6 +2709,18 @@ btr_estimate_number_of_different_key_vals( rec = page_rec_get_next(rec); } + if (n_cols == dict_index_get_n_unique_in_tree(index)) { + /* We add one because we know that the first record + on the page certainly had a different prefix than the + last record on the previous index page in the + alphabetical order. Before this fix, if there was + just one big record on each clustered index page, the + algorithm grossly underestimated the number of rows + in the table. */ + + n_diff[n_cols]++; + } + total_external_size += btr_rec_get_externally_stored_len(rec); mtr_commit(&mtr); From a8da91f9fb480b52e5e376f8584bf809d922790e Mon Sep 17 00:00:00 2001 From: "heikki@hundin.mysql.fi" <> Date: Sat, 20 Mar 2004 06:09:18 +0200 Subject: [PATCH 5/5] btr0btr.c: Correct previous bk commit comment about page splits: actually, in versions < 4.0.19 space utilization is very poor if 1500 - 8000 byte rows are inserted in the order of the primary key --- innobase/btr/btr0btr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/innobase/btr/btr0btr.c b/innobase/btr/btr0btr.c index 1c3e033a8d7..1d22d107b12 100644 --- a/innobase/btr/btr0btr.c +++ b/innobase/btr/btr0btr.c @@ -5,7 +5,7 @@ The B-tree Created 6/2/1994 Heikki Tuuri *******************************************************/ - + #include "btr0btr.h" #ifdef UNIV_NONINL