Merge from next-mr

This commit is contained in:
Bjorn Munch 2009-12-16 12:14:14 +01:00
commit 034e86a533
1462 changed files with 149388 additions and 171426 deletions

View File

@ -1139,6 +1139,7 @@ libmysqld/protocol_cursor.cc
libmysqld/records.cc
libmysqld/repl_failsafe.cc
libmysqld/rpl_filter.cc
libmysqld/rpl_handler.cc
libmysqld/rpl_injector.cc
libmysqld/rpl_record.cc
libmysqld/rpl_record_old.cc
@ -3065,4 +3066,7 @@ sql/share/swedish
sql/share/ukrainian
libmysqld/examples/mysqltest.cc
libmysqld/sql_signal.cc
libmysqld/rpl_handler.cc
libmysqld/debug_sync.cc
libmysqld/rpl_handler.cc
dbug/tests

View File

@ -1,37 +0,0 @@
.snprj
COPYING
COPYING.LIB
INSTALL-SOURCE
INSTALL-SOURCE-GENERIC
Logs
MIRRORS
Makefile
Makefile.in
NEW-RPMS
PUBLIC
Projects
TODO
WIN-LICENSE
aclocal.m4
binary
compile
confdefs.h
config.cache
config.h
config.log
config.status
configure
configure.in-removed
conftest.c
conftest.s1
conftest.s2
conftest.subs
internal-docs
libtool
linked_client_sources
linked_server_sources
mysql-copyright-120700-194832
mysql-copyright-120700-221248
skr
stamp-h
tmp

View File

@ -1 +0,0 @@
compile-pentium-test

View File

@ -1274,7 +1274,7 @@ set_bsd_configs()
if test "x$fast_flag" != "xno" ; then
compiler_flags="$compiler_flags -O3"
else
compiler_flags="$compiler_flags -O"
compiler_flags="$compiler_flags -O0"
fi
set_cc_and_cxx_for_gcc
}
@ -1305,7 +1305,7 @@ set_linux_configs()
if test "x$fast_flag" != "xno" ; then
compiler_flags="$compiler_flags -O2"
else
compiler_flags="$compiler_flags -O"
compiler_flags="$compiler_flags -O0"
fi
# configure will set proper compiler flags for gcc on Linux
elif test "x$compiler" = "xicc" ; then
@ -1375,8 +1375,8 @@ set_solaris_configs()
LDFLAGS="$LDFLAGS -O2"
compiler_flags="$compiler_flags -O2"
else
LDFLAGS="$LDFLAGS -O"
compiler_flags="$compiler_flags -O"
LDFLAGS="$LDFLAGS -O0"
compiler_flags="$compiler_flags -O0"
fi
fi
else
@ -1407,7 +1407,7 @@ set_solaris_configs()
elif test "x$fast_flag" = "xgeneric" ; then
compiler_flags="$compiler_flags -xO2"
else
compiler_flags="$compiler_flags -xO"
compiler_flags="$compiler_flags -xO0"
fi
else
#Using SPARC cpu with SunStudio (Forte) compiler
@ -1421,7 +1421,7 @@ set_solaris_configs()
elif test "x$fast_flag" = "xgeneric" ; then
compiler_flags="$compiler_flags -xO2"
else
compiler_flags="$compiler_flags -xO"
compiler_flags="$compiler_flags -xO0"
fi
fi
fi
@ -1452,7 +1452,7 @@ set_macosx_configs()
if test "x$fast_flag" != "xno" ; then
compiler_flags="$compiler_flags -Os"
else
compiler_flags="$compiler_flags -O"
compiler_flags="$compiler_flags -O0"
fi
set_cc_and_cxx_for_gcc
}

View File

@ -1,62 +0,0 @@
44d03f27qNdqJmARzBoP3Is_cN5e0w
44ec850ac2k4y2Omgr92GiWPBAVKGQ
44edb86b1iE5knJ97MbliK_3lCiAXA
44f33f3aj5KW5qweQeekY1LU0E9ZCg
45001f7c3b2hhCXDKfUvzkX9TNe6VA
45002051rHJfMEXAIMiAZV0clxvKSA
4513d8e4Af4dQWuk13sArwofRgFDQw
45143312u0Tz4r0wPXCbUKwdHa2jWA
45143b90ewOQuTW8-jrB3ZSAQvMRJw
45184588w9U72A6KX1hUFeAC4shSHA
45185df8mZbxfp85FbA0VxUXkmDewA
4519a6c5BVUxEHTf5iJnjZkixMBs8g
451ab499rgdjXyOnUDqHu-wBDoS-OQ
451b110a3ZV6MITl93ehXk2wxrbW7g
45214442pBGT9KuZEGixBH71jTzbOA
45214a07hVsIGwvwa-WrO-jpeaSwVw
452a92d0-31-8wSzSfZi165fcGcXPA
452c6c6dAjuNghfc1ObZ_UQ5SCl85g
4538a7b0EbDHHkWPbIwxO6ZIDdg6Dg
454a7ef8gdvE_ddMlJyghvOAkKPNOQ
454bb488ijVLOUK_GFjcoISE0GxPUA
454bb9a8AwlGRC_wWLS2sNMoRBMRGw
454c946ciQoR4dfTBZ0RTBmGJKp6lw
454f6e7eAnfLD9OCbGr5X9KiKvfKcQ
454f704bJiJy0_Nx2drY9P5kK3uOzg
454f8960jsVT_kMKJtZ9OCgXoba0xQ
454fa71cxshxszXJQYa9jbo0-_hAHw
4550b0ceIcozdgQhWFUTAtWkN196lA
4554a95d7txO1DuO9G3nAizI3SkFAA
4554b3722d71SbPiI2Gx-RhbZjmuIQ
4558b3d73Cxjlb7Wv1oytdSTthxDfw
4561b2ecZbhuAc0TTDdCdultxUYaMw
4561bde4qWhz1I8tkItXKex5uniipA
4562ba016dYH0JzszOqZ8p6psbKfnQ
45771031yRCoM_ZfONdYchPvVEgLRg
459a60d8rIxeTuhB3j_QsOwLGdcpng
459a61c9OS8PzIsdviZJDkybJ1y1uA
459a70691aYIfU2ohV0a3P5iTLpO2A
459a7422KF_P7PuU3YQ5qG6ZLEVpiA
459a74e4nRcXppMSBYeQQ5efDkTADg
459c03b9N_mqF2XJKK6DwSrIt7e6_g
459c1965_BQMBzBO8S_gVqjTHYQrmw
459c2098XoAUsUn8N07IVRDD6CTM-A
459ea845XenN-uWqEM5LFvUT60tW_A
45ae6628gqKTsUFfnoNExadETVIkbA
45af88c9RIIJWPfBxs3o7zekI-ELPQ
45ba4faf2oqu6eR8fqecR3LfSNcYUg
45ba5238-NKl80QVXzdGo8hO9M75Xg
45c0fdfb2mz6NdOIsLenJtf6_ZelTA
45c38d90tNwOTSaYKHXd3ccLtnytlQ
45c390d6BbWrwyEi5T5VsWKYxl06Rg
45c39d31g0iik6UE_oTK5N55ry-ycA
45d1ffcd-r3v8A7uh92hQaMfQM9UPQ
45d21437Vg_-i4uOWyvzYWHESXDP6A
45da6370nnZlAAIieMCrXkxF9toOyQ
45da6551zUuplwxuqcT2fhRgceC0CQ
45db0d4bkGtxBk21sZFJgbCV1FcNRg
45db468b-DKE8kUTV42eYMYmk8_g9g
45dd21d1rVPnDfvZTNVHLalcjnbsZw
45ddaf15_Ld7IAEpUUP3FJjJ-oSEFg
45ddc763DodLG1BqH_wRBJXMbCSB5A
45ddc8282KnaNGuijqCTphlXV_eeog

View File

@ -1,80 +0,0 @@
# This is the BitKeeper configuration for this package.
#
# Please take a minute to fill it out carefully, it needs to be accurate.
#
# NOTICE: you really do want to fill this out, if something goes wrong
# with your repository, or if someone changes the logging policy, we
# send mail to the contact listed here for confirmation.
#
# BitKeeper can maintain a log of your change comments (not your source,
# just the comments) on a centralized server. This is useful as your
# project grows, it gives people a place to go see what is happening on
# a per project basis. This is especially useful for distributed developers.
#
#
# Name of the project, such as "BitKeeper" or "The GNU C compiler".
#
description: MySQL - fast and reliable SQL database
#
# Open Logging server. This site is where users go to see the
# changelog comments for all instances of this repository. This must
# be logging@openlogging.org for usage under the terms of the BKL,
# "bk help bkl" will show you the default licensing terms. If this
# repository is commercial it can be an internal email address or "none"
# to disable logging.
#
logging: none
#
# If this field is set, all checkins will appear to be made by this user,
# in effect making this a single user package. Single user packages are
# free from the logging constraint. In order for the package to really
# be free, both the single_user and the single_host field need to be set.
#
single_user:
#
# If this field is set, all checkins will appear to be made on this host.
#
single_host:
#
# Contact person for this project. This is whoever is the person that
# should be contacted with update information or contacted if BitKeeper
# discovers a problem which requires local intervention. Please make the
# contact information accurate so we can support you.
#
contact: sys@mysql.com
#
# It is very important that this email address is filled out and accurate.
# If someone converts your repository to open logging (which you may not
# want), we will contact this email address for confirmation that you really
# did want open logging. If the email address is inaccurate and we get no
# response from anyone else at your location after 90 days, then open logging
# will be implicitly approved.
#
email: sys@mysql.com
#
# Add your street address if you like, it is optional.
#
street:
city:
state:
postal:
country:
phone:
cell:
pager:
#
# Business Hours when we can contact you if you left a phone number.
#
hours:
[serg:]checkout:get
[arjen:]checkout:get
[kostja:]checkout:get
[nick:]checkout:get
[jonas:]checkout:get
[tomas:]checkout:get
[guilhem:]checkout:get
[pekka:]checkout:get
[msvensson:]checkout:get
checkout:edit
eoln:unix

File diff suppressed because it is too large Load Diff

View File

@ -1,314 +0,0 @@
Administrador@light.
Administrator@co3064164-a.
Administrator@co3064164-a.rochd1.qld.optushome.com.au
Administrator@fred.
Administrator@w2k.
Greg@greg-laptop.
Miguel@light.local
Sinisa@sinisa.nasamreza.org
WAX@sergbook.mysql.com
acurtis@ltantony.rdg.cyberkinetica.homeunix.net
acurtis@pcgem.rdg.cyberkinetica.com
acurtis@xiphis.org
administrador@light.hegel.local
ahlentz@co3064164-a.rochd1.qld.optusnet.com.au
akishkin@work.mysql.com
anjuta@arthur.local
antony@ltantony.dsl-verizon.net
antony@ltantony.mysql.com
antony@ltantony.rdg.cyberkinetica.com
antony@ltantony.rdg.cyberkinetica.homeunix.net
antony@ltantony.xiphis.org
arjen@bitbike.com
arjen@co3064164-a.bitbike.com
arjen@fred.bitbike.com
arjen@george.bitbike.com
autotest@mc01.ndb.mysql.com
bar@bar.intranet.mysql.r18.ru
bar@bar.mysql.r18.ru
bar@bar.udmsearch.izhnet.ru
bar@deer.(none)
bar@eagle.intranet.mysql.r18.ru
bar@gw.udmsearch.izhnet.ru
bar@mysql.com
bar@noter.intranet.mysql.r18.ru
bell@51.0.168.192.in-addr.arpa
bell@52.0.168.192.in-addr.arpa
bell@book.sanja.is.com.ua
bell@laptop.sanja.is.com.ua
bell@sanja.is.com.ua
bk@admin.bk
bk@mysql.r18.ru
brian@avenger.(none)
brian@brian-akers-computer.local
brian@private-client-ip-101.oz.net
brian@zim.(none)
carsten@tsort.bitbybit.dk
cps@silver_beast.(none)
davida@isil.mysql.com
dean@mysql.com
dellis@goetia.(none)
dlenev@brandersnatch.localdomain
dlenev@build.mysql.com
dlenev@jabberwock.localdomain
dlenev@mysql.com
ejonore@mc03.ndb.mysql.com
elliot@mysql.com
evgen@moonbone.(none)
evgen@moonbone.local
gbichot@bk-internal.mysql.com
gbichot@production.mysql.com
gbichot@quadita2.mysql.com
gbichot@quadxeon.mysql.com
geert@kriem.kemuri.org
georg@beethoven.local
georg@beethoven.site
georg@lmy002.wdf.sap.corp
gerberb@ou800.zenez.com
gluh@eagle.intranet.mysql.r18.ru
gluh@gluh.(none)
gluh@gluh.mysql.r18.ru
gluh@mysql.com
gordon@zero.local.lan
greg@gcw.ath.cx
greg@mysql.com
guilhem@mysql.com
gweir@build.mysql.com
gweir@work.mysql.com
harrison@mysql.com
harry@corona.lordblink.com
hartmut@mysql.com
heikki@donna.mysql.fi
heikki@hundin.mysql.fi
heikki@rescue.
heikki@work.mysql.com
hf@bison.(none)
hf@bisonxp.(none)
hf@deer.(none)
hf@deer.mysql.r18.ru
hf@genie.(none)
holyfoot@mysql.com
igor@hundin.mysql.fi
igor@igor-inspiron.creware.com
igor@linux.local
igor@rurik.mysql.com
ingo@mysql.com
jan@hundin.mysql.fi
jani@a193-229-222-105.elisa-laajakaista.fi
jani@a193-229-222-2.elisa-laajakaista.fi
jani@a80-186-24-72.elisa-laajakaista.fi
jani@a80-186-41-201.elisa-laajakaista.fi
jani@a80-186-8-224.elisa-laajakaista.fi
jani@dsl-jkl1657.dial.inet.fi
jani@dsl-kpogw4gb5.dial.inet.fi
jani@hynda.(none)
jani@hynda.mysql.fi
jani@ibmlab.site
jani@janikt.pp.saunalahti.fi
jani@linux.local
jani@rhols221.adsl.netsonic.fi
jani@rhols221.arenanet.fi
jani@ua126d19.elisa.omakaista.fi
jani@ua141d10.elisa.omakaista.fi
jani@ua167d18.elisa.omakaista.fi
jani@ua72d24.elisa.omakaista.fi
jcole@abel.spaceapes.com
jcole@main.burghcom.com
jcole@mugatu.jcole.us
jcole@mugatu.spaceapes.com
jcole@sarvik.tfr.cafe.ee
jcole@tetra.spaceapes.com
jimw@mysql.com
joerg@mysql.com
joerg@trift-lap.fambruehe
jon@gigan.
jonas@mysql.com
joreland@bk-internal.mysql.com
joreland@mysql.com
jorge@linux.jorge.mysql.com
jplindst@t41.(none)
kaa@polly.local
kaj@work.mysql.com
kent@mysql.com
konstantin@mysql.com
kosipov@production.mysql.com
kostja@oak.local
lars@mysql.com
lenz@kallisto.mysql.com
lenz@mysql.com
magnus@msdesk.mysql.com
magnus@neptunus.(none)
magnus@shellback.(none)
marko@hundin.mysql.fi
marty@flipper.bredbandsbolaget.se
marty@linux.site
marty@shark.
mats@mysql.com
matt@booty.(none)
matt@mysql.com
matthias@three.local.lan
miguel@hegel.(none)
miguel@hegel.br
miguel@hegel.local
miguel@hegel.txg
miguel@hegel.txg.br
miguel@light.
miguel@light.local
miguel@sartre.local
mikael@mc04.(none)
mikael@orca.ndb.mysql.com
mikron@c-fb0ae253.1238-1-64736c10.cust.bredbandsbolaget.se
mikron@mikael-ronstr-ms-dator.local
mleich@mysql.com
mmatthew@markslaptop.
monty@bitch.mysql.fi
monty@butch.
monty@donna.mysql.fi
monty@hundin.mysql.fi
monty@mashka.(none)
monty@mashka.mysql.fi
monty@mishka.local
monty@mishka.mysql.fi
monty@mysql.com
monty@narttu.
monty@narttu.mysql.fi
monty@rescue.
monty@tik.
monty@tik.mysql.fi
monty@tramp.mysql.fi
monty@work.mysql.com
mronstrom@build.mysql.com
mronstrom@mysql.com
mskold@bk-internal.mysql.com
mskold@mysql.com
msvensson@build.mysql.com
msvensson@neptunus.(none)
msvensson@neptunus.homeip.net
mwagner@cash.mwagner.org
mwagner@evoq.mwagner.org
mwagner@here.mwagner.org
mwagner@mysql.com
mwagner@ultrafly.mysql.com
mwagner@work.mysql.com
mydev@mysql.com
mysql@home.(none)
mysql@mc04.(none)
mysqldev@bk-internal.mysql.com
mysqldev@build.mysql2.com
mysqldev@melody.local
mysqldev@mysql.com
mysqldev@o2k.irixworld.net
ndbdev@dl145b.mysql.com
ndbdev@dl145c.mysql.com
ndbdev@eel.hemma.oreland.se
ndbdev@ndbmaster.mysql.com
ndbdev@shark.
nick@mysql.com
nick@nick.leippe.com
obarnir@mysql.com
papa@gbichot.local
patg@krsna.
patg@krsna.patg.net
patg@patrick-galbraiths-computer.local
patg@patrick.local
patg@pc248.lfp.kcls.org
patg@radha.local
paul@central.snake.net
paul@frost.snake.net
paul@ice.local
paul@ice.snake.net
paul@kite-hub.kitebird.com
paul@snake-hub.snake.net
paul@teton.kitebird.com
pekka@mysql.com
pem@mysql.com
pem@per-erik-martins-dator.local
peter@linux.local
peter@mysql.com
peterg@mysql.com
petr@mysql.com
pgulutzan@linux.local
pmartin@build.mysql2.com
psergey@psergey-rh8.(none)
psergey@psergey.(none)
ram@deer.(none)
ram@gw.mysql.r18.ru
ram@gw.udmsearch.izhnet.ru
ram@mysql.r18.ru
ram@ram-book.(none)
ram@ram.(none)
ramil@mysql.com
ranger@regul.home.lan
rburnett@bk-internal.mysql.com
rburnett@build.mysql.com
reggie@bob.(none)
reggie@mdk10.(none)
reggie@monster.
root@home.(none)
root@mc04.(none)
root@x3.internalnet
salle@banica.(none)
salle@geopard.(none)
salle@geopard.online.bg
salle@vafla.home
salle@vafla.online.bg
sasha@mysql.sashanet.com
schwenke@lmy003.wdf.sap.corp
schwenke@lmy003.xl.local
serg@build.mysql.com
serg@build.mysql2.com
serg@mysql.com
serg@serg.mylan
serg@serg.mysql.com
serg@sergbook.mylan
serg@sergbook.mysql.com
sergefp@mysql.com
shuichi@mysql.com
sinisa@rhols221.adsl.netsonic.fi
stewart@mysql.com
svoj@mysql.com
tfr@beta.frontier86.ee
tfr@indrek.tfr.cafe.ee
tfr@sarvik.tfr.cafe.ee
tim@bitch.mysql.fi
tim@black.box
tim@hundin.mysql.fi
tim@sand.box
tim@siva.hindu.god
tim@threads.polyesthetic.msg
tim@white.box
tim@work.mysql.com
timour@mysql.com
tom@basil-firewall.home.com
tomas@mc05.(none)
tomas@poseidon.(none)
tomas@poseidon.bredbandsbolaget.se
tomas@poseidon.elisa-laajakaista.fi
tomas@poseidon.ndb.mysql.com
tonu@hundin.mysql.fi
tonu@volk.internalnet
tonu@x153.internalnet
tonu@x3.internalnet
tsmith@build.mysql.com
tulin@build.mysql.com
tulin@dl145b.mysql.com
tulin@dl145c.mysql.com
tulin@mysql.com
ulli@morbus.(none)
venu@hundin.mysql.fi
venu@myvenu.com
venu@work.mysql.com
vtkachenko@intelp4d.mysql.com
vtkachenko@mail.mysql.com
vva@eagle.mysql.r18.ru
vva@genie.(none)
vva@mysql.r18.ru
walrus@kishkin.ru
walrus@mysql.com
wax@kishkin.ru
wax@mysql.com
worm@altair.is.lan
zak@balfor.local
zak@linux.local
zak@mysql.com
zgreant@mysql.com

View File

@ -1 +0,0 @@
dev@mysql.com

View File

@ -1,7 +0,0 @@
BK|scripts/safe_mysqld.sh|19700101030959|01930|d0a3cc73fd1b0d8d tim@localhost.polyesthetic.msg|scripts/safe_mysqld.sh|20000802235627|38519
bk@work.mysql.com|BitKeeper/etc/logging_ok|20000731192914|03271|5e19f6258f804ffe arjen@co3064164-a.bitbike.com|BitKeeper/etc/logging_ok|20011212060636|33009
bk@work.mysql.com|BitKeeper/etc/logging_ok|20000731192914|03271|5e19f6258f804ffe jcole@tetra.bedford.progress.com|BitKeeper/etc/logging_ok|20001004201211|30554
bk@work.mysql.com|BitKeeper/etc/logging_ok|20000731192914|03271|5e19f6258f804ffe sasha@work.mysql.com|BitKeeper/etc/logging_ok|20000802223223|24242
bk@work.mysql.com|BitKeeper/etc/logging_ok|20000731192914|03271|5e19f6258f804ffe tim@localhost.polyesthetic.msg|BitKeeper/etc/logging_ok|20000802235640|27343
bk@work.mysql.com|ChangeSet|20000731191004|44203|eae70093a6122e66+ sasha@work.mysql.com|ChangeSet|20000802223249|54774
bk@work.mysql.com|ChangeSet|20000731191004|44203|eae70093a6122e66+ tim@localhost.polyesthetic.msg|ChangeSet|20000802235645|56533

View File

@ -1,14 +0,0 @@
#!/bin/sh
shift
REPO=`bk gethost`:`pwd`
TO=dev@mysql.com
if [ -f BitKeeper/etc/pushed -a "$BK_OUTGOING" = OK ]
then (
echo ${USER}@"$@"
echo ""
bk changes - < BitKeeper/etc/pushed
) | mail -s "Outgoing from $REPO" $TO
else
echo ${USER}@"$@"| mail -s "Outgoing from $REPO = $BK_OUTGOING" $TO
fi

View File

@ -1,134 +0,0 @@
#!/bin/sh
#shift
if [ -n "$BK_USER" ]
then
COMMITTER=$BK_USER
else
COMMITTER=$USER
fi
FROM=$COMMITTER@mysql.com
COMMITS=commits@lists.mysql.com
DOCS=docs-commit@mysql.com
LIMIT=10000
VERSION="5.1"
BKROOT=`bk root`
if [ -x /usr/sbin/sendmail ]; then
SENDMAIL=/usr/sbin/sendmail
else
SENDMAIL=sendmail
fi
if [ "$REAL_EMAIL" = "" ]
then
echo "Warning: you must set REAL_EMAIL in your profile"
else
FROM=$REAL_EMAIL
fi
BK_STATUS=$BK_STATUS$BK_COMMIT
if [ "$BK_STATUS" = OK ]
then
HAS_ACTUAL_CHANGES=`bk cset -r+ -d | grep -v "^#"`
if [ "$HAS_ACTUAL_CHANGES" = "" ]
then
echo ChangeSet had no real changes, not sending emails
exit
fi
IS_MERGE=`bk changes -r+ -k -m`
if [ "$IS_MERGE" = "" ]
then
echo Merge changeset, not sending mails
exit
fi
CHANGESET=`bk -R prs -r+ -h -d':P:::I:' ChangeSet`
CSETKEY=`bk -R prs -r+ -h -d':KEY:' ChangeSet`
#
# composing subject lines of commit mails.
# if a fix targets to a WL and there is a bug referred
# then X-Bug mail header will contain the first found bug's number
#
BUG=`bk -R prs -r+ -h -d':C:' ChangeSet | \
sed -ne 's/[Bb][Uu][Gg] *# *\([0-9][0-9]*\).*$/BUG#\1/
s/.*BUG#\([0-9][0-9]*\)/\1/p'`
WL=`bk -R prs -r+ -h -d':C:' ChangeSet | \
sed -ne 's/[Ww][Ll] *# *\([0-9][0-9]*\).*$/WL#\1/
s/.*\(WL#[0-9][0-9]*\)/ \1/p'`
if [ "$BUG" = "" ]
then
# TO=dev-public@mysql.com
BS=""
BH=""
else
# TO=dev-bugs@mysql.com
BS=" BUG#$BUG"
# need newline here
BH="X-Bug: $BUG
"
fi
#++
# commits@ or dev-private@ mail
#--
LIST="commits"
TO="commits@lists.mysql.com"
if [ -f .tree-is-private ]
then
LIST="dev-private"
TO="dev-private@mysql.com"
fi
echo "Notifying $LIST list at $TO"
(
cat <<EOF
List-ID: <bk.mysql-$VERSION>
From: $FROM
To: $TO
Subject: bk commit into $VERSION tree ($CHANGESET)$BS
X-CSetKey: <$CSETKEY>
$BH
Below is the list of changes that have just been committed into a local
$VERSION repository of $COMMITTER. When $COMMITTER does a push these changes
will be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
EOF
bk changes -v -r+
bk rset -r+ -ah | bk gnupatch -h -dup -T
) | bk sed -e ${LIMIT}q > $BKROOT/BitKeeper/tmp/commits.txt
$SENDMAIL -t < $BKROOT/BitKeeper/tmp/commits.txt
#++
# docs-commit@ mail
# Picks up anything under the Docs subdirectory (relevant for docs team).
#--
bk changes -v -r+ | grep -q " Docs/"
if [ $? -eq 0 ]
then
echo "Notifying docs list at $DOCS"
(
cat <<EOF
List-ID: <bk.mysql-$VERSION>
From: $FROM
To: $DOCS
Subject: bk commit - $VERSION tree (Manual) ($CHANGESET)$BS
EOF
bk changes -v -r+
bk rset -r+ -ah | bk gnupatch -h -dup -T
) > $BKROOT/BitKeeper/tmp/docs.txt
$SENDMAIL -t < $BKROOT/BitKeeper/tmp/docs.txt
fi
else
echo "commit failed because '$BK_STATUS', you may need to re-clone..."
fi

View File

@ -1,22 +0,0 @@
#! /usr/bin/perl
use strict;
use warnings;
use FindBin;
require "$FindBin::Bin/triggers-lib.pl";
# Don't run unless commit was successful
check_status() || exit 0;
my $cset = latest_cset();
# Read most recent ChangeSet's changed files. Send merge changes along, since
# they'll need to be incorporated in InnoDB's source tree eventually.
my $changes = innodb_get_changes('cset', $cset, 'yes')
or exit 0;
innodb_send_changes_email($cset, $changes)
or exit 1;
exit 0;

View File

@ -1,30 +0,0 @@
#! /usr/bin/perl
use strict;
use warnings;
use FindBin;
require "$FindBin::Bin/triggers-lib.pl";
# Don't run unless push/pull was successful
check_status() or exit 0;
# Don't run if push/pull is in local clones
exit 0 if repository_type() eq 'local';
# For each pushed ChangeSet, check it for InnoDB files and send
# diff of entire ChangeSet to InnoDB developers if such changes
# exist.
my $error = 0;
foreach my $cset (read_bk_csetlist())
{
my $changes = innodb_get_changes('cset', $cset, 'yes')
or next;
innodb_send_changes_email($cset, $changes)
or $error = 1;
}
exit ($error == 0 ? 0 : 1);

View File

@ -1,22 +0,0 @@
#!/bin/sh
if [ "$BK_USER" = "Administrator" -o "$BK_USER" = "mysqldev" ]
then
echo "Error: you cannot commit as 'Administrator' or 'mysqldev' user."
echo "as a workaround set BK_USER to your nickname"
echo "e.g.: export BK_USER='bar'"
echo ""
echo "Checkin FAILED!"
echo "Set BK_USER and retry."
exit 1
fi
if [ "$REAL_EMAIL" = "" ]
then
echo "Error: you must set REAL_EMAIL in your profile"
echo "e.g.: export REAL_EMAIL='Joe Dow <joe@foo.bar>'"
echo ""
echo "Commit FAILED!"
echo "Set REAL_EMAIL and retry."
exit 1
fi

View File

@ -1,26 +0,0 @@
#!/usr/bin/perl
my $status = 0;
my $pending = $ENV{'BK_PENDING'};
exit 0 unless -f $pending;
open FI, "<", $pending || exit 0;
while(<FI>) {
my ($file, $stuff) = split /\|/, $_, 2;
next unless -f $file;
$file =~ s/^(.*)\/([^\/]*)$/$2/;
my $path = $1;
opendir DIR, $path;
my @files = sort map { lc } readdir DIR;
closedir DIR;
my %count = ();
$count{$_}++ for @files;
@files = grep { $count{$_} > 1 } keys %count;
if(@files > 0) {
print "$path/$file: duplicate file names: " . (join " ", @files) . "\n";
$status = 1;
}
}
close FI;
exit $status;

View File

@ -1,21 +0,0 @@
#! /usr/bin/perl
use strict;
use warnings;
use FindBin;
require "$FindBin::Bin/triggers-lib.pl";
die "$0: Script error: \$BK_PENDING is not set in pre-commit trigger\n"
unless defined $ENV{BK_PENDING};
# Read changed files from $BK_PENDING directly. Do not bother user about
# merge changes; they don't have any choice, the merge must be done.
my $changes = innodb_get_changes('file', $ENV{BK_PENDING}, undef)
or exit 0;
innodb_inform_and_query_user($changes)
or exit 1; # Abort commit
# OK, continue with commit
exit 0;

View File

@ -1,22 +0,0 @@
#!/bin/sh
if [ "$BK_USER" = "Administrator" -o "$BK_USER" = "mysqldev" ]
then
echo "Error: you cannot checkin as 'Administrator' or 'mysqldev' user."
echo "as a workaround set BK_USER to your nickname"
echo "e.g.: export BK_USER='bar'"
echo ""
echo "Checkin FAILED!"
echo "Set BK_USER and retry."
exit 1
fi
if [ `tail -c1 $BK_FILE` ]
then
echo "File $BK_FILE does not end with a new-line character!"
echo ""
echo "Checkin FAILED!"
echo "Fix the problem and retry."
exit 1
fi

View File

@ -1,82 +0,0 @@
#! /usr/bin/perl
use strict;
use warnings;
my $event= $ENV{BK_EVENT};
unless($event eq 'outgoing pull' || $event eq 'outgoing push' ||
$event eq 'resolve') {
exit 0;
}
my @bad_csets=
( 'monty@mysql.com|ChangeSet|20060418090255|16983',
'monty@mysql.com|ChangeSet|20060418090458|02628',
'monty@mysql.com|ChangeSet|20060419084236|49576',
'monty@mysql.com|ChangeSet|20060503164655|51444',
'monty@mysql.com|ChangeSet|20060503225814|60133',
'monty@mysql.com|ChangeSet|20060504033006|54878',
'monty@mysql.com|ChangeSet|20060504130520|48660',
'monty@mysql.com|ChangeSet|20060504164102|03511',
'monty@mysql.com|ChangeSet|20060504193112|04109',
'monty@mysql.com|ChangeSet|20060505015314|02799',
'monty@mysql.com|ChangeSet|20060505084007|16704',
'monty@mysql.com|ChangeSet|20060505104008|16695',
'monty@mysql.com|ChangeSet|20060505171041|13924',
'monty@mysql.com|ChangeSet|20060508121933|13866',
'monty@mysql.com|ChangeSet|20060508160902|15029',
'monty@mysql.com|ChangeSet|20060509145448|38636',
'monty@mysql.com|ChangeSet|20060509224111|40037',
'monty@mysql.com|ChangeSet|20060510090758|40678',
'monty@mysql.com|ChangeSet|20060515164104|46760',
'monty@mysql.com|ChangeSet|20060530114549|35852',
'monty@mysql.com|ChangeSet|20060605032828|23579',
'monty@mysql.com|ChangeSet|20060605033011|10641',
'monty@mysql.com|ChangeSet|20060605060652|09843',
'msvensson@neptunus.(none)|ChangeSet|20060605094744|10838',
'msvensson@neptunus.(none)|ChangeSet|20060605105746|11800',
'msvensson@neptunus.(none)|ChangeSet|20060605122345|12772',
'jmiller@mysql.com|ChangeSet|20060531210831|36442',
'jmiller@mysql.com|ChangeSet|20060602151941|36118',
'jmiller@mysql.com|ChangeSet|20060602152136|27762',
'jmiller@mysql.com|ChangeSet|20060605121748|12864',
'jmiller@mysql.com|ChangeSet|20060605160304|14798',
'jimw@mysql.com|ChangeSet|20060605210201|14667',
'igor@rurik.mysql.com|ChangeSet|20060605220727|15265',
'igor@rurik.mysql.com|ChangeSet|20060605221206|15134',
'stewart@mysql.com|ChangeSet|20060525073521|11169',
'stewart@mysql.com|ChangeSet|20060605154220|12975',
'stewart@mysql.com|ChangeSet|20060606040001|15337',
'hartmut@mysql.com/linux.site|ChangeSet|20070413121444|50289'
);
# Read the list of changesets.
my $csetlist = $ENV{BK_CSETLIST};
if(!defined($csetlist) || !open(FH, '<', $csetlist)) {
die "Failed to open list of incoming changesets '$csetlist': $!.\n";
}
my @csets = <FH>;
close FH;
# Reject any attempt to push/pull a bad changeset.
for my $cs (@csets) {
# Do this the raw way, don't want to be bitten by different EOL conventions
# on server and client (Unix/Windows/Mac).
$cs =~ s/\x0d?\x0a?$//s;
if(grep($_ eq $cs, @bad_csets)) {
print <<END;
BAD CHANGESET DETECTED! $event REJECTED!
The changeset with key '$cs' was detected in the attempted push or pull.
This changeset is from the corrupt part of the crashed mysql-5.1-new tree.
Pushing or pulling this changeset would result in corruption of the new tree,
and therefore the operation has been rejected.
Contact Kristian Nielsen (knielsen\@mysql.com, IRC knielsen) if you have any
questions regarding this.
END
exit 1;
}
}
exit 0;

View File

@ -1,82 +0,0 @@
#! /usr/bin/perl
use strict;
use warnings;
my $event= $ENV{BK_EVENT};
unless($event eq 'outgoing pull' || $event eq 'outgoing push' ||
$event eq 'resolve') {
exit 0;
}
my @bad_csets=
( 'monty@mysql.com|ChangeSet|20060418090255|16983',
'monty@mysql.com|ChangeSet|20060418090458|02628',
'monty@mysql.com|ChangeSet|20060419084236|49576',
'monty@mysql.com|ChangeSet|20060503164655|51444',
'monty@mysql.com|ChangeSet|20060503225814|60133',
'monty@mysql.com|ChangeSet|20060504033006|54878',
'monty@mysql.com|ChangeSet|20060504130520|48660',
'monty@mysql.com|ChangeSet|20060504164102|03511',
'monty@mysql.com|ChangeSet|20060504193112|04109',
'monty@mysql.com|ChangeSet|20060505015314|02799',
'monty@mysql.com|ChangeSet|20060505084007|16704',
'monty@mysql.com|ChangeSet|20060505104008|16695',
'monty@mysql.com|ChangeSet|20060505171041|13924',
'monty@mysql.com|ChangeSet|20060508121933|13866',
'monty@mysql.com|ChangeSet|20060508160902|15029',
'monty@mysql.com|ChangeSet|20060509145448|38636',
'monty@mysql.com|ChangeSet|20060509224111|40037',
'monty@mysql.com|ChangeSet|20060510090758|40678',
'monty@mysql.com|ChangeSet|20060515164104|46760',
'monty@mysql.com|ChangeSet|20060530114549|35852',
'monty@mysql.com|ChangeSet|20060605032828|23579',
'monty@mysql.com|ChangeSet|20060605033011|10641',
'monty@mysql.com|ChangeSet|20060605060652|09843',
'msvensson@neptunus.(none)|ChangeSet|20060605094744|10838',
'msvensson@neptunus.(none)|ChangeSet|20060605105746|11800',
'msvensson@neptunus.(none)|ChangeSet|20060605122345|12772',
'jmiller@mysql.com|ChangeSet|20060531210831|36442',
'jmiller@mysql.com|ChangeSet|20060602151941|36118',
'jmiller@mysql.com|ChangeSet|20060602152136|27762',
'jmiller@mysql.com|ChangeSet|20060605121748|12864',
'jmiller@mysql.com|ChangeSet|20060605160304|14798',
'jimw@mysql.com|ChangeSet|20060605210201|14667',
'igor@rurik.mysql.com|ChangeSet|20060605220727|15265',
'igor@rurik.mysql.com|ChangeSet|20060605221206|15134',
'stewart@mysql.com|ChangeSet|20060525073521|11169',
'stewart@mysql.com|ChangeSet|20060605154220|12975',
'stewart@mysql.com|ChangeSet|20060606040001|15337',
'hartmut@mysql.com/linux.site|ChangeSet|20070413121444|50289'
);
# Read the list of changesets.
my $csetlist = $ENV{BK_CSETLIST};
if(!defined($csetlist) || !open(FH, '<', $csetlist)) {
die "Failed to open list of incoming changesets '$csetlist': $!.\n";
}
my @csets = <FH>;
close FH;
# Reject any attempt to push/pull a bad changeset.
for my $cs (@csets) {
# Do this the raw way, don't want to be bitten by different EOL conventions
# on server and client (Unix/Windows/Mac).
$cs =~ s/\x0d?\x0a?$//s;
if(grep($_ eq $cs, @bad_csets)) {
print <<END;
BAD CHANGESET DETECTED! $event REJECTED!
The changeset with key '$cs' was detected in the attempted push or pull.
This changeset is from the corrupt part of the crashed mysql-5.1-new tree.
Pushing or pulling this changeset would result in corruption of the new tree,
and therefore the operation has been rejected.
Contact Kristian Nielsen (knielsen\@mysql.com, IRC knielsen) if you have any
questions regarding this.
END
exit 1;
}
}
exit 0;

View File

@ -1,356 +0,0 @@
# To use this convenience library in a trigger, simply require it at
# at the top of the script. For example:
#
# #! /usr/bin/perl
#
# use FindBin;
# require "$FindBin::Bin/triggers-lib.pl";
#
# FindBin is needed, because sometimes a trigger is called from the
# RESYNC directory, and the trigger dir is ../BitKeeper/triggers
use strict;
use warnings;
use Carp;
use FindBin;
my $mysql_version = "5.1";
# These addresses must be kept current in all MySQL versions.
# See the wiki page InnoDBandOracle.
#my @innodb_to_email = ('dev_innodb_ww@oracle.com');
#my @innodb_cc_email = ('dev-innodb@mysql.com');
# FIXME: Keep this for testing; remove it once it's been used for a
# week or two.
my @innodb_to_email = ('tim@mysql.com');
my @innodb_cc_email = ();
# This is for MySQL >= 5.1. Regex which defines the InnoDB files
# which should generally not be touched by MySQL developers.
my $innodb_files_description = <<EOF;
storage/innobase/*
mysql-test/t/innodb* (except mysql-test/t/innodb_mysql*)
mysql-test/r/innodb* (except mysql-test/r/innodb_mysql*)
EOF
my $innodb_files_regex = qr{
^
(
# Case 1: innobase/*
storage/innobase/
|
# Case 2: mysql-test/[tr]/innodb* (except innodb_mysql*)
mysql-test/(t|r)/SCCS/s.innodb
# The mysql-test/[tr]/innodb_mysql* are OK to edit
(?!_mysql)
)
}x;
# See 'bk help log', and the format of, e.g., $BK_PENDING.
# Important: this already contains the terminating newline!
my $file_rev_dspec = ':SFILE:|:REV:\n';
my $bktmp = "$FindBin::Bin/../tmp";
my $sendmail;
foreach ('/usr/sbin/sendmail', 'sendmail') {
$sendmail = $_;
last if -x $sendmail;
}
my $from = $ENV{REAL_EMAIL} || $ENV{USER} . '@mysql.com';
# close_or_warn
# $fh file handle to be closed
# $description description of the file handle
# RETURN Return value of close($fh)
#
# Print a nice warning message if close() isn't successful. See
# perldoc perlvar and perldoc -f close for details.
sub close_or_warn (*$)
{
my ($fh, $description) = @_;
my $status = close $fh;
if (not $status) {
warn "$0: error on close of '$description': ",
($! ? "$!" : "exit status " . ($? >> 8)), "\n";
}
return $status;
}
# check_status
# $warn If true, warn about bad status
# RETURN TRUE, if $BK_STATUS is "OK"; FALSE otherwise
#
# Also checks the undocumented $BK_COMMIT env variable
sub check_status
{
my ($warn) = @_;
my $status = (grep { defined $_ }
$ENV{BK_STATUS}, $ENV{BK_COMMIT}, '<undef>')[0];
unless ($status eq 'OK')
{
warn "Bad BK_STATUS '$status'\n" if $warn;
return undef;
}
return 1;
}
# repository_location
#
# RETURN ('HOST', 'ROOT') for the repository being modified
sub repository_location
{
if ($ENV{BK_SIDE} eq 'client') {
return ($ENV{BK_HOST}, $ENV{BK_ROOT});
} else {
return ($ENV{BKD_HOST}, $ENV{BKD_ROOT});
}
}
# repository_type
# RETURN:
# 'main' for repo on bk-internal with post-incoming.bugdb trigger
# 'team' for repo on bk-internal with post-incoming.queuepush.pl trigger
# 'local' otherwise
#
# This definition may need to be modified if the host name or triggers change.
sub repository_type
{
my ($host, $root) = repository_location();
return 'local'
unless uc($host) eq 'BK-INTERNAL.MYSQL.COM'
and -e "$root/BitKeeper/triggers/post-incoming.queuepush.pl";
return 'main' if -e "$root/BitKeeper/triggers/post-incoming.bugdb";
return 'team';
}
# latest_cset
# RETURN Key for most recent ChangeSet
sub latest_cset {
chomp(my $retval = `bk changes -r+ -k`);
return $retval;
}
# read_bk_csetlist
# RETURN list of cset keys from $BK_CSETLIST file
sub read_bk_csetlist
{
die "$0: script error: \$BK_CSETLIST not set\n"
unless defined $ENV{BK_CSETLIST};
open CSETS, '<', $ENV{BK_CSETLIST}
or die "$0: can't read \$BK_CSETLIST='$ENV{BK_CSETLIST}': $!\n";
chomp(my @csets = <CSETS>);
close_or_warn(CSETS, "\$BK_CSETLIST='$ENV{BK_CSETLIST}'");
return @csets;
}
# innodb_get_changes
# $type 'file' or 'cset'
# $value file name (e.g., $BK_PENDING) or ChangeSet key
# $want_merge_changes flag; if false, merge changes will be ignored
# RETURN A string describing the InnoDB changes, or undef if no changes
#
# The return value does *not* include ChangeSet comments, only per-file
# comments.
sub innodb_get_changes
{
my ($type, $value, $want_merge_changes) = @_;
if ($type eq 'file')
{
open CHANGES, '<', $value
or die "$0: can't read '$value': $!\n";
}
elsif ($type eq 'cset')
{
open CHANGES, '-|', "bk changes -r'$value' -v -d'$file_rev_dspec'"
or die "$0: can't exec 'bk changes': $!\n";
}
else
{
croak "$0: script error: invalid type '$type'";
}
my @changes = grep { /$innodb_files_regex/ } <CHANGES>;
close_or_warn(CHANGES, "($type, '$value')");
return undef unless @changes;
# Set up a pipeline of 'bk log' commands to weed out unwanted deltas. We
# never want deltas which contain no actual changes. We may not want deltas
# which are merges.
my @filters;
# This tests if :LI: (lines inserted) or :LD: (lines deleted) is
# non-zero. That is, did this delta change the file contents?
push @filters,
"bk log -d'"
. "\$if(:LI: -gt 0){$file_rev_dspec}"
. "\$if(:LI: -eq 0){\$if(:LD: -gt 0){$file_rev_dspec}}"
. "' -";
push @filters, "bk log -d'\$unless(:MERGE:){$file_rev_dspec}' -"
unless $want_merge_changes;
my $tmpname = "$bktmp/ibchanges.txt";
my $pipeline = join(' | ', @filters) . " > $tmpname";
open TMP, '|-', $pipeline
or die "$0: can't exec [[$pipeline]]: $!\n";
print TMP @changes;
close_or_warn(TMP, "| $pipeline");
# Use bk log to describe the changes
open LOG, "bk log - < $tmpname |"
or die "$0: can't exec 'bk log - < $tmpname': $!\n";
my @log = <LOG>;
close_or_warn(LOG, "bk log - < $tmpname |");
unlink $tmpname;
return undef unless @log;
return join('', @log);
}
# Ask user if they really want to commit.
# RETURN TRUE = YES, commit; FALSE = NO, do not commit
sub innodb_inform_and_query_user
{
my ($description) = @_;
my $tmpname = "$bktmp/ibquery.txt";
open MESSAGE, "> $tmpname"
or die "$0: can't write message to '$tmpname': $!";
print MESSAGE <<EOF;
This ChangeSet modifies some files which should normally be changed by
InnoDB developers only. In general, MySQL developers should not change:
$innodb_files_description
The following InnoDB files were modified:
=========================================================
$description
=========================================================
If you understand this, you may Commit these changes. The changes
will be sent to the InnoDB developers at @{[join ', ', @innodb_to_email]},
CC @{[join ', ', @innodb_cc_email]}.
EOF
close_or_warn(MESSAGE, "$tmpname");
my $status = system('bk', 'prompt', '-w',
'-yCommit these changes', '-nDo not Commit', "-f$tmpname");
unlink $tmpname;
return ($status == 0 ? 1 : undef);
}
# innodb_send_changes_email
# $cset The ChangeSet key
# $description A (maybe brief) description of the changes
# RETURN TRUE = Success, e-mail sent; FALSE = Failure
#
# Sends a complete diff of changes in $cset by e-mail.
sub innodb_send_changes_email
{
my ($cset, $description) = @_;
# FIXME: Much of this is duplicated in the 'post-commit' Bourne shell
# trigger
my $cset_short = `bk changes -r'$cset' -d':P:::I:'`;
my $cset_key = `bk changes -r'$cset' -d':KEY:'`;
my ($host, $bk_root) = repository_location();
my $type = repository_type();
(my $treename = $bk_root) =~ s,^.*/,,;
print "Nofifying InnoDB developers at ",
(join ', ', @innodb_to_email, @innodb_cc_email), "\n";
open SENDMAIL, '|-', "$sendmail -t"
or die "Can't exec '$sendmail -t': $!\n";
my @headers;
push @headers, "List-ID: <bk.innodb-$mysql_version>";
push @headers, "From: $from";
push @headers, "To: " . (join ', ', @innodb_to_email);
push @headers, "Cc: " . (join ', ', @innodb_cc_email) if @innodb_cc_email;
push @headers,
"Subject: InnoDB changes in $type $mysql_version tree ($cset_short)";
push @headers, "X-CSetKey: <$cset_key>";
print SENDMAIL map { "$_\n" } @headers, '';
if ($type eq 'main')
{
print SENDMAIL <<EOF;
Changes pushed to $treename by $ENV{USER} affect the following
files. These changes are in a $mysql_version main tree. They
will be available publicly within 24 hours.
EOF
}
elsif ($type eq 'team')
{
print SENDMAIL <<EOF;
Changes added to $treename by $ENV{USER} affect the
following files. These changes are in a $mysql_version team tree.
EOF
}
else
{
print SENDMAIL <<EOF;
A local commit by $ENV{USER} affects the following files. These
changes are in a clone of a $mysql_version tree.
EOF
}
print SENDMAIL "\n";
print SENDMAIL qx(bk changes -r'$cset');
print SENDMAIL "$description";
print SENDMAIL "The complete ChangeSet diffs follow.\n\n";
print SENDMAIL qx(bk rset -r'$cset' -ah | bk gnupatch -h -dup -T);
close_or_warn(SENDMAIL, "$sendmail -t")
or return undef;
return 1;
}
1;

View File

@ -1,4 +1,4 @@
# Copyright (C) 2006 MySQL AB
# Copyright (C) 2006 MySQL AB, 2009 Sun Microsystems, Inc
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -39,6 +39,9 @@ ADD_DEFINITIONS(-DDEFAULT_CHARSET_HOME="c:/Program Files/MySQL/MySQL Server ${MY
ADD_DEFINITIONS(-DPACKAGE=mysql)
ADD_DEFINITIONS(-DSHAREDIR="share")
# Enable IPv6 handling code
ADD_DEFINITIONS(-DHAVE_IPV6)
# Set debug options
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DFORCE_INIT_OF_VARS")
@ -284,13 +287,23 @@ CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/sql/sql_builtin.cc.in
SET (ENGINE_BUILD_TYPE "STATIC")
FOREACH(DIR ${STATIC_ENGINE_DIRECTORIES})
ADD_SUBDIRECTORY(${DIR})
IF(EXISTS ${DIR}/unittest)
ADD_SUBDIRECTORY(${DIR}/unittest)
ENDIF(EXISTS ${DIR}/unittest)
ENDFOREACH(DIR ${STATIC_ENGINE_DIRECTORIES})
SET (ENGINE_BUILD_TYPE "DYNAMIC")
FOREACH(DIR ${DYNAMIC_ENGINE_DIRECTORIES})
IF(EXISTS ${DIR}/unittest)
ADD_SUBDIRECTORY(${DIR}/unittest)
ENDIF(EXISTS ${DIR}/unittest)
ADD_SUBDIRECTORY(${DIR})
ENDFOREACH(DIR ${DYNAMIC_ENGINE_DIRECTORIES})
# Add subdirectories for semisync plugin
IF(NOT WITHOUT_DYNAMIC_PLUGINS)
ADD_SUBDIRECTORY(plugin/semisync)
ENDIF(NOT WITHOUT_DYNAMIC_PLUGINS)
# FIXME "debug" only needed if build type is "Debug", but
# CMAKE_BUILD_TYPE is not set during configure time.
@ -307,7 +320,11 @@ ADD_SUBDIRECTORY(extra)
ADD_SUBDIRECTORY(client)
ADD_SUBDIRECTORY(sql)
ADD_SUBDIRECTORY(libmysql)
ADD_SUBDIRECTORY(libservices)
ADD_SUBDIRECTORY(tests)
ADD_SUBDIRECTORY(unittest/mytap)
ADD_SUBDIRECTORY(unittest/examples)
ADD_SUBDIRECTORY(unittest/mysys)
IF(WITH_EMBEDDED_SERVER)
ADD_SUBDIRECTORY(libmysqld)
ADD_SUBDIRECTORY(libmysqld/examples)

View File

@ -1,5 +0,0 @@
INSTALL-SOURCE
INSTALL-BINARY
Makefile
Makefile.in
mysql.info

View File

@ -23,7 +23,7 @@ EXTRA_DIST = INSTALL-SOURCE INSTALL-WIN-SOURCE \
SUBDIRS = . include @docs_dirs@ @zlib_dir@ \
@readline_topdir@ sql-common scripts \
@pstack_dir@ \
@pstack_dir@ libservices \
@sql_union_dirs@ unittest \
@sql_server@ @man_dirs@ tests \
netware @libmysqld_dirs@ \
@ -32,7 +32,7 @@ SUBDIRS = . include @docs_dirs@ @zlib_dir@ \
DIST_SUBDIRS = . include Docs zlib \
cmd-line-utils sql-common scripts \
pstack \
pstack libservices \
strings mysys dbug extra regex libmysql libmysql_r client unittest storage plugin \
vio sql man tests \
netware libmysqld \
@ -98,7 +98,8 @@ test-pr:
test-ns:
cd mysql-test ; \
@PERL@ ./mysql-test-run.pl $(force) $(mem) --mysqld=--binlog-format=mixed
@PERL@ ./mysql-test-run.pl $(force) $(mem) --mysqld=--binlog-format=mixed ; \
@PERL@ ./mysql-test-run.pl $(force) $(mem) --suite=funcs_1
test-binlog-statement:
cd mysql-test ; \
@ -205,6 +206,8 @@ test-bt-debug:
test-bt-debug-fast:
test-bt-debug-fast:
# Keep these for a while
test-pl: test
test-full-pl: test-full
@ -262,11 +265,12 @@ test-full-qa:
#
API_PREPROCESSOR_HEADER = $(top_srcdir)/include/mysql/plugin.h \
$(top_srcdir)/include/mysql.h
$(top_srcdir)/include/mysql.h \
$(top_srcdir)/include/mysql/psi/psi_abi_v1.h \
$(top_srcdir)/include/mysql/psi/psi_abi_v2.h
TEST_PREPROCESSOR_HEADER = $(top_srcdir)/include/mysql/plugin.h \
$(top_srcdir)/sql/mysql_priv.h \
$(top_srcdir)/include/mysql.h
TEST_PREPROCESSOR_HEADER = $(API_PREPROCESSOR_HEADER) \
$(top_srcdir)/sql/mysql_priv.h
#
# Rules for checking that the abi/api has not changed.

View File

@ -1,14 +0,0 @@
.deps
.libs
Makefile
Makefile.in
insert_test
mysql
mysql-test
mysql_test
mysqladmin
mysqldump
mysqlimport
mysqlshow
select_test
thread_test

View File

@ -62,6 +62,9 @@ enum options_client
OPT_MYSQL_NUMBER_OF_QUERY,
OPT_IGNORE_TABLE,OPT_INSERT_IGNORE,OPT_SHOW_WARNINGS,OPT_DROP_DATABASE,
OPT_TZ_UTC, OPT_AUTO_CLOSE, OPT_CREATE_SLAP_SCHEMA,
OPT_MYSQLDUMP_SLAVE_APPLY,
OPT_MYSQLDUMP_SLAVE_DATA,
OPT_MYSQLDUMP_INCLUDE_MASTER_HOST_PORT,
OPT_SLAP_CSV, OPT_SLAP_CREATE_STRING,
OPT_SLAP_AUTO_GENERATE_SQL_LOAD_TYPE, OPT_SLAP_AUTO_GENERATE_WRITE_NUM,
OPT_SLAP_AUTO_GENERATE_ADD_AUTO,
@ -78,6 +81,7 @@ enum options_client
OPT_SLAP_DETACH,
OPT_MYSQL_REPLACE_INTO, OPT_BASE64_OUTPUT_MODE, OPT_SERVER_ID,
OPT_FIX_TABLE_NAMES, OPT_FIX_DB_NAMES, OPT_SSL_VERIFY_SERVER_CERT,
OPT_AUTO_VERTICAL_OUTPUT,
OPT_DEBUG_INFO, OPT_DEBUG_CHECK, OPT_COLUMN_TYPES, OPT_ERROR_LOG_FILE,
OPT_WRITE_BINLOG, OPT_DUMP_DATE,
OPT_INIT_COMMAND,

View File

@ -1,3 +1,6 @@
#ifndef CLIENT_MY_READLINE_INCLUDED
#define CLIENT_MY_READLINE_INCLUDED
/* Copyright (C) 2000 MySQL AB
This program is free software; you can redistribute it and/or modify
@ -31,3 +34,5 @@ extern LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file);
extern LINE_BUFFER *batch_readline_command(LINE_BUFFER *buffer, char * str);
extern char *batch_readline(LINE_BUFFER *buffer, bool *truncated);
extern void batch_readline_end(LINE_BUFFER *buffer);
#endif /* CLIENT_MY_READLINE_INCLUDED */

View File

@ -141,8 +141,9 @@ static my_bool ignore_errors=0,wait_flag=0,quick=0,
vertical=0, line_numbers=1, column_names=1,opt_html=0,
opt_xml=0,opt_nopager=1, opt_outfile=0, named_cmds= 0,
tty_password= 0, opt_nobeep=0, opt_reconnect=1,
default_charset_used= 0, opt_secure_auth= 0,
opt_secure_auth= 0,
default_pager_set= 0, opt_sigint_ignore= 0,
auto_vertical_output= 0,
show_warnings= 0, executing_query= 0, interrupted_query= 0,
ignore_spaces= 0;
static my_bool debug_info_flag, debug_check_flag;
@ -155,7 +156,7 @@ static char * opt_mysql_unix_port=0;
static int connect_flag=CLIENT_INTERACTIVE;
static char *current_host,*current_db,*current_user=0,*opt_password=0,
*current_prompt=0, *delimiter_str= 0,
*default_charset= (char*) MYSQL_DEFAULT_CHARSET_NAME,
*default_charset= (char*) MYSQL_AUTODETECT_CHARSET_NAME,
*opt_init_command= 0;
static char *histfile;
static char *histfile_tmp;
@ -185,6 +186,7 @@ static MEM_ROOT hash_mem_root;
static uint prompt_counter;
static char delimiter[16]= DEFAULT_DELIMITER;
static uint delimiter_length= 1;
unsigned short terminal_width= 80;
#ifdef HAVE_SMEM
static char *shared_memory_base_name=0;
@ -238,6 +240,8 @@ static const char* construct_prompt();
static char *get_arg(char *line, my_bool get_next_arg);
static void init_username();
static void add_int_to_prompt(int toadd);
static int get_result_width(MYSQL_RES *res);
static int get_field_disp_length(MYSQL_FIELD * field);
/* A structure which contains information on the commands this program
can understand. */
@ -1065,6 +1069,10 @@ static void mysql_end_timer(ulong start_time,char *buff);
static void nice_time(double sec,char *buff,bool part_second);
extern "C" sig_handler mysql_end(int sig);
extern "C" sig_handler handle_sigint(int sig);
#if defined(HAVE_TERMIOS_H) && defined(GWINSZ_IN_SYS_IOCTL)
static sig_handler window_resize(int sig);
#endif
int main(int argc,char *argv[])
{
@ -1114,7 +1122,11 @@ int main(int argc,char *argv[])
close(stdout_fileno_copy); /* Clean up dup(). */
}
load_defaults("my",load_default_groups,&argc,&argv);
if (load_defaults("my",load_default_groups,&argc,&argv))
{
my_end(0);
exit(1);
}
defaults_argv=argv;
if (get_options(argc, (char **) argv))
{
@ -1144,8 +1156,8 @@ int main(int argc,char *argv[])
if (sql_connect(current_host,current_db,current_user,opt_password,
opt_silent))
{
quick=1; // Avoid history
status.exit_status=1;
quick= 1; // Avoid history
status.exit_status= 1;
mysql_end(-1);
}
if (!status.batch)
@ -1157,6 +1169,13 @@ int main(int argc,char *argv[])
signal(SIGINT, handle_sigint); // Catch SIGINT to clean up
signal(SIGQUIT, mysql_end); // Catch SIGQUIT to clean up
#if defined(HAVE_TERMIOS_H) && defined(GWINSZ_IN_SYS_IOCTL)
/* Readline will call this if it installs a handler */
signal(SIGWINCH, window_resize);
/* call the SIGWINCH handler to get the default term width */
window_resize(0);
#endif
put_info("Welcome to the MySQL monitor. Commands end with ; or \\g.",
INFO_INFO);
sprintf((char*) glob_buffer.ptr(),
@ -1281,21 +1300,35 @@ sig_handler handle_sigint(int sig)
MYSQL *kill_mysql= NULL;
/* terminate if no query being executed, or we already tried interrupting */
if (!executing_query || interrupted_query)
/* terminate if no query being executed, or we already tried interrupting */
if (!executing_query || (interrupted_query == 2))
{
tee_fprintf(stdout, "Ctrl-C -- exit!\n");
goto err;
}
kill_mysql= mysql_init(kill_mysql);
if (!mysql_real_connect(kill_mysql,current_host, current_user, opt_password,
"", opt_mysql_port, opt_mysql_unix_port,0))
{
tee_fprintf(stdout, "Ctrl-C -- sorry, cannot connect to server to kill query, giving up ...\n");
goto err;
}
interrupted_query++;
/* mysqld < 5 does not understand KILL QUERY, skip to KILL CONNECTION */
if ((interrupted_query == 1) && (mysql_get_server_version(&mysql) < 50000))
interrupted_query= 2;
/* kill_buffer is always big enough because max length of %lu is 15 */
sprintf(kill_buffer, "KILL /*!50000 QUERY */ %lu", mysql_thread_id(&mysql));
mysql_real_query(kill_mysql, kill_buffer, strlen(kill_buffer));
sprintf(kill_buffer, "KILL %s%lu",
(interrupted_query == 1) ? "QUERY " : "",
mysql_thread_id(&mysql));
tee_fprintf(stdout, "Ctrl-C -- sending \"%s\" to server ...\n", kill_buffer);
mysql_real_query(kill_mysql, kill_buffer, (uint) strlen(kill_buffer));
mysql_close(kill_mysql);
tee_fprintf(stdout, "Query aborted by Ctrl+C\n");
interrupted_query= 1;
tee_fprintf(stdout, "Ctrl-C -- query aborted.\n");
return;
@ -1315,6 +1348,16 @@ err:
}
#if defined(HAVE_TERMIOS_H) && defined(GWINSZ_IN_SYS_IOCTL)
sig_handler window_resize(int sig)
{
struct winsize window_size;
if (ioctl(fileno(stdin), TIOCGWINSZ, &window_size) == 0)
terminal_width= window_size.ws_col;
}
#endif
static struct my_option my_long_options[] =
{
{"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0,
@ -1332,6 +1375,9 @@ static struct my_option my_long_options[] =
{"no-auto-rehash", 'A',
"No automatic rehashing. One has to use 'rehash' to get table and field completion. This gives a quicker start of mysql and disables rehashing on reconnect. WARNING: options deprecated; use --disable-auto-rehash instead.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"auto-vertical-output", OPT_AUTO_VERTICAL_OUTPUT,
"Automatically switch to vertical output mode if the result is wider than the terminal width.",
(uchar**) &auto_vertical_output, (uchar**) &auto_vertical_output, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"batch", 'B',
"Don't use history file. Disable interactive behavior. (Enables --silent)", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"character-sets-dir", OPT_CHARSETS_DIR,
@ -1581,9 +1627,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
strmake(mysql_charsets_dir, argument, sizeof(mysql_charsets_dir) - 1);
charsets_dir = mysql_charsets_dir;
break;
case OPT_DEFAULT_CHARSET:
default_charset_used= 1;
break;
case OPT_DELIMITER:
if (argument == disabled_my_option)
{
@ -1788,10 +1831,6 @@ static int get_options(int argc, char **argv)
connect_flag= 0; /* Not in interactive mode */
}
if (strcmp(default_charset, charset_info->csname) &&
!(charset_info= get_charset_by_csname(default_charset,
MY_CS_PRIMARY, MYF(MY_WME))))
exit(1);
if (argc > 1)
{
usage(0);
@ -2919,7 +2958,6 @@ com_charset(String *buffer __attribute__((unused)), char *line)
charset_info= new_cs;
mysql_set_character_set(&mysql, charset_info->csname);
default_charset= (char *)charset_info->csname;
default_charset_used= 1;
put_info("Charset changed", INFO_INFO);
}
else put_info("Charset is not found", INFO_INFO);
@ -3046,7 +3084,7 @@ com_go(String *buffer,char *line __attribute__((unused)))
print_table_data_html(result);
else if (opt_xml)
print_table_data_xml(result);
else if (vertical)
else if (vertical || (auto_vertical_output && (terminal_width < get_result_width(result))))
print_table_data_vertically(result);
else if (opt_silent && verbose <= 2 && !output_tables)
print_tab_data(result);
@ -3377,6 +3415,65 @@ print_table_data(MYSQL_RES *result)
my_afree((uchar*) num_flag);
}
/**
Return the length of a field after it would be rendered into text.
This doesn't know or care about multibyte characters. Assume we're
using such a charset. We can't know that all of the upcoming rows
for this column will have bytes that each render into some fraction
of a character. It's at least possible that a row has bytes that
all render into one character each, and so the maximum length is
still the number of bytes. (Assumption 1: This can't be better
because we can never know the number of characters that the DB is
going to send -- only the number of bytes. 2: Chars <= Bytes.)
@param field Pointer to a field to be inspected
@returns number of character positions to be used, at most
*/
static int get_field_disp_length(MYSQL_FIELD *field)
{
uint length= column_names ? field->name_length : 0;
if (quick)
length= max(length, field->length);
else
length= max(length, field->max_length);
if (length < 4 && !IS_NOT_NULL(field->flags))
length= 4; /* Room for "NULL" */
return length;
}
/**
For a new result, return the max number of characters that any
upcoming row may return.
@param result Pointer to the result to judge
@returns The max number of characters in any row of this result
*/
static int get_result_width(MYSQL_RES *result)
{
unsigned int len= 0;
MYSQL_FIELD *field;
MYSQL_FIELD_OFFSET offset;
#ifndef DBUG_OFF
offset= mysql_field_tell(result);
DBUG_ASSERT(offset == 0);
#else
offset= 0;
#endif
while ((field= mysql_fetch_field(result)) != NULL)
len+= get_field_disp_length(field) + 3; /* plus bar, space, & final space */
(void) mysql_field_seek(result, offset);
return len + 1; /* plus final bar. */
}
static void
tee_print_sized_data(const char *data, unsigned int data_length, unsigned int total_bytes_to_send, bool right_justified)
@ -4243,8 +4340,9 @@ sql_real_connect(char *host,char *database,char *user,char *password,
select_limit,max_join_size);
mysql_options(&mysql, MYSQL_INIT_COMMAND, init_command);
}
if (default_charset_used)
mysql_options(&mysql, MYSQL_SET_CHARSET_NAME, default_charset);
mysql_options(&mysql, MYSQL_SET_CHARSET_NAME, default_charset);
if (!mysql_real_connect(&mysql, host, user, password,
database, opt_mysql_port, opt_mysql_unix_port,
connect_flag | CLIENT_MULTI_STATEMENTS))
@ -4259,6 +4357,9 @@ sql_real_connect(char *host,char *database,char *user,char *password,
}
return -1; // Retryable
}
charset_info= mysql.charset;
connected=1;
#ifndef EMBEDDED_LIBRARY
mysql.reconnect= debug_info_flag; // We want to know if this happens
@ -4328,7 +4429,7 @@ com_status(String *buffer __attribute__((unused)),
Don't remove "limit 1",
it is protection againts SQL_SELECT_LIMIT=0
*/
if (mysql_store_result_for_lazy(&result))
if (!mysql_store_result_for_lazy(&result))
{
MYSQL_ROW cur=mysql_fetch_row(result);
if (cur)
@ -4372,7 +4473,7 @@ com_status(String *buffer __attribute__((unused)),
if (mysql_errno(&mysql) == CR_SERVER_GONE_ERROR)
return 0;
}
if (mysql_store_result_for_lazy(&result))
if (!mysql_store_result_for_lazy(&result))
{
MYSQL_ROW cur=mysql_fetch_row(result);
if (cur)
@ -4467,9 +4568,7 @@ server_version_string(MYSQL *con)
*/
if (server_version == NULL)
{
server_version= strdup(mysql_get_server_info(con));
}
server_version= my_strdup(mysql_get_server_info(con), MYF(MY_WME));
}
return server_version ? server_version : "";

View File

@ -34,7 +34,8 @@
static char mysql_path[FN_REFLEN];
static char mysqlcheck_path[FN_REFLEN];
static my_bool opt_force, opt_verbose, debug_info_flag, debug_check_flag;
static my_bool opt_force, opt_verbose, debug_info_flag, debug_check_flag,
opt_systables_only;
static uint my_end_arg= 0;
static char *opt_user= (char*)"root";
@ -121,6 +122,10 @@ static struct my_option my_long_options[]=
#include <sslopt-longopts.h>
{"tmpdir", 't', "Directory for temporary files",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"upgrade-system-tables", 's', "Only upgrade the system tables "
"do not try to upgrade the data.",
(uchar**)&opt_systables_only, (uchar**)&opt_systables_only, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"user", 'u', "User for login if not current user.", (uchar**) &opt_user,
(uchar**) &opt_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"verbose", 'v', "Display more output about the process",
@ -814,7 +819,8 @@ int main(int argc, char **argv)
init_dynamic_string(&conn_args, "", 512, 256))
die("Out of memory");
load_defaults("my", load_default_groups, &argc, &argv);
if (load_defaults("my", load_default_groups, &argc, &argv))
die(NULL);
defaults_argv= argv; /* Must be freed by 'free_defaults' */
if (handle_options(&argc, &argv, my_long_options, get_one_option))
@ -838,8 +844,15 @@ int main(int argc, char **argv)
/* Find mysql */
find_tool(mysql_path, IF_WIN("mysql.exe", "mysql"), self_name);
/* Find mysqlcheck */
find_tool(mysqlcheck_path, IF_WIN("mysqlcheck.exe", "mysqlcheck"), self_name);
if (!opt_systables_only)
{
/* Find mysqlcheck */
find_tool(mysqlcheck_path, IF_WIN("mysqlcheck.exe", "mysqlcheck"), self_name);
}
else
{
printf("The --upgrade-system-tables option was used, databases won't be touched.\n");
}
/*
Read the mysql_upgrade_info file to check if mysql_upgrade
@ -856,8 +869,8 @@ int main(int argc, char **argv)
/*
Run "mysqlcheck" and "mysql_fix_privilege_tables.sql"
*/
if (run_mysqlcheck_fixnames() ||
run_mysqlcheck_upgrade() ||
if ((!opt_systables_only &&
(run_mysqlcheck_fixnames() || run_mysqlcheck_upgrade())) ||
run_sql_fix_privilege_tables())
{
/*

View File

@ -30,7 +30,7 @@
#define MAX_TRUNC_LENGTH 3
char *host= NULL, *user= 0, *opt_password= 0,
*default_charset= NULL;
*default_charset= (char*) MYSQL_AUTODETECT_CHARSET_NAME;
char truncated_var_names[MAX_MYSQL_VAR][MAX_TRUNC_LENGTH];
char ex_var_names[MAX_MYSQL_VAR][FN_REFLEN];
ulonglong last_values[MAX_MYSQL_VAR];
@ -304,7 +304,8 @@ int main(int argc,char *argv[])
MY_INIT(argv[0]);
mysql_init(&mysql);
load_defaults("my",load_default_groups,&argc,&argv);
if (load_defaults("my",load_default_groups,&argc,&argv))
exit(1);
save_argv = argv; /* Save for free_defaults */
if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
{
@ -325,8 +326,8 @@ int main(int argc,char *argv[])
if (tty_password)
opt_password = get_tty_password(NullS);
VOID(signal(SIGINT,endprog)); /* Here if abort */
VOID(signal(SIGTERM,endprog)); /* Here if abort */
(void) signal(SIGINT,endprog); /* Here if abort */
(void) signal(SIGTERM,endprog); /* Here if abort */
if (opt_compress)
mysql_options(&mysql,MYSQL_OPT_COMPRESS,NullS);
@ -348,8 +349,7 @@ int main(int argc,char *argv[])
if (shared_memory_base_name)
mysql_options(&mysql,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name);
#endif
if (default_charset)
mysql_options(&mysql, MYSQL_SET_CHARSET_NAME, default_charset);
mysql_options(&mysql, MYSQL_SET_CHARSET_NAME, default_charset);
error_flags= (myf)(opt_nobeep ? 0 : ME_BELL);
if (sql_connect(&mysql, option_wait))
@ -901,23 +901,38 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
{
char buff[128],crypted_pw[64];
time_t start_time;
char *typed_password= NULL, *verified= NULL;
/* Do initialization the same way as we do in mysqld */
start_time=time((time_t*) 0);
randominit(&rand_st,(ulong) start_time,(ulong) start_time/2);
if (argc < 2)
if (argc < 1)
{
my_printf_error(0, "Too few arguments to change password", error_flags);
return 1;
}
if (argv[1][0])
else if (argc == 1)
{
/* prompt for password */
typed_password= get_tty_password("New password: ");
verified= get_tty_password("Confirm new password: ");
if (strcmp(typed_password, verified) != 0)
{
my_printf_error(0,"Passwords don't match",MYF(ME_BELL));
return -1;
}
}
else
typed_password= argv[1];
if (typed_password[0])
{
char *pw= argv[1];
bool old= (find_type(argv[0], &command_typelib, 2) ==
ADMIN_OLD_PASSWORD);
#ifdef __WIN__
uint pw_len= (uint) strlen(pw);
if (pw_len > 1 && pw[0] == '\'' && pw[pw_len-1] == '\'')
size_t pw_len= strlen(typed_password);
if (pw_len > 1 && typed_password[0] == '\'' &&
typed_password[pw_len-1] == '\'')
printf("Warning: single quotes were not trimmed from the password by"
" your command\nline client, as you might have expected.\n");
#endif
@ -955,9 +970,9 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
}
}
if (old)
make_scrambled_password_323(crypted_pw, pw);
make_scrambled_password_323(crypted_pw, typed_password);
else
make_scrambled_password(crypted_pw, pw);
make_scrambled_password(crypted_pw, typed_password);
}
else
crypted_pw[0]=0; /* No password */
@ -992,6 +1007,12 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
return -1;
}
}
/* free up memory from prompted password */
if (typed_password != argv[1])
{
my_free(typed_password,MYF(MY_ALLOW_ZERO_PTR));
my_free(verified,MYF(MY_ALLOW_ZERO_PTR));
}
argc--; argv++;
break;
}
@ -1083,8 +1104,8 @@ static void usage(void)
kill id,id,... Kill mysql threads");
#if MYSQL_VERSION_ID >= 32200
puts("\
password new-password Change old password to new-password, MySQL 4.1 hashing.\n\
old-password new-password Change old password to new-password in old format.\n");
password [new-password] Change old password to new-password in current format\n\
old-password [new-password] Change old password to new-password in old format");
#endif
puts("\
ping Check if mysqld is alive\n\

View File

@ -78,6 +78,9 @@ static const char* host = 0;
static int port= 0;
static uint my_end_arg;
static const char* sock= 0;
#ifdef HAVE_SMEM
static char *shared_memory_base_name= 0;
#endif
static const char* user = 0;
static char* pass = 0;
static char *charset= 0;
@ -439,6 +442,7 @@ Exit_status Load_log_processor::process_first_event(const char *bname,
{
error("Could not construct local filename %s%s.",
target_dir_name,bname);
my_free(fname, MYF(0));
delete ce;
DBUG_RETURN(ERROR_STOP);
}
@ -446,9 +450,15 @@ Exit_status Load_log_processor::process_first_event(const char *bname,
rec.fname= fname;
rec.event= ce;
/*
fname is freed in process_event()
after Execute_load_query_log_event or Execute_load_log_event
will have been processed, otherwise in Load_log_processor::destroy()
*/
if (set_dynamic(&file_names, (uchar*)&rec, file_id))
{
error("Out of memory.");
my_free(fname, MYF(0));
delete ce;
DBUG_RETURN(ERROR_STOP);
}
@ -828,7 +838,17 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev,
print_event_info->common_header_len=
glob_description_event->common_header_len;
ev->print(result_file, print_event_info);
ev->temp_buf= 0; // as the event ref is zeroed
if (!remote_opt)
{
ev->free_temp_buf(); // free memory allocated in dump_local_log_entries
}
else
{
/*
disassociate but not free dump_remote_log_entries time memory
*/
ev->temp_buf= 0;
}
/*
We don't want this event to be deleted now, so let's hide it (I
(Guilhem) should later see if this triggers a non-serious Valgrind
@ -992,13 +1012,13 @@ static struct my_option my_long_options[] =
/* 'unspec' is not mentioned because it is just a placeholder. */
"Determine when the output statements should be base64-encoded BINLOG "
"statements: 'never' disables it and works only for binlogs without "
"row-based events; 'auto' is the default and prints base64 only when "
"necessary (i.e., for row-based events and format description events); "
"'decode-rows' suppresses BINLOG statements for row events, but does "
"not exit as an error if a row event is found, unlike 'never'; "
"'always' prints base64 whenever possible. 'always' is for debugging "
"only and should not be used in a production system. The default is "
"'auto'. --base64-output is a short form for --base64-output=always."
"row-based events; 'decode-rows' decodes row events into commented SQL "
"statements if the --verbose option is also given; 'auto' prints base64 "
"only when necessary (i.e., for row-based events and format description "
"events); 'always' prints base64 whenever possible. 'always' is for "
"debugging only and should not be used in a production system. If this "
"argument is not given, the default is 'auto'; if it is given with no "
"argument, 'always' is used."
,(uchar**) &opt_base64_output_mode_str,
(uchar**) &opt_base64_output_mode_str,
0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
@ -1077,6 +1097,12 @@ static struct my_option my_long_options[] =
{"set-charset", OPT_SET_CHARSET,
"Add 'SET NAMES character_set' to the output.", (uchar**) &charset,
(uchar**) &charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#ifdef HAVE_SMEM
{"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME,
"Base name of shared memory.", (uchar**) &shared_memory_base_name,
(uchar**) &shared_memory_base_name,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#endif
{"short-form", 's', "Just show regular queries: no extra info and no "
"row-based events. This is for testing only, and should not be used in "
"production systems. If you want to suppress base64-output, consider "
@ -1349,7 +1375,6 @@ static int parse_args(int *argc, char*** argv)
int ho_error;
result_file = stdout;
load_defaults("my",load_default_groups,argc,argv);
if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option)))
exit(ho_error);
if (debug_info_flag)
@ -1379,6 +1404,11 @@ static Exit_status safe_connect()
if (opt_protocol)
mysql_options(mysql, MYSQL_OPT_PROTOCOL, (char*) &opt_protocol);
#ifdef HAVE_SMEM
if (shared_memory_base_name)
mysql_options(mysql, MYSQL_SHARED_MEMORY_BASE_NAME,
shared_memory_base_name);
#endif
if (!mysql_real_connect(mysql, host, user, pass, 0, port, sock, 0))
{
error("Failed on connect: %s", mysql_error(mysql));
@ -2001,8 +2031,10 @@ int main(int argc, char** argv)
my_init_time(); // for time functions
if (load_defaults("my", load_default_groups, &argc, &argv))
exit(1);
defaults_argv= argv;
parse_args(&argc, (char***)&argv);
defaults_argv=argv;
if (!argc)
{

View File

@ -128,7 +128,7 @@ static struct my_option my_long_options[] =
"Faster than extended-check, but only finds 99.99 percent of all errors. Should be good enough for most cases.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"write-binlog", OPT_WRITE_BINLOG,
"Log ANALYZE, OPTIMIZE and REPAIR TABLE commands. Enabled by default; use --skip-write-binlog when commands should not be sent to replication slaves.",
"Log ANALYZE, OPTIMIZE and REPAIR TABLE commands. Use --skip-write-binlog when commands should not be sent to replication slaves.",
(uchar**) &opt_write_binlog, (uchar**) &opt_write_binlog, 0, GET_BOOL, NO_ARG,
1, 0, 0, 0, 0, 0},
{"optimize", 'o', "Optimize table.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0,
@ -344,9 +344,8 @@ static int get_options(int *argc, char ***argv)
exit(0);
}
load_defaults("my", load_default_groups, argc, argv);
if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option)))
if ((ho_error= load_defaults("my", load_default_groups, argc, argv)) ||
(ho_error=handle_options(argc, argv, my_long_options, get_one_option)))
exit(ho_error);
if (!what_to_do)
@ -369,12 +368,15 @@ static int get_options(int *argc, char ***argv)
If there's no --default-character-set option given with
--fix-table-name or --fix-db-name set the default character set to "utf8".
*/
if (!default_charset && (opt_fix_db_names || opt_fix_table_names))
if (!default_charset)
{
default_charset= (char*) "utf8";
if (opt_fix_db_names || opt_fix_table_names)
default_charset= (char*) "utf8";
else
default_charset= (char*) MYSQL_AUTODETECT_CHARSET_NAME;
}
if (default_charset && !get_charset_by_csname(default_charset, MY_CS_PRIMARY,
MYF(MY_WME)))
if (strcmp(default_charset, MYSQL_AUTODETECT_CHARSET_NAME) &&
!get_charset_by_csname(default_charset, MY_CS_PRIMARY, MYF(MY_WME)))
{
printf("Unsupported character set: %s\n", default_charset);
return 1;
@ -798,8 +800,7 @@ static int dbConnect(char *host, char *user, char *passwd)
if (shared_memory_base_name)
mysql_options(&mysql_connection,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name);
#endif
if (default_charset)
mysql_options(&mysql_connection, MYSQL_SET_CHARSET_NAME, default_charset);
mysql_options(&mysql_connection, MYSQL_SET_CHARSET_NAME, default_charset);
if (!(sock = mysql_real_connect(&mysql_connection, host, user, passwd,
NULL, opt_mysql_port, opt_mysql_unix_port, 0)))
{

View File

@ -98,6 +98,8 @@ static my_bool verbose= 0, opt_no_create_info= 0, opt_no_data= 0,
opt_complete_insert= 0, opt_drop_database= 0,
opt_replace_into= 0,
opt_dump_triggers= 0, opt_routines=0, opt_tz_utc=1,
opt_slave_apply= 0,
opt_include_master_host_port= 0,
opt_events= 0,
opt_alltspcs=0, opt_notspcs= 0;
static my_bool insert_pat_inited= 0, debug_info_flag= 0, debug_check_flag= 0;
@ -118,7 +120,10 @@ static my_bool server_supports_switching_charsets= TRUE;
static ulong opt_compatible_mode= 0;
#define MYSQL_OPT_MASTER_DATA_EFFECTIVE_SQL 1
#define MYSQL_OPT_MASTER_DATA_COMMENTED_SQL 2
#define MYSQL_OPT_SLAVE_DATA_EFFECTIVE_SQL 1
#define MYSQL_OPT_SLAVE_DATA_COMMENTED_SQL 2
static uint opt_mysql_port= 0, opt_master_data;
static uint opt_slave_data;
static uint my_end_arg;
static char * opt_mysql_unix_port=0;
static int first_error=0;
@ -206,6 +211,10 @@ static struct my_option my_long_options[] =
{"allow-keywords", OPT_KEYWORDS,
"Allow creation of column names that are keywords.", (uchar**) &opt_keywords,
(uchar**) &opt_keywords, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"apply-slave-statements", OPT_MYSQLDUMP_SLAVE_APPLY,
"Adds 'STOP SLAVE' prior to 'CHANGE MASTER' and 'START SLAVE' to bottom of dump.",
(uchar**) &opt_slave_apply, (uchar**) &opt_slave_apply, 0, GET_BOOL, NO_ARG,
0, 0, 0, 0, 0, 0},
#ifdef __NETWARE__
{"autoclose", OPT_AUTO_CLOSE, "Auto close the screen on exit for Netware.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
@ -264,6 +273,19 @@ static struct my_option my_long_options[] =
{"disable-keys", 'K',
"'/*!40000 ALTER TABLE tb_name DISABLE KEYS */; and '/*!40000 ALTER TABLE tb_name ENABLE KEYS */; will be put in the output.", (uchar**) &opt_disable_keys,
(uchar**) &opt_disable_keys, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
{"dump-slave", OPT_MYSQLDUMP_SLAVE_DATA,
"This causes the binary log position and filename of the master to be "
"appended to the dumped data output. Setting the value to 1, will print"
"it as a CHANGE MASTER command in the dumped data output; if equal"
" to 2, that command will be prefixed with a comment symbol. "
"This option will turn --lock-all-tables on, unless "
"--single-transaction is specified too (in which case a "
"global read lock is only taken a short time at the beginning of the dump "
"- don't forget to read about --single-transaction below). In all cases "
"any action on logs will happen at the exact moment of the dump."
"Option automatically turns --lock-tables off.",
(uchar**) &opt_slave_data, (uchar**) &opt_slave_data, 0,
GET_UINT, OPT_ARG, 0, 0, MYSQL_OPT_SLAVE_DATA_COMMENTED_SQL, 0, 0, 0},
{"events", 'E', "Dump events.",
(uchar**) &opt_events, (uchar**) &opt_events, 0, GET_BOOL,
NO_ARG, 0, 0, 0, 0, 0, 0},
@ -317,6 +339,12 @@ static struct my_option my_long_options[] =
"use the directive multiple times, once for each table. Each table must "
"be specified with both database and table names, e.g. --ignore-table=database.table",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"include-master-host-port", OPT_MYSQLDUMP_INCLUDE_MASTER_HOST_PORT,
"Adds 'MASTER_HOST=<host>, MASTER_PORT=<port>' to 'CHANGE MASTER TO..' in dump produced with --dump-slave.",
(uchar**) &opt_include_master_host_port,
(uchar**) &opt_include_master_host_port,
0, GET_BOOL, NO_ARG,
0, 0, 0, 0, 0, 0},
{"insert-ignore", OPT_INSERT_IGNORE, "Insert rows with INSERT IGNORE.",
(uchar**) &opt_ignore, (uchar**) &opt_ignore, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
0, 0},
@ -402,7 +430,7 @@ static struct my_option my_long_options[] =
(uchar**) &opt_routines, (uchar**) &opt_routines, 0, GET_BOOL,
NO_ARG, 0, 0, 0, 0, 0, 0},
{"set-charset", OPT_SET_CHARSET,
"Add 'SET NAMES default_character_set' to the output. Enabled by default; suppress with --skip-set-charset.",
"Add 'SET NAMES default_character_set' to the output.",
(uchar**) &opt_set_charset, (uchar**) &opt_set_charset, 0, GET_BOOL, NO_ARG, 1,
0, 0, 0, 0, 0},
{"set-variable", 'O',
@ -764,6 +792,10 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
if (!argument) /* work like in old versions */
opt_master_data= MYSQL_OPT_MASTER_DATA_EFFECTIVE_SQL;
break;
case (int) OPT_MYSQLDUMP_SLAVE_DATA:
if (!argument) /* work like in old versions */
opt_slave_data= MYSQL_OPT_SLAVE_DATA_EFFECTIVE_SQL;
break;
case (int) OPT_OPTIMIZE:
extended_insert= opt_drop= opt_lock= quick= create_options=
opt_disable_keys= lock_tables= opt_set_charset= 1;
@ -858,12 +890,13 @@ static int get_options(int *argc, char ***argv)
opt_net_buffer_length= *mysql_params->p_net_buffer_length;
md_result_file= stdout;
load_defaults("my",load_default_groups,argc,argv);
if (load_defaults("my",load_default_groups,argc,argv))
return 1;
defaults_argv= *argv;
if (hash_init(&ignore_table, charset_info, 16, 0, 0,
(hash_get_key) get_table_key,
(hash_free_key) free_table_ent, 0))
if (my_hash_init(&ignore_table, charset_info, 16, 0, 0,
(my_hash_get_key) get_table_key,
(my_hash_free_key) free_table_ent, 0))
return(EX_EOM);
/* Don't copy internal log tables */
if (my_hash_insert(&ignore_table,
@ -896,6 +929,14 @@ static int get_options(int *argc, char ***argv)
return(EX_USAGE);
}
/* We don't delete master logs if slave data option */
if (opt_slave_data)
{
opt_lock_all_tables= !opt_single_transaction;
opt_master_data= 0;
opt_delete_master_logs= 0;
}
/* Ensure consistency of the set of binlog & locking options */
if (opt_delete_master_logs && !opt_master_data)
opt_master_data= MYSQL_OPT_MASTER_DATA_COMMENTED_SQL;
@ -906,7 +947,10 @@ static int get_options(int *argc, char ***argv)
return(EX_USAGE);
}
if (opt_master_data)
{
opt_lock_all_tables= !opt_single_transaction;
opt_slave_data= 0;
}
if (opt_single_transaction || opt_lock_all_tables)
lock_tables= 0;
if (enclosed && opt_enclosed)
@ -1273,120 +1317,68 @@ static int switch_character_set_results(MYSQL *mysql, const char *cs_name)
}
/**
Rewrite CREATE TRIGGER statement, enclosing DEFINER clause in
version-specific comment.
Rewrite statement, enclosing DEFINER clause in version-specific comment.
This function parses the CREATE TRIGGER statement and encloses
DEFINER-clause in version-specific comment:
input query: CREATE DEFINER=a@b TRIGGER ...
rewritten query: CREATE * / / *!50017 DEFINER=a@b * / / *!50003 TRIGGER ...
@note This function will go away when WL#3995 is implemented.
@param[in] trigger_def_str CREATE TRIGGER statement string.
@param[in] trigger_def_length length of the trigger_def_str.
@return pointer to the new allocated query string.
*/
static char *cover_definer_clause_in_trigger(const char *trigger_def_str,
uint trigger_def_length)
{
char *query_str= NULL;
char *definer_begin= my_case_str(trigger_def_str, trigger_def_length,
C_STRING_WITH_LEN(" DEFINER"));
char *definer_end;
if (!definer_begin)
return NULL;
definer_end= my_case_str(definer_begin, strlen(definer_begin),
C_STRING_WITH_LEN(" TRIGGER"));
if (definer_end)
{
char *query_str_tail;
/*
Allocate memory for new query string: original string
from SHOW statement and version-specific comments.
*/
query_str= alloc_query_str(trigger_def_length + 23);
query_str_tail= strnmov(query_str,
trigger_def_str,
definer_begin - trigger_def_str);
query_str_tail= strmov(query_str_tail,
"*/ /*!50017");
query_str_tail= strnmov(query_str_tail,
definer_begin,
definer_end - definer_begin);
query_str_tail= strxmov(query_str_tail,
"*/ /*!50003",
definer_end,
NullS);
}
return query_str;
}
/**
Rewrite CREATE FUNCTION or CREATE PROCEDURE statement, enclosing DEFINER
clause in version-specific comment.
This function parses the CREATE FUNCTION | PROCEDURE statement and
encloses DEFINER-clause in version-specific comment:
This function parses any CREATE statement and encloses DEFINER-clause in
version-specific comment:
input query: CREATE DEFINER=a@b FUNCTION ...
rewritten query: CREATE * / / *!50020 DEFINER=a@b * / / *!50003 FUNCTION ...
@note This function will go away when WL#3995 is implemented.
@param[in] def_str CREATE FUNCTION|PROCEDURE statement string.
@param[in] def_str_length length of the def_str.
@param[in] stmt_str CREATE statement string.
@param[in] stmt_length Length of the stmt_str.
@param[in] definer_version_str Minimal MySQL version number when
DEFINER clause is supported in the
given statement.
@param[in] definer_version_length Length of definer_version_str.
@param[in] stmt_version_str Minimal MySQL version number when the
given statement is supported.
@param[in] stmt_version_length Length of stmt_version_str.
@param[in] keyword_str Keyword to look for after CREATE.
@param[in] keyword_length Length of keyword_str.
@return pointer to the new allocated query string.
*/
static char *cover_definer_clause_in_sp(const char *def_str,
uint def_str_length)
static char *cover_definer_clause(const char *stmt_str,
uint stmt_length,
const char *definer_version_str,
uint definer_version_length,
const char *stmt_version_str,
uint stmt_version_length,
const char *keyword_str,
uint keyword_length)
{
char *query_str= NULL;
char *definer_begin= my_case_str(def_str, def_str_length,
char *definer_begin= my_case_str(stmt_str, stmt_length,
C_STRING_WITH_LEN(" DEFINER"));
char *definer_end;
char *definer_end= NULL;
char *query_str= NULL;
char *query_ptr;
if (!definer_begin)
return NULL;
definer_end= my_case_str(definer_begin, strlen(definer_begin),
C_STRING_WITH_LEN(" PROCEDURE"));
keyword_str, keyword_length);
if (!definer_end)
{
definer_end= my_case_str(definer_begin, strlen(definer_begin),
C_STRING_WITH_LEN(" FUNCTION"));
}
return NULL;
if (definer_end)
{
char *query_str_tail;
/*
Allocate memory for new query string: original string
from SHOW statement and version-specific comments.
*/
query_str= alloc_query_str(stmt_length + 23);
/*
Allocate memory for new query string: original string
from SHOW statement and version-specific comments.
*/
query_str= alloc_query_str(def_str_length + 23);
query_str_tail= strnmov(query_str, def_str, definer_begin - def_str);
query_str_tail= strmov(query_str_tail, "*/ /*!50020");
query_str_tail= strnmov(query_str_tail, definer_begin,
definer_end - definer_begin);
query_str_tail= strxmov(query_str_tail, "*/ /*!50003",
definer_end, NullS);
}
query_ptr= strnmov(query_str, stmt_str, definer_begin - stmt_str);
query_ptr= strnmov(query_ptr, C_STRING_WITH_LEN("*/ /*!"));
query_ptr= strnmov(query_ptr, definer_version_str, definer_version_length);
query_ptr= strnmov(query_ptr, definer_begin, definer_end - definer_begin);
query_ptr= strnmov(query_ptr, C_STRING_WITH_LEN("*/ /*!"));
query_ptr= strnmov(query_ptr, stmt_version_str, stmt_version_length);
query_ptr= strxmov(query_ptr, definer_end, NullS);
return query_str;
}
@ -1419,8 +1411,8 @@ static void free_resources()
if (md_result_file && md_result_file != stdout)
my_fclose(md_result_file, MYF(0));
my_free(opt_password, MYF(MY_ALLOW_ZERO_PTR));
if (hash_inited(&ignore_table))
hash_free(&ignore_table);
if (my_hash_inited(&ignore_table))
my_hash_free(&ignore_table);
if (extended_insert)
dynstr_free(&extended_row);
if (insert_pat_inited)
@ -1922,6 +1914,8 @@ static uint dump_events_for_db(char *db)
*/
if (strlen(row[3]) != 0)
{
char *query_str;
if (opt_drop)
fprintf(sql_file, "/*!50106 DROP EVENT IF EXISTS %s */%s\n",
event_name, delimiter);
@ -1948,31 +1942,36 @@ static uint dump_events_for_db(char *db)
row[4], /* character_set_results */
row[5]); /* collation_connection */
}
else
{
/*
mysqldump is being run against the server, that does not
provide character set information in SHOW CREATE
statements.
else
{
/*
mysqldump is being run against the server, that does not
provide character set information in SHOW CREATE
statements.
NOTE: the dump may be incorrect, since character set
information is required in order to restore event properly.
*/
NOTE: the dump may be incorrect, since character set
information is required in order to restore event properly.
*/
fprintf(sql_file,
"--\n"
"-- WARNING: old server version. "
"The following dump may be incomplete.\n"
"--\n");
}
fprintf(sql_file,
"--\n"
"-- WARNING: old server version. "
"The following dump may be incomplete.\n"
"--\n");
}
switch_sql_mode(sql_file, delimiter, row[1]);
switch_time_zone(sql_file, delimiter, row[2]);
query_str= cover_definer_clause(row[3], strlen(row[3]),
C_STRING_WITH_LEN("50117"),
C_STRING_WITH_LEN("50106"),
C_STRING_WITH_LEN(" EVENT"));
fprintf(sql_file,
"/*!50106 %s */ %s\n",
(const char *) row[3],
(const char *) (query_str != NULL ? query_str : row[3]),
(const char *) delimiter);
restore_time_zone(sql_file, delimiter);
@ -2003,7 +2002,7 @@ static uint dump_events_for_db(char *db)
mysql_free_result(event_list_res);
if (lock_tables)
VOID(mysql_query_with_error_report(mysql, 0, "UNLOCK TABLES"));
(void) mysql_query_with_error_report(mysql, 0, "UNLOCK TABLES");
DBUG_RETURN(0);
}
@ -2127,7 +2126,16 @@ static uint dump_routines_for_db(char *db)
fprintf(sql_file, "/*!50003 DROP %s IF EXISTS %s */;\n",
routine_type[i], routine_name);
query_str= cover_definer_clause_in_sp(row[2], strlen(row[2]));
query_str= cover_definer_clause(row[2], strlen(row[2]),
C_STRING_WITH_LEN("50020"),
C_STRING_WITH_LEN("50003"),
C_STRING_WITH_LEN(" FUNCTION"));
if (!query_str)
query_str= cover_definer_clause(row[2], strlen(row[2]),
C_STRING_WITH_LEN("50020"),
C_STRING_WITH_LEN("50003"),
C_STRING_WITH_LEN(" PROCEDURE"));
if (mysql_num_fields(routine_res) >= 6)
{
@ -2197,7 +2205,7 @@ static uint dump_routines_for_db(char *db)
DBUG_RETURN(1);
if (lock_tables)
VOID(mysql_query_with_error_report(mysql, 0, "UNLOCK TABLES"));
(void) mysql_query_with_error_report(mysql, 0, "UNLOCK TABLES");
DBUG_RETURN(0);
}
@ -2806,8 +2814,10 @@ static int dump_trigger(FILE *sql_file, MYSQL_RES *show_create_trigger_rs,
while ((row= mysql_fetch_row(show_create_trigger_rs)))
{
char *query_str= cover_definer_clause_in_trigger(row[2], strlen(row[2]));
char *query_str= cover_definer_clause(row[2], strlen(row[2]),
C_STRING_WITH_LEN("50017"),
C_STRING_WITH_LEN("50003"),
C_STRING_WITH_LEN(" TRIGGER"));
if (switch_db_collation(sql_file, db_name, ";",
db_cl_name, row[5], &db_cl_altered))
@ -3992,7 +4002,7 @@ static int init_dumping(char *database, int init_func(char*))
my_bool include_table(const uchar *hash_key, size_t len)
{
return !hash_search(&ignore_table, hash_key, len);
return ! my_hash_search(&ignore_table, hash_key, len);
}
@ -4077,7 +4087,7 @@ static int dump_all_tables_in_db(char *database)
check_io(md_result_file);
}
if (lock_tables)
VOID(mysql_query_with_error_report(mysql, 0, "UNLOCK TABLES"));
(void) mysql_query_with_error_report(mysql, 0, "UNLOCK TABLES");
if (flush_privileges && using_mysql_db == 0)
{
fprintf(md_result_file,"\n--\n-- Flush Grant Tables \n--\n");
@ -4151,7 +4161,7 @@ static my_bool dump_all_views_in_db(char *database)
check_io(md_result_file);
}
if (lock_tables)
VOID(mysql_query_with_error_report(mysql, 0, "UNLOCK TABLES"));
(void) mysql_query_with_error_report(mysql, 0, "UNLOCK TABLES");
return 0;
} /* dump_all_tables_in_db */
@ -4323,7 +4333,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
check_io(md_result_file);
}
if (lock_tables)
VOID(mysql_query_with_error_report(mysql, 0, "UNLOCK TABLES"));
(void) mysql_query_with_error_report(mysql, 0, "UNLOCK TABLES");
DBUG_RETURN(0);
} /* dump_selected_tables */
@ -4367,6 +4377,130 @@ static int do_show_master_status(MYSQL *mysql_con)
return 0;
}
static int do_stop_slave_sql(MYSQL *mysql_con)
{
MYSQL_RES *slave;
/* We need to check if the slave sql is running in the first place */
if (mysql_query_with_error_report(mysql_con, &slave, "SHOW SLAVE STATUS"))
return(1);
else
{
MYSQL_ROW row= mysql_fetch_row(slave);
if (row && row[11])
{
/* if SLAVE SQL is not running, we don't stop it */
if (!strcmp(row[11],"No"))
{
mysql_free_result(slave);
/* Silently assume that they don't have the slave running */
return(0);
}
}
}
mysql_free_result(slave);
/* now, stop slave if running */
if (mysql_query_with_error_report(mysql_con, 0, "STOP SLAVE SQL_THREAD"))
return(1);
return(0);
}
static int add_stop_slave(void)
{
if (opt_comments)
fprintf(md_result_file,
"\n--\n-- stop slave statement to make a recovery dump)\n--\n\n");
fprintf(md_result_file, "STOP SLAVE;\n");
return(0);
}
static int add_slave_statements(void)
{
if (opt_comments)
fprintf(md_result_file,
"\n--\n-- start slave statement to make a recovery dump)\n--\n\n");
fprintf(md_result_file, "START SLAVE;\n");
return(0);
}
static int do_show_slave_status(MYSQL *mysql_con)
{
MYSQL_RES *slave;
const char *comment_prefix=
(opt_slave_data == MYSQL_OPT_SLAVE_DATA_COMMENTED_SQL) ? "-- " : "";
if (mysql_query_with_error_report(mysql_con, &slave, "SHOW SLAVE STATUS"))
{
if (!ignore_errors)
{
/* SHOW SLAVE STATUS reports nothing and --force is not enabled */
my_printf_error(0, "Error: Slave not set up", MYF(0));
}
mysql_free_result(slave);
return 1;
}
else
{
MYSQL_ROW row= mysql_fetch_row(slave);
if (row && row[9] && row[21])
{
/* SHOW MASTER STATUS reports file and position */
if (opt_comments)
fprintf(md_result_file,
"\n--\n-- Position to start replication or point-in-time "
"recovery from (the master of this slave)\n--\n\n");
fprintf(md_result_file, "%sCHANGE MASTER TO ", comment_prefix);
if (opt_include_master_host_port)
{
if (row[1])
fprintf(md_result_file, "MASTER_HOST='%s', ", row[1]);
if (row[3])
fprintf(md_result_file, "MASTER_PORT='%s', ", row[3]);
}
fprintf(md_result_file,
"MASTER_LOG_FILE='%s', MASTER_LOG_POS=%s;\n", row[9], row[21]);
check_io(md_result_file);
}
mysql_free_result(slave);
}
return 0;
}
static int do_start_slave_sql(MYSQL *mysql_con)
{
MYSQL_RES *slave;
/* We need to check if the slave sql is stopped in the first place */
if (mysql_query_with_error_report(mysql_con, &slave, "SHOW SLAVE STATUS"))
return(1);
else
{
MYSQL_ROW row= mysql_fetch_row(slave);
if (row && row[11])
{
/* if SLAVE SQL is not running, we don't start it */
if (!strcmp(row[11],"Yes"))
{
mysql_free_result(slave);
/* Silently assume that they don't have the slave running */
return(0);
}
}
}
mysql_free_result(slave);
/* now, start slave if stopped */
if (mysql_query_with_error_report(mysql_con, 0, "START SLAVE"))
{
my_printf_error(0, "Error: Unable to start slave", MYF(0));
return 1;
}
return(0);
}
static int do_flush_tables_read_lock(MYSQL *mysql_con)
{
@ -5029,6 +5163,9 @@ int main(int argc, char **argv)
if (!path)
write_header(md_result_file, *argv);
if (opt_slave_data && do_stop_slave_sql(mysql))
goto err;
if ((opt_lock_all_tables || opt_master_data) &&
do_flush_tables_read_lock(mysql))
goto err;
@ -5047,8 +5184,13 @@ int main(int argc, char **argv)
goto err;
flush_logs= 0; /* not anymore; that would not be sensible */
}
/* Add 'STOP SLAVE to beginning of dump */
if (opt_slave_apply && add_stop_slave())
goto err;
if (opt_master_data && do_show_master_status(mysql))
goto err;
if (opt_slave_data && do_show_slave_status(mysql))
goto err;
if (opt_single_transaction && do_unlock_tables(mysql)) /* unlock but no commit! */
goto err;
@ -5076,6 +5218,14 @@ int main(int argc, char **argv)
dump_databases(argv);
}
/* if --dump-slave , start the slave sql thread */
if (opt_slave_data && do_start_slave_sql(mysql))
goto err;
/* add 'START SLAVE' to end of dump */
if (opt_slave_apply && add_slave_statements())
goto err;
/* ensure dumped data flushed */
if (md_result_file && fflush(md_result_file))
{

View File

@ -55,11 +55,10 @@ static char *opt_password=0, *current_user=0,
*current_host=0, *current_db=0, *fields_terminated=0,
*lines_terminated=0, *enclosed=0, *opt_enclosed=0,
*escaped=0, *opt_columns=0,
*default_charset= (char*) MYSQL_DEFAULT_CHARSET_NAME;
*default_charset= (char*) MYSQL_AUTODETECT_CHARSET_NAME;
static uint opt_mysql_port= 0, opt_protocol= 0;
static char * opt_mysql_unix_port=0;
static longlong opt_ignore_lines= -1;
static CHARSET_INFO *charset_info= &my_charset_latin1;
#include <sslopt-vars.h>
#ifdef HAVE_SMEM
@ -282,10 +281,6 @@ static int get_options(int *argc, char ***argv)
fprintf(stderr, "You can't use --ignore (-i) and --replace (-r) at the same time.\n");
return(1);
}
if (strcmp(default_charset, charset_info->csname) &&
!(charset_info= get_charset_by_csname(default_charset,
MY_CS_PRIMARY, MYF(MY_WME))))
exit(1);
if (*argc < 2)
{
usage();
@ -440,6 +435,7 @@ static MYSQL *db_connect(char *host, char *database,
if (shared_memory_base_name)
mysql_options(mysql,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name);
#endif
mysql_options(mysql, MYSQL_SET_CHARSET_NAME, default_charset);
if (!(mysql_real_connect(mysql,host,user,passwd,
database,opt_mysql_port,opt_mysql_unix_port,
0)))
@ -596,7 +592,8 @@ int main(int argc, char **argv)
char **argv_to_free;
MY_INIT(argv[0]);
load_defaults("my",load_default_groups,&argc,&argv);
if (load_defaults("my",load_default_groups,&argc,&argv))
return 1;
/* argv is changed in the program */
argv_to_free= argv;
if (get_options(&argc, &argv))
@ -614,8 +611,8 @@ int main(int argc, char **argv)
pthread_attr_setdetachstate(&attr,
PTHREAD_CREATE_DETACHED);
VOID(pthread_mutex_init(&counter_mutex, NULL));
VOID(pthread_cond_init(&count_threshhold, NULL));
pthread_mutex_init(&counter_mutex, NULL);
pthread_cond_init(&count_threshhold, NULL);
for (counter= 0; *argv != NULL; argv++) /* Loop through tables */
{
@ -654,8 +651,8 @@ int main(int argc, char **argv)
pthread_cond_timedwait(&count_threshhold, &counter_mutex, &abstime);
}
pthread_mutex_unlock(&counter_mutex);
VOID(pthread_mutex_destroy(&counter_mutex));
VOID(pthread_cond_destroy(&count_threshhold));
pthread_mutex_destroy(&counter_mutex);
pthread_cond_destroy(&count_threshhold);
pthread_attr_destroy(&attr);
}
else

View File

@ -32,7 +32,7 @@ static my_bool tty_password= 0, opt_table_type= 0;
static my_bool debug_info_flag= 0, debug_check_flag= 0;
static uint my_end_arg= 0;
static uint opt_verbose=0;
static char *default_charset= (char*) MYSQL_DEFAULT_CHARSET_NAME;
static char *default_charset= (char*) MYSQL_AUTODETECT_CHARSET_NAME;
#ifdef HAVE_SMEM
static char *shared_memory_base_name=0;
@ -63,7 +63,9 @@ int main(int argc, char **argv)
char *wild;
MYSQL mysql;
MY_INIT(argv[0]);
load_defaults("my",load_default_groups,&argc,&argv);
if (load_defaults("my",load_default_groups,&argc,&argv))
exit(1);
get_options(&argc,&argv);
wild=0;

View File

@ -299,7 +299,11 @@ int main(int argc, char **argv)
MY_INIT(argv[0]);
load_defaults("my",load_default_groups,&argc,&argv);
if (load_defaults("my",load_default_groups,&argc,&argv))
{
my_end(0);
exit(1);
}
defaults_argv=argv;
if (get_options(&argc,&argv))
{
@ -352,10 +356,10 @@ int main(int argc, char **argv)
}
}
VOID(pthread_mutex_init(&counter_mutex, NULL));
VOID(pthread_cond_init(&count_threshhold, NULL));
VOID(pthread_mutex_init(&sleeper_mutex, NULL));
VOID(pthread_cond_init(&sleep_threshhold, NULL));
pthread_mutex_init(&counter_mutex, NULL);
pthread_cond_init(&count_threshhold, NULL);
pthread_mutex_init(&sleeper_mutex, NULL);
pthread_cond_init(&sleep_threshhold, NULL);
/* Main iterations loop */
eptr= engine_options;
@ -386,10 +390,10 @@ int main(int argc, char **argv)
} while (eptr ? (eptr= eptr->next) : 0);
VOID(pthread_mutex_destroy(&counter_mutex));
VOID(pthread_cond_destroy(&count_threshhold));
VOID(pthread_mutex_destroy(&sleeper_mutex));
VOID(pthread_cond_destroy(&sleep_threshhold));
pthread_mutex_destroy(&counter_mutex);
pthread_cond_destroy(&count_threshhold);
pthread_mutex_destroy(&sleeper_mutex);
pthread_cond_destroy(&sleep_threshhold);
if (!opt_only_print)
mysql_close(&mysql); /* Close & free connection */

View File

@ -75,16 +75,21 @@
enum {
OPT_SKIP_SAFEMALLOC=OPT_MAX_CLIENT_OPTION,
OPT_PS_PROTOCOL, OPT_SP_PROTOCOL, OPT_CURSOR_PROTOCOL, OPT_VIEW_PROTOCOL,
OPT_MAX_CONNECT_RETRIES, OPT_MARK_PROGRESS, OPT_LOG_DIR, OPT_TAIL_LINES
OPT_MAX_CONNECT_RETRIES, OPT_MARK_PROGRESS, OPT_LOG_DIR, OPT_TAIL_LINES,
OPT_RESULT_FORMAT_VERSION
};
static int record= 0, opt_sleep= -1;
static char *opt_db= 0, *opt_pass= 0;
const char *opt_user= 0, *opt_host= 0, *unix_sock= 0, *opt_basedir= "./";
#ifdef HAVE_SMEM
static char *shared_memory_base_name=0;
#endif
const char *opt_logdir= "";
const char *opt_include= 0, *opt_charsets_dir;
static int opt_port= 0;
static int opt_max_connect_retries;
static int opt_result_format_version;
static my_bool opt_compress= 0, silent= 0, verbose= 0;
static my_bool debug_info_flag= 0, debug_check_flag= 0;
static my_bool tty_password= 0;
@ -112,6 +117,8 @@ static uint my_end_arg= 0;
/* Number of lines of the result to include in failure report */
static uint opt_tail_lines= 0;
static uint opt_connect_timeout= 0;
static char delimiter[MAX_DELIMITER_LENGTH]= ";";
static uint delimiter_length= 1;
@ -257,8 +264,7 @@ enum enum_commands {
Q_SEND, Q_REAP,
Q_DIRTY_CLOSE, Q_REPLACE, Q_REPLACE_COLUMN,
Q_PING, Q_EVAL,
Q_RPL_PROBE, Q_ENABLE_RPL_PARSE,
Q_DISABLE_RPL_PARSE, Q_EVAL_RESULT,
Q_EVAL_RESULT,
Q_ENABLE_QUERY_LOG, Q_DISABLE_QUERY_LOG,
Q_ENABLE_RESULT_LOG, Q_DISABLE_RESULT_LOG,
Q_WAIT_FOR_SLAVE_TO_STOP,
@ -280,11 +286,12 @@ enum enum_commands {
Q_SEND_QUIT, Q_CHANGE_USER, Q_MKDIR, Q_RMDIR,
Q_LIST_FILES, Q_LIST_FILES_WRITE_FILE, Q_LIST_FILES_APPEND_FILE,
Q_SEND_SHUTDOWN, Q_SHUTDOWN_SERVER,
Q_MOVE_FILE,
Q_RESULT_FORMAT_VERSION,
Q_MOVE_FILE, Q_SEND_EVAL,
Q_UNKNOWN, /* Unknown command. */
Q_COMMENT, /* Comments, ignored. */
Q_COMMENT_WITH_COMMAND
Q_COMMENT_WITH_COMMAND,
Q_EMPTY_LINE
};
@ -317,9 +324,6 @@ const char *command_names[]=
"replace_column",
"ping",
"eval",
"rpl_probe",
"enable_rpl_parse",
"disable_rpl_parse",
"eval_result",
/* Enable/disable that the _query_ is logged to result file */
"enable_query_log",
@ -377,7 +381,9 @@ const char *command_names[]=
"list_files_append_file",
"send_shutdown",
"shutdown_server",
"result_format",
"move_file",
"send_eval",
0
};
@ -659,14 +665,6 @@ public:
LogFile log_file;
LogFile progress_file;
/* Disable functions that only exist in MySQL 4.0 */
#if MYSQL_VERSION_ID < 40000
void mysql_enable_rpl_parse(MYSQL* mysql __attribute__((unused))) {}
void mysql_disable_rpl_parse(MYSQL* mysql __attribute__((unused))) {}
int mysql_rpl_parse_enabled(MYSQL* mysql __attribute__((unused))) { return 1; }
my_bool mysql_rpl_probe(MYSQL *mysql __attribute__((unused))) { return 1; }
#endif
void replace_dynstr_append_mem(DYNAMIC_STRING *ds, const char *val,
int len);
void replace_dynstr_append(DYNAMIC_STRING *ds, const char *val);
@ -698,12 +696,12 @@ pthread_handler_t send_one_query(void *arg)
struct st_connection *cn= (struct st_connection*)arg;
mysql_thread_init();
VOID(mysql_send_query(&cn->mysql, cn->cur_query, cn->cur_query_len));
(void) mysql_send_query(&cn->mysql, cn->cur_query, cn->cur_query_len);
mysql_thread_end();
pthread_mutex_lock(&cn->mutex);
cn->query_done= 1;
VOID(pthread_cond_signal(&cn->cond));
pthread_cond_signal(&cn->cond);
pthread_mutex_unlock(&cn->mutex);
pthread_exit(0);
return 0;
@ -1135,7 +1133,7 @@ void free_used_memory()
close_connections();
close_files();
hash_free(&var_hash);
my_hash_free(&var_hash);
for (i= 0 ; i < q_lines.elements ; i++)
{
@ -1168,7 +1166,6 @@ void free_used_memory()
mysql_server_end();
/* Don't use DBUG after mysql_server_end() */
DBUG_VIOLATION_HELPER_LEAVE;
return;
}
@ -1998,8 +1995,8 @@ VAR* var_get(const char *var_name, const char **var_name_end, my_bool raw,
if (length >= MAX_VAR_NAME_LENGTH)
die("Too long variable name: %s", save_var_name);
if (!(v = (VAR*) hash_search(&var_hash, (const uchar*) save_var_name,
length)))
if (!(v = (VAR*) my_hash_search(&var_hash, (const uchar*) save_var_name,
length)))
{
char buff[MAX_VAR_NAME_LENGTH+1];
strmake(buff, save_var_name, length);
@ -2030,7 +2027,7 @@ err:
VAR *var_obtain(const char *name, int len)
{
VAR* v;
if ((v = (VAR*)hash_search(&var_hash, (const uchar *) name, len)))
if ((v = (VAR*)my_hash_search(&var_hash, (const uchar *) name, len)))
return v;
v = var_init(0, name, len, "", 0);
my_hash_insert(&var_hash, (uchar*)v);
@ -2200,6 +2197,59 @@ void var_query_set(VAR *var, const char *query, const char** query_end)
}
static void
set_result_format_version(ulong new_version)
{
switch (new_version){
case 1:
/* The first format */
break;
case 2:
/* New format that also writes comments and empty lines
from test file to result */
break;
default:
die("Version format %lu has not yet been implemented", new_version);
break;
}
opt_result_format_version= new_version;
}
/*
Set the result format version to use when generating
the .result file
*/
static void
do_result_format_version(struct st_command *command)
{
long version;
static DYNAMIC_STRING ds_version;
const struct command_arg result_format_args[] = {
"version", ARG_STRING, TRUE, &ds_version, "Version to use",
};
DBUG_ENTER("do_result_format_version");
check_command_args(command, command->first_argument,
result_format_args,
sizeof(result_format_args)/sizeof(struct command_arg),
',');
/* Convert version number to int */
if (!str2int(ds_version.str, 10, (long) 0, (long) INT_MAX, &version))
die("Invalid version number: '%s'", ds_version.str);
set_result_format_version(version);
dynstr_append(&ds_res, "result_format: ");
dynstr_append_mem(&ds_res, ds_version.str, ds_version.length);
dynstr_append(&ds_res, "\n");
dynstr_free(&ds_version);
}
/*
Set variable from the result of a field in a query
@ -2964,6 +3014,7 @@ void do_move_file(struct st_command *command)
void do_chmod_file(struct st_command *command)
{
long mode= 0;
int err_code;
static DYNAMIC_STRING ds_mode;
static DYNAMIC_STRING ds_file;
const struct command_arg chmod_file_args[] = {
@ -2983,7 +3034,10 @@ void do_chmod_file(struct st_command *command)
die("You must write a 4 digit octal number for mode");
DBUG_PRINT("info", ("chmod %o %s", (uint)mode, ds_file.str));
handle_command_error(command, chmod(ds_file.str, mode));
err_code= chmod(ds_file.str, mode);
if (err_code < 0)
err_code= 1;
handle_command_error(command, err_code);
dynstr_free(&ds_mode);
dynstr_free(&ds_file);
DBUG_VOID_RETURN;
@ -3853,12 +3907,8 @@ int do_save_master_pos()
MYSQL_ROW row;
MYSQL *mysql = &cur_con->mysql;
const char *query;
int rpl_parse;
DBUG_ENTER("do_save_master_pos");
rpl_parse = mysql_rpl_parse_enabled(mysql);
mysql_disable_rpl_parse(mysql);
#ifdef HAVE_NDB_BINLOG
/*
Wait for ndb binlog to be up-to-date with all changes
@ -4008,10 +4058,6 @@ int do_save_master_pos()
strnmov(master_pos.file, row[0], sizeof(master_pos.file)-1);
master_pos.pos = strtoul(row[1], (char**) 0, 10);
mysql_free_result(res);
if (rpl_parse)
mysql_enable_rpl_parse(mysql);
DBUG_RETURN(0);
}
@ -4074,29 +4120,6 @@ void do_let(struct st_command *command)
}
int do_rpl_probe(struct st_command *command __attribute__((unused)))
{
DBUG_ENTER("do_rpl_probe");
if (mysql_rpl_probe(&cur_con->mysql))
die("Failed in mysql_rpl_probe(): '%s'", mysql_error(&cur_con->mysql));
DBUG_RETURN(0);
}
int do_enable_rpl_parse(struct st_command *command __attribute__((unused)))
{
mysql_enable_rpl_parse(&cur_con->mysql);
return 0;
}
int do_disable_rpl_parse(struct st_command *command __attribute__((unused)))
{
mysql_disable_rpl_parse(&cur_con->mysql);
return 0;
}
/*
Sleep the number of specified seconds
@ -4905,6 +4928,8 @@ do_handle_error:
<opts> - options to use for the connection
* SSL - use SSL if available
* COMPRESS - use compression if available
* SHM - use shared memory if available
* PIPE - use named pipe if available
*/
@ -4913,6 +4938,7 @@ void do_connect(struct st_command *command)
int con_port= opt_port;
char *con_options;
my_bool con_ssl= 0, con_compress= 0;
my_bool con_pipe= 0, con_shm= 0;
struct st_connection* con_slot;
static DYNAMIC_STRING ds_connection_name;
@ -4923,6 +4949,9 @@ void do_connect(struct st_command *command)
static DYNAMIC_STRING ds_port;
static DYNAMIC_STRING ds_sock;
static DYNAMIC_STRING ds_options;
#ifdef HAVE_SMEM
static DYNAMIC_STRING ds_shm;
#endif
const struct command_arg connect_args[] = {
{ "connection name", ARG_STRING, TRUE, &ds_connection_name, "Name of the connection" },
{ "host", ARG_STRING, TRUE, &ds_host, "Host to connect to" },
@ -4950,6 +4979,11 @@ void do_connect(struct st_command *command)
die("Illegal argument for port: '%s'", ds_port.str);
}
#ifdef HAVE_SMEM
/* Shared memory */
init_dynamic_string(&ds_shm, ds_sock.str, 0, 0);
#endif
/* Sock */
if (ds_sock.length)
{
@ -4988,6 +5022,10 @@ void do_connect(struct st_command *command)
con_ssl= 1;
else if (!strncmp(con_options, "COMPRESS", 8))
con_compress= 1;
else if (!strncmp(con_options, "PIPE", 4))
con_pipe= 1;
else if (!strncmp(con_options, "SHM", 3))
con_shm= 1;
else
die("Illegal option to connect: %.*s",
(int) (end - con_options), con_options);
@ -5012,6 +5050,11 @@ void do_connect(struct st_command *command)
#endif
if (!mysql_init(&con_slot->mysql))
die("Failed on mysql_init()");
if (opt_connect_timeout)
mysql_options(&con_slot->mysql, MYSQL_OPT_CONNECT_TIMEOUT,
(void *) &opt_connect_timeout);
if (opt_compress || con_compress)
mysql_options(&con_slot->mysql, MYSQL_OPT_COMPRESS, NullS);
mysql_options(&con_slot->mysql, MYSQL_OPT_LOCAL_INFILE, 0);
@ -5035,6 +5078,31 @@ void do_connect(struct st_command *command)
}
#endif
#ifdef __WIN__
if (con_pipe)
{
uint protocol= MYSQL_PROTOCOL_PIPE;
mysql_options(&con_slot->mysql, MYSQL_OPT_PROTOCOL, &protocol);
}
#endif
#ifdef HAVE_SMEM
if (con_shm)
{
uint protocol= MYSQL_PROTOCOL_MEMORY;
if (!ds_shm.length)
die("Missing shared memory base name");
mysql_options(&con_slot->mysql, MYSQL_SHARED_MEMORY_BASE_NAME, ds_shm.str);
mysql_options(&con_slot->mysql, MYSQL_OPT_PROTOCOL, &protocol);
}
else if(shared_memory_base_name)
{
mysql_options(&con_slot->mysql, MYSQL_SHARED_MEMORY_BASE_NAME,
shared_memory_base_name);
}
#endif
/* Use default db name */
if (ds_database.length == 0)
dynstr_set(&ds_database, opt_db);
@ -5067,6 +5135,9 @@ void do_connect(struct st_command *command)
dynstr_free(&ds_port);
dynstr_free(&ds_sock);
dynstr_free(&ds_options);
#ifdef HAVE_SMEM
dynstr_free(&ds_shm);
#endif
DBUG_VOID_RETURN;
}
@ -5268,7 +5339,7 @@ my_bool end_of_query(int c)
int read_line(char *buf, int size)
{
char c, UNINIT_VAR(last_quote);
char c, UNINIT_VAR(last_quote), last_char= 0;
char *p= buf, *buf_end= buf + size - 1;
int skip_char= 0;
enum {R_NORMAL, R_Q, R_SLASH_IN_Q,
@ -5366,14 +5437,24 @@ int read_line(char *buf, int size)
}
else if (my_isspace(charset_info, c))
{
/* Skip all space at begining of line */
if (c == '\n')
{
if (last_char == '\n')
{
/* Two new lines in a row, return empty line */
DBUG_PRINT("info", ("Found two new lines in a row"));
*p++= c;
*p= 0;
DBUG_RETURN(0);
}
/* Query hasn't started yet */
start_lineno= cur_file->lineno;
DBUG_PRINT("info", ("Query hasn't started yet, start_lineno: %d",
start_lineno));
}
/* Skip all space at begining of line */
skip_char= 1;
}
else if (end_of_query(c))
@ -5414,6 +5495,8 @@ int read_line(char *buf, int size)
}
last_char= c;
if (!skip_char)
{
/* Could be a multibyte character */
@ -5623,9 +5706,10 @@ int read_command(struct st_command** command_ptr)
DBUG_RETURN(1);
}
convert_to_format_v1(read_command_buf);
if (opt_result_format_version == 1)
convert_to_format_v1(read_command_buf);
DBUG_PRINT("info", ("query: %s", read_command_buf));
DBUG_PRINT("info", ("query: '%s'", read_command_buf));
if (*p == '#')
{
command->type= Q_COMMENT;
@ -5635,6 +5719,10 @@ int read_command(struct st_command** command_ptr)
command->type= Q_COMMENT_WITH_COMMAND;
p+= 2; /* Skip past -- */
}
else if (*p == '\n')
{
command->type= Q_EMPTY_LINE;
}
/* Skip leading spaces */
while (*p && my_isspace(charset_info, *p))
@ -5729,10 +5817,21 @@ static struct my_option my_long_options[] =
{"result-file", 'R', "Read/Store result from/in this file.",
(uchar**) &result_file_name, (uchar**) &result_file_name, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"result-format-version", OPT_RESULT_FORMAT_VERSION,
"Version of the result file format to use",
(uchar**) &opt_result_format_version,
(uchar**) &opt_result_format_version, 0,
GET_INT, REQUIRED_ARG, 1, 1, 2, 0, 0, 0},
{"server-arg", 'A', "Send option value to embedded server as a parameter.",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"server-file", 'F', "Read embedded server arguments from file.",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#ifdef HAVE_SMEM
{"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME,
"Base name of shared memory.", (uchar**) &shared_memory_base_name,
(uchar**) &shared_memory_base_name, 0, GET_STR, REQUIRED_ARG, 0, 0, 0,
0, 0, 0},
#endif
{"silent", 's', "Suppress all normal output. Synonym for --quiet.",
(uchar**) &silent, (uchar**) &silent, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"skip-safemalloc", OPT_SKIP_SAFEMALLOC,
@ -5767,6 +5866,11 @@ static struct my_option my_long_options[] =
{"view-protocol", OPT_VIEW_PROTOCOL, "Use views for select",
(uchar**) &view_protocol, (uchar**) &view_protocol, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"connect_timeout", OPT_CONNECT_TIMEOUT,
"Number of seconds before connection timeout.",
(uchar**) &opt_connect_timeout,
(uchar**) &opt_connect_timeout, 0, GET_UINT, REQUIRED_ARG,
120, 0, 3600 * 12, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
@ -5927,6 +6031,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
sf_malloc_quick=1;
#endif
break;
case OPT_RESULT_FORMAT_VERSION:
set_result_format_version(opt_result_format_version);
break;
case 'V':
print_version();
exit(0);
@ -5940,7 +6047,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
int parse_args(int argc, char **argv)
{
load_defaults("my",load_default_groups,&argc,&argv);
if (load_defaults("my",load_default_groups,&argc,&argv))
exit(1);
default_argv= argv;
if ((handle_options(&argc, &argv, my_long_options, get_one_option)))
@ -6505,8 +6614,6 @@ void run_query_normal(struct st_connection *cn, struct st_command *command,
if (!disable_result_log)
{
ulonglong UNINIT_VAR(affected_rows); /* Ok to be undef if 'disable_info' is set */
if (res)
{
MYSQL_FIELD *fields= mysql_fetch_fields(res);
@ -6523,10 +6630,10 @@ void run_query_normal(struct st_connection *cn, struct st_command *command,
/*
Need to call mysql_affected_rows() before the "new"
query to find the warnings
query to find the warnings.
*/
if (!disable_info)
affected_rows= mysql_affected_rows(mysql);
append_info(ds, mysql_affected_rows(mysql), mysql_info(mysql));
/*
Add all warnings to the result. We can't do this if we are in
@ -6541,9 +6648,6 @@ void run_query_normal(struct st_connection *cn, struct st_command *command,
dynstr_append_mem(ds, ds_warnings->str, ds_warnings->length);
}
}
if (!disable_info)
append_info(ds, affected_rows, mysql_info(mysql));
}
if (res)
@ -6784,10 +6888,8 @@ void run_query_stmt(MYSQL *mysql, struct st_command *command,
MYSQL_STMT *stmt;
DYNAMIC_STRING ds_prepare_warnings;
DYNAMIC_STRING ds_execute_warnings;
ulonglong affected_rows;
DBUG_ENTER("run_query_stmt");
DBUG_PRINT("query", ("'%-.60s'", query));
LINT_INIT(affected_rows);
/*
Init a new stmt if it's not already one created for this connection
@ -6919,11 +7021,12 @@ void run_query_stmt(MYSQL *mysql, struct st_command *command,
}
/*
Need to grab affected rows information before getting
warnings here
Fetch info before fetching warnings, since it will be reset
otherwise.
*/
if (!disable_info)
affected_rows= mysql_affected_rows(mysql);
append_info(ds, mysql_stmt_affected_rows(stmt), mysql_info(mysql));
if (!disable_warnings)
{
@ -6936,21 +7039,17 @@ void run_query_stmt(MYSQL *mysql, struct st_command *command,
ds_warnings->length)
{
dynstr_append_mem(ds, "Warnings:\n", 10);
if (ds_warnings->length)
dynstr_append_mem(ds, ds_warnings->str,
ds_warnings->length);
if (ds_prepare_warnings.length)
dynstr_append_mem(ds, ds_prepare_warnings.str,
ds_prepare_warnings.length);
if (ds_execute_warnings.length)
dynstr_append_mem(ds, ds_execute_warnings.str,
ds_execute_warnings.length);
if (ds_warnings->length)
dynstr_append_mem(ds, ds_warnings->str,
ds_warnings->length);
if (ds_prepare_warnings.length)
dynstr_append_mem(ds, ds_prepare_warnings.str,
ds_prepare_warnings.length);
if (ds_execute_warnings.length)
dynstr_append_mem(ds, ds_execute_warnings.str,
ds_execute_warnings.length);
}
}
if (!disable_info)
append_info(ds, affected_rows, mysql_info(mysql));
}
end:
@ -6999,6 +7098,10 @@ int util_query(MYSQL* org_mysql, const char* query){
if (!(mysql= mysql_init(mysql)))
die("Failed in mysql_init()");
if (opt_connect_timeout)
mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT,
(void *) &opt_connect_timeout);
/* enable local infile, in non-binary builds often disabled by default */
mysql_options(mysql, MYSQL_OPT_LOCAL_INFILE, 0);
safe_connect(mysql, "util", org_mysql->host, org_mysql->user,
@ -7047,7 +7150,7 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags)
/*
Evaluate query if this is an eval command
*/
if (command->type == Q_EVAL)
if (command->type == Q_EVAL || command->type == Q_SEND_EVAL)
{
init_dynamic_string(&eval_query, "", command->query_len+256, 1024);
do_eval(&eval_query, command->query, command->end, FALSE);
@ -7594,8 +7697,8 @@ int main(int argc, char **argv)
my_init_dynamic_array(&q_lines, sizeof(struct st_command*), 1024, 1024);
if (hash_init(&var_hash, charset_info,
1024, 0, 0, get_var_key, var_free, MYF(0)))
if (my_hash_init(&var_hash, charset_info,
1024, 0, 0, get_var_key, var_free, MYF(0)))
die("Variable hash initialization failed");
var_set_string("$MYSQL_SERVER_VERSION", MYSQL_SERVER_VERSION);
@ -7658,6 +7761,9 @@ int main(int argc, char **argv)
st_connection *con= connections;
if (!( mysql_init(&con->mysql)))
die("Failed in mysql_init()");
if (opt_connect_timeout)
mysql_options(&con->mysql, MYSQL_OPT_CONNECT_TIMEOUT,
(void *) &opt_connect_timeout);
if (opt_compress)
mysql_options(&con->mysql,MYSQL_OPT_COMPRESS,NullS);
mysql_options(&con->mysql, MYSQL_OPT_LOCAL_INFILE, 0);
@ -7682,6 +7788,11 @@ int main(int argc, char **argv)
}
#endif
#ifdef HAVE_SMEM
if (shared_memory_base_name)
mysql_options(&con->mysql,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name);
#endif
if (!(con->name = my_strdup("default", MYF(MY_WME))))
die("Out of memory");
@ -7757,9 +7868,6 @@ int main(int argc, char **argv)
case Q_DISCONNECT:
case Q_DIRTY_CLOSE:
do_close_connection(command); break;
case Q_RPL_PROBE: do_rpl_probe(command); break;
case Q_ENABLE_RPL_PARSE: do_enable_rpl_parse(command); break;
case Q_DISABLE_RPL_PARSE: do_disable_rpl_parse(command); break;
case Q_ENABLE_QUERY_LOG: disable_query_log=0; break;
case Q_DISABLE_QUERY_LOG: disable_query_log=1; break;
case Q_ENABLE_ABORT_ON_ERROR: abort_on_error=1; break;
@ -7801,6 +7909,7 @@ int main(int argc, char **argv)
case Q_MOVE_FILE: do_move_file(command); break;
case Q_CHMOD_FILE: do_chmod_file(command); break;
case Q_PERL: do_perl(command); break;
case Q_RESULT_FORMAT_VERSION: do_result_format_version(command); break;
case Q_DELIMITER:
do_delimiter(command);
break;
@ -7866,6 +7975,7 @@ int main(int argc, char **argv)
break;
}
case Q_SEND:
case Q_SEND_EVAL:
if (!*command->first_argument)
{
/*
@ -7917,9 +8027,38 @@ int main(int argc, char **argv)
do_sync_with_master2(command, 0);
break;
}
case Q_COMMENT: /* Ignore row */
case Q_COMMENT:
{
command->last_argument= command->end;
/* Don't output comments in v1 */
if (opt_result_format_version == 1)
break;
/* Don't output comments if query logging is off */
if (disable_query_log)
break;
/* Write comment's with two starting #'s to result file */
const char* p= command->query;
if (p && *p == '#' && *(p+1) == '#')
{
dynstr_append_mem(&ds_res, command->query, command->query_len);
dynstr_append(&ds_res, "\n");
}
break;
}
case Q_EMPTY_LINE:
/* Don't output newline in v1 */
if (opt_result_format_version == 1)
break;
/* Don't output newline if query logging is off */
if (disable_query_log)
break;
dynstr_append(&ds_res, "\n");
break;
case Q_PING:
handle_command_error(command, mysql_ping(&cur_con->mysql));
break;
@ -8935,7 +9074,7 @@ REPLACE *init_replace(char * *from, char * *to,uint count,
free_sets(&sets);
DBUG_RETURN(0);
}
VOID(make_new_set(&sets)); /* Set starting set */
(void) make_new_set(&sets); /* Set starting set */
make_sets_invisible(&sets); /* Hide previus sets */
used_sets=-1;
word_states=make_new_set(&sets); /* Start of new word */
@ -9406,7 +9545,7 @@ int insert_pointer_name(reg1 POINTER_ARRAY *pa,char * name)
pa->flag[pa->typelib.count]=0; /* Reset flag */
pa->typelib.type_names[pa->typelib.count++]= (char*) pa->str+pa->length;
pa->typelib.type_names[pa->typelib.count]= NullS; /* Put end-mark */
VOID(strmov((char*) pa->str+pa->length,name));
(void) strmov((char*) pa->str+pa->length,name);
pa->length+=length;
DBUG_RETURN(0);
} /* insert_pointer_name */

View File

@ -23,6 +23,7 @@
#include <my_sys.h>
#include <m_string.h>
#include <m_ctype.h>
#include <mysql_com.h>
#ifdef HAVE_FCONVERT
#include <floatingpoint.h>
#endif
@ -129,7 +130,7 @@ bool String::set(double num,uint decimals, CHARSET_INFO *cs)
int decpt,sign;
char *pos,*to;
VOID(fconvert(num,(int) decimals,&decpt,&sign,buff+1));
(void) fconvert(num,(int) decimals,&decpt,&sign,buff+1);
if (!my_isdigit(&my_charset_latin1, buff[1]))
{ // Nan or Inf
pos=buff+1;

View File

@ -1,3 +1,6 @@
#ifndef CLIENT_SQL_STRING_INCLUDED
#define CLIENT_SQL_STRING_INCLUDED
/* Copyright (C) 2000 MySQL AB
This program is free software; you can redistribute it and/or modify
@ -19,10 +22,6 @@
#pragma interface /* gcc class implementation */
#endif
#ifndef NOT_FIXED_DEC
#define NOT_FIXED_DEC 31
#endif
class String;
int sortcmp(const String *a,const String *b, CHARSET_INFO *cs);
String *copy_if_not_alloced(String *a,String *b,uint32 arg_length);
@ -353,3 +352,5 @@ public:
return (s->alloced && Ptr >= s->Ptr && Ptr < s->Ptr + s->str_length);
}
};
#endif /* CLIENT_SQL_STRING_INCLUDED */

View File

@ -1,3 +0,0 @@
.deps
Makefile
Makefile.in

View File

@ -14,7 +14,7 @@ DTRACEFLAGS=""
HAVE_DTRACE=""
HAVE_DTRACE_DASH_G=""
if test "$ENABLE_DTRACE" = "yes"; then
AC_CHECK_PROGS(DTRACE, dtrace, [not found], [$PATH:/usr/sbin])
AC_PATH_PROGS(DTRACE, dtrace, [not found], [$PATH:/usr/sbin])
if test "$DTRACE" = "not found"; then
ENABLE_DTRACE="no"
else

View File

@ -601,15 +601,15 @@ dnl ---------------------------------------------------------------------------
dnl MYSQL_NEEDS_MYSYS_NEW
AC_DEFUN([MYSQL_NEEDS_MYSYS_NEW],
[AC_CACHE_CHECK([needs mysys_new helpers], mysql_use_mysys_new,
[AC_CACHE_CHECK([needs mysys_new helpers], mysql_cv_use_mysys_new,
[
AC_LANG_PUSH(C++)
AC_TRY_LINK([], [
class A { public: int b; }; A *a=new A; a->b=10; delete a;
], mysql_use_mysys_new=no, mysql_use_mysys_new=yes)
], mysql_cv_use_mysys_new=no, mysql_cv_use_mysys_new=yes)
AC_LANG_POP(C++)
])
if test "$mysql_use_mysys_new" = "yes"
if test "$mysql_cv_use_mysys_new" = "yes"
then
AC_DEFINE([USE_MYSYS_NEW], [1], [Needs to use mysys_new helpers])
fi

View File

@ -1,6 +1,21 @@
dnl -*- ksh -*-
dnl Process this file with autoconf to produce a configure script.
# Copyright (C) 2008-2009 Sun Microsystems, Inc
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
AC_PREREQ(2.52)dnl Minimum Autoconf version required.
AC_INIT(sql/mysqld.cc)
@ -10,9 +25,15 @@ AC_CANONICAL_SYSTEM
#
# When changing major version number please also check switch statement
# in client/mysqlbinlog.cc:check_master_version().
AM_INIT_AUTOMAKE(mysql, 5.5.0-beta)
AM_INIT_AUTOMAKE(mysql, 5.5.99)
AM_CONFIG_HEADER([include/config.h:config.h.in])
# Request support for automake silent-rules if available.
# Default to verbose output. One can use the configure-time
# option --enable-silent-rules or make V=0 to activate
# silent rules.
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([no])])
PROTOCOL_VERSION=10
DOT_FRM_VERSION=6
# See the libtool docs for information on how to do shared lib versions.
@ -617,24 +638,6 @@ then
fi
fi
AC_MSG_CHECKING(whether features provided by the user community should be included.)
AC_ARG_ENABLE(community-features,
AC_HELP_STRING(
[--disable-community-features],
[Disable additional features provided by the user community.]),
[ ENABLE_COMMUNITY_FEATURES=$enableval ],
[ ENABLE_COMMUNITY_FEATURES=yes ]
)
if test "$ENABLE_COMMUNITY_FEATURES" = "yes"
then
AC_DEFINE([COMMUNITY_SERVER], [1],
[Whether features provided by the user community should be included])
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
AC_ARG_WITH(server-suffix,
[ --with-server-suffix Append value to the version string.],
[ MYSQL_SERVER_SUFFIX=`echo "$withval" | sed -e 's/^\(...................................\)..*$/\1/'` ],
@ -700,21 +703,14 @@ fi
# Add query profiler
AC_MSG_CHECKING(if SHOW PROFILE should be enabled.)
AC_ARG_ENABLE(profiling,
AS_HELP_STRING([--enable-profiling], [Build a version with query profiling code (req. community-features)]),
AS_HELP_STRING([--enable-profiling], [Enable profiling of query lifetime.]),
[ ENABLED_PROFILING=$enableval ],
[ ENABLED_PROFILING=$ENABLE_COMMUNITY_FEATURES ])
[ ENABLED_PROFILING=no ])
AC_DEFINE([ENABLED_PROFILING], [1], [If SHOW PROFILE should be enabled])
if test "$ENABLED_PROFILING" = "yes"
then
if test "$ENABLE_COMMUNITY_FEATURES" = "yes";
then
AC_DEFINE([ENABLED_PROFILING], [1],
[If SHOW PROFILE should be enabled])
AC_MSG_RESULT([yes])
else
ENABLED_PROFILING="no"
AC_MSG_RESULT([no, overridden by community-features disabled])
fi
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
@ -888,6 +884,42 @@ AC_CHECK_DECLS(MHA_MAPSIZE_VA,
fi
#--------------------------------------------------------------------
# Check for IPv6 support
#--------------------------------------------------------------------
AC_CHECK_HEADERS(netinet/in6.h)
AC_CHECK_TYPES([struct sockaddr_in6, struct in6_addr],
[have_in6_types=yes],
[have_in6_types=no],
[[
#ifdef WIN32
#include <winsock2.h>
#else
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN6_H
#include <netinet/in6.h>
#endif
]])
AC_MSG_CHECKING([for IPv6 support])
AC_ARG_ENABLE(ipv6,
AS_HELP_STRING([--disable-ipv6], [Disable support for IPv6 networking]),
[disable_ipv6=yes], [disable_ipv6=no])
if test x"$disable_ipv6" = xyes -o x"$have_in6_types" = xno; then
AC_MSG_RESULT([no])
else
AC_DEFINE([HAVE_IPV6], [1], [Define if IPv6 networking support is present])
AC_MSG_RESULT([yes])
fi
#--------------------------------------------------------------------
# Check for TCP wrapper support
#--------------------------------------------------------------------
@ -986,12 +1018,6 @@ AC_CHECK_TYPES([int8, uint8, int16, uint16, int32, uint32, int64, uint64,
uchar, uint, ulong],[],[], [
#include <sys/types.h>
])
AC_CHECK_TYPES([in_addr_t], [], [], [
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
])
AC_CHECK_TYPES([fp_except], [], [], [
#include <sys/types.h>
#include <ieeefp.h>
@ -1775,64 +1801,74 @@ then
fi
AC_ARG_WITH([atomic-ops],
AC_HELP_STRING([--with-atomic-ops=rwlocks|smp|up],
[Implement atomic operations using pthread rwlocks or atomic CPU
instructions for multi-processor (default) or uniprocessor
configuration]), , [with_atomic_ops=smp])
AS_HELP_STRING([--with-atomic-ops=rwlocks|smp|up],
[Implement atomic operations using pthread rwlocks or atomic CPU
instructions for multi-processor or uniprocessor
configuration. By default gcc built-in sync functions are used,
if available and 'smp' configuration otherwise.]))
case "$with_atomic_ops" in
"up") AC_DEFINE([MY_ATOMIC_MODE_DUMMY], [1],
[Assume single-CPU mode, no concurrency]) ;;
"rwlocks") AC_DEFINE([MY_ATOMIC_MODE_RWLOCKS], [1],
[Use pthread rwlocks for atomic ops]) ;;
"smp") ;;
"")
;;
*) AC_MSG_ERROR(["$with_atomic_ops" is not a valid value for --with-atomic-ops]) ;;
esac
AC_CACHE_CHECK([whether the compiler provides atomic builtins],
[mysql_cv_gcc_atomic_builtins], [AC_TRY_RUN([
int main()
{
int foo= -10; int bar= 10;
if (!__sync_fetch_and_add(&foo, bar) || foo)
return -1;
bar= __sync_lock_test_and_set(&foo, bar);
if (bar || foo != 10)
return -1;
bar= __sync_val_compare_and_swap(&bar, foo, 15);
if (bar)
return -1;
return 0;
}
], [mysql_cv_gcc_atomic_builtins=yes],
[mysql_cv_gcc_atomic_builtins],
[AC_RUN_IFELSE(
[AC_LANG_PROGRAM(
[
],
[[
int foo= -10; int bar= 10;
if (!__sync_fetch_and_add(&foo, bar) || foo)
return -1;
bar= __sync_lock_test_and_set(&foo, bar);
if (bar || foo != 10)
return -1;
bar= __sync_val_compare_and_swap(&bar, foo, 15);
if (bar)
return -1;
return 0;
]]
)],
[mysql_cv_gcc_atomic_builtins=yes],
[mysql_cv_gcc_atomic_builtins=no],
[mysql_cv_gcc_atomic_builtins=no])])
[mysql_cv_gcc_atomic_builtins=no]
)])
if test "x$mysql_cv_gcc_atomic_builtins" = xyes; then
AC_DEFINE(HAVE_GCC_ATOMIC_BUILTINS, 1,
[Define to 1 if compiler provides atomic builtins.])
fi
AC_CACHE_CHECK([whether the OS provides atomic_* functions like Solaris],
[mysql_cv_solaris_atomic], [AC_TRY_RUN([
#include <atomic.h>
int
main()
{
int foo = -10; int bar = 10;
if (atomic_add_int_nv((uint_t *)&foo, bar) || foo)
return -1;
bar = atomic_swap_uint((uint_t *)&foo, (uint_t)bar);
if (bar || foo != 10)
return -1;
bar = atomic_cas_uint((uint_t *)&bar, (uint_t)foo, 15);
if (bar)
return -1;
return 0;
}
], [mysql_cv_solaris_atomic=yes],
[mysql_cv_solaris_atomic],
[AC_RUN_IFELSE(
[AC_LANG_PROGRAM(
[
#include <atomic.h>
]
[[
int foo = -10; int bar = 10;
if (atomic_add_int_nv((uint_t *)&foo, bar) || foo)
return -1;
bar = atomic_swap_uint((uint_t *)&foo, (uint_t)bar);
if (bar || foo != 10)
return -1;
bar = atomic_cas_uint((uint_t *)&bar, (uint_t)foo, 15);
if (bar)
return -1;
return 0;
]]
)],
[mysql_cv_solaris_atomic=yes],
[mysql_cv_solaris_atomic=no],
[mysql_cv_solaris_atomic=no])])
[mysql_cv_solaris_atomic=no]
)])
if test "x$mysql_cv_solaris_atomic" = xyes; then
AC_DEFINE(HAVE_SOLARIS_ATOMIC, 1,
[Define to 1 if OS provides atomic_* functions like Solaris.])
@ -2048,10 +2084,11 @@ AC_SUBST(MAKE_SHELL)
AC_CHECK_HEADERS(varargs.h stdarg.h dirent.h locale.h ndir.h sys/dir.h \
sys/file.h sys/ndir.h sys/ptem.h sys/pte.h sys/select.h sys/stream.h \
sys/mman.h curses.h termcap.h termio.h termbits.h asm/termbits.h grp.h \
paths.h semaphore.h)
paths.h semaphore.h langinfo.h)
# Already-done: strcasecmp
AC_CHECK_FUNCS(lstat putenv select setenv setlocale strcoll tcgetattr)
AC_CHECK_FUNCS(nl_langinfo)
AC_STAT_MACROS_BROKEN
MYSQL_SIGNAL_CHECK
@ -2122,13 +2159,11 @@ AC_CHECK_FUNCS(alarm bcmp bfill bmove bsearch bzero \
localtime_r gethrtime gmtime_r \
locking longjmp lrand48 madvise mallinfo memcpy memmove \
mkstemp mlockall perror poll pread pthread_attr_create mmap mmap64 getpagesize \
pthread_attr_getstacksize pthread_attr_setprio pthread_attr_setschedparam \
pthread_attr_setstacksize pthread_condattr_create pthread_getsequence_np \
pthread_key_delete pthread_rwlock_rdlock pthread_setprio \
pthread_setprio_np pthread_setschedparam pthread_sigmask readlink \
realpath rename rint rwlock_init setupterm \
pthread_attr_getstacksize pthread_attr_setstacksize pthread_condattr_create \
pthread_getsequence_np pthread_key_delete pthread_rwlock_rdlock pthread_sigmask \
readlink realpath rename rint rwlock_init setupterm \
shmget shmat shmdt shmctl sigaction sigemptyset sigaddset \
sighold sigset sigthreadmask port_create sleep \
sighold sigset sigthreadmask port_create sleep thr_yield \
snprintf socket stpcpy strcasecmp strerror strsignal strnlen strpbrk strstr \
strtol strtoll strtoul strtoull tell tempnam thr_setconcurrency vidattr \
posix_fallocate backtrace backtrace_symbols backtrace_symbols_fd)
@ -2930,7 +2965,54 @@ case $SYSTEM_TYPE in
esac
AC_SUBST(MAKE_BINARY_DISTRIBUTION_OPTIONS)
#--------------------------------------------------------------------
# Support for WL#2373 (Use cycle counter for timing)
#--------------------------------------------------------------------
AC_CHECK_HEADERS(time.h)
AC_CHECK_HEADERS(sys/time.h)
AC_CHECK_HEADERS(sys/times.h)
AC_CHECK_HEADERS(asm/msr.h)
#msr.h has rdtscll()
AC_CHECK_HEADERS(ia64intrin.h)
AC_CHECK_FUNCS(times)
AC_CHECK_FUNCS(gettimeofday)
AC_CHECK_FUNCS(read_real_time)
# This should work on AIX.
AC_CHECK_FUNCS(ftime)
# This is still a normal call for milliseconds.
AC_CHECK_FUNCS(time)
# We can use time() on Macintosh if there is no ftime().
AC_CHECK_FUNCS(rdtscll)
# I doubt that we'll ever reach the check for this.
# When compiling with Sun Studio C / C++ we need to include
# my_timer_cycles.il, an "inline templates" separate file,
# on the command line. It has assembly code, "rd %tick" for
# SPARC or "rdtsc" for x86.
RDTSC_SPARC_ASSEMBLY=""
case $CC_VERSION in
*Sun*C*)
RDTSC_SPARC_ASSEMBLY="my_timer_cycles.il"
;;
esac
case $CXX_VERSION in
*Sun*C++*)
RDTSC_SPARC_ASSEMBLY="my_timer_cycles.il"
;;
esac
AC_SUBST([RDTSC_SPARC_ASSEMBLY])
#--------------------------------------------------------------------
# Output results
#--------------------------------------------------------------------
if test -d "$srcdir/pstack" ; then
AC_CONFIG_FILES(pstack/Makefile pstack/aout/Makefile)
fi
@ -2945,7 +3027,7 @@ AC_CONFIG_FILES(Makefile extra/Makefile mysys/Makefile dnl
man/Makefile BUILD/Makefile vio/Makefile dnl
libmysql/Makefile libmysql_r/Makefile client/Makefile dnl
sql/Makefile sql/share/Makefile dnl
sql/sql_builtin.cc sql-common/Makefile dnl
sql/sql_builtin.cc sql-common/Makefile libservices/Makefile dnl
dbug/Makefile scripts/Makefile include/Makefile dnl
tests/Makefile Docs/Makefile support-files/Makefile dnl
support-files/MacOSX/Makefile support-files/RHEL4-SElinux/Makefile dnl

View File

@ -1,3 +0,0 @@
.deps
Makefile
Makefile.in

View File

@ -23,19 +23,20 @@ libdbug_a_SOURCES = dbug.c sanity.c
EXTRA_DIST = CMakeLists.txt example1.c example2.c example3.c \
user.r monty.doc dbug_add_tags.pl \
my_main.c main.c factorial.c dbug_analyze.c \
CMakeLists.txt
CMakeLists.txt tests.c tests-t.pl
NROFF_INC = example1.r example2.r example3.r main.r \
factorial.r output1.r output2.r output3.r \
output4.r output5.r
CLEANFILES = $(NROFF_INC) user.t user.ps
CLEANFILES = $(NROFF_INC) user.t user.ps tests-t
# Must be linked with libs that are not compiled yet
noinst_PROGRAMS = factorial dbug_analyze
noinst_PROGRAMS = factorial dbug_analyze tests
factorial_SOURCES = my_main.c factorial.c
tests_SOURCES = tests.c
dbug_analyze_SOURCES = dbug_analyze.c
all: user.t user.ps
all: user.t user.ps tests-t
user.t: user.r $(NROFF_INC)
-nroff -mm user.r > $@
@ -61,5 +62,7 @@ output5.r: factorial
@RM@ -f $@
@SED@ -e 's!\\!\\\\!g' $< > $@
# Don't update the files from bitkeeper
%::SCCS/s.%
# a hack to have executable in builddir, not in srcdir
tests-t: tests-t.pl
cp -f $(srcdir)/tests-t.pl ./tests-t

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,7 @@ $ctags="exctags -x -f - --c-types=f -u";
sub get_tag {
local $.; local $_=<TAGS>;
($symbol, $line)= /^(.*\S)\s+function\s+(\d+)/;
$symbol=$1 if /\s(\S+)\s*\(/;
$symbol=$1 if /[\s*]([^\s*]+)\s*\(/;
$line=1e50 unless $line;
}
@ -51,7 +51,7 @@ while($src=shift)
$skip=!$semicolon;
$semicolon= /;\s*$/;
print && next if $skip ||
(/^\s+\w+((::\w+)?|<\w+>)\s+\**\w+/ && !/^\s*return/);
(/^\s+\w+((::\w+)?|<\w+>)\s+\**\w+/ && !/^\s*return\b/);
last if /DBUG_ENTER/;
print "$tab DBUG_ENTER(\"$symbol\");\n";
print "\n" unless $_ eq "\n";

View File

@ -1,15 +0,0 @@
# Warning - first line left blank for sh/csh/ksh compatibility. Do not
# remove it. fnf@Unisoft
# doinstall.sh --- figure out environment and do recursive make with
# appropriate pathnames. Works under SV or BSD.
if [ -r /usr/include/search.h ]
then
# System V
$* LLIB=/usr/lib
else
# 4.2 BSD
$* LLIB=/usr/lib/lint
fi

View File

@ -1,64 +0,0 @@
# WARNING -- first line intentionally left blank for sh/csh/ksh
# compatibility. Do not remove it! FNF, UniSoft Systems.
#
# Usage is:
# install <from> <to>
#
# The file <to> is replaced with the file <from>, after first
# moving <to> to a backup file. The backup file name is created
# by prepending the filename (after removing any leading pathname
# components) with "OLD".
#
# This script is currently not real robust in the face of signals
# or permission problems. It also does not do (by intention) all
# the things that the System V or BSD install scripts try to do
#
if [ $# -ne 2 ]
then
echo "usage: $0 <from> <to>"
exit 1
fi
# Now extract the dirname and basename components. Unfortunately, BSD does
# not have dirname, so we do it the hard way.
fd=`expr $1'/' : '\(/\)[^/]*/$' \| $1'/' : '\(.*[^/]\)//*[^/][^/]*//*$' \| .`
ff=`basename $1`
td=`expr $2'/' : '\(/\)[^/]*/$' \| $2'/' : '\(.*[^/]\)//*[^/][^/]*//*$' \| .`
tf=`basename $2`
# Now test to make sure that they are not the same files.
if [ $fd/$ff = $td/$tf ]
then
echo "install: input and output are same files"
exit 2
fi
# Save a copy of the "to" file as a backup.
if test -f $td/$tf
then
if test -f $td/OLD$tf
then
rm -f $td/OLD$tf
fi
mv $td/$tf $td/OLD$tf
if [ $? != 0 ]
then
exit 3
fi
fi
# Now do the copy and return appropriate status
cp $fd/$ff $td/$tf
if [ $? != 0 ]
then
exit 4
else
exit 0
fi

View File

@ -1,30 +0,0 @@
# Warning - first line left blank for sh/csh/ksh compatibility. Do not
# remove it. fnf@Unisoft
# mklintlib --- make a lint library, under either System V or 4.2 BSD
#
# usage: mklintlib <infile> <outfile>
#
if test $# -ne 2
then
echo "usage: mklintlib <infile> <outfile>"
exit 1
fi
if grep SIGTSTP /usr/include/signal.h >/dev/null
then # BSD
if test -r /usr/include/whoami.h # 4.1
then
/lib/cpp -C -Dlint $1 >hlint
(/usr/lib/lint/lint1 <hlint >$2) 2>&1 | grep -v warning
else # 4.2
lint -Cxxxx $1
mv llib-lxxxx.ln $2
fi
else # USG
cc -E -C -Dlint $1 | /usr/lib/lint1 -vx -Hhlint >$2
rm -f hlint
fi
exit 0 # don't kill make

View File

@ -1,4 +0,0 @@
CL -I\my\include -AL -Gsm2 -FPi -DDBUG_OFF *.c
rm \my\lib\dbug.lib
lib.exe \my\lib\dbug dbug.obj sanity.obj;
link /NOD /STACK:8000 main factoria,factoria,,DBUG+STRINGS+LLIBCEP+DOSCALLS;

View File

@ -0,0 +1,26 @@
#!/usr/bin/perl
die <<EEE unless @ARGV;
Usage: $0 func1 [func2 [ ...] ]
This filter (stdin->stdout) removes lines from dbug trace that were generated
by specified functions and all functions down the call stack. Produces the
same effect as if the original source had DBUG_PUSH(""); right after
DBUG_ENTER() and DBUG_POP(); right before DBUG_RETURN in every such a function.
EEE
$re=join('|', @ARGV);
$skip='';
while(<STDIN>) {
print unless $skip;
next unless /^(?:.*: )*((?:\| )*)([<>])($re)\n/o;
if ($2 eq '>') {
$skip=$1.$3 unless $skip;
next;
}
next if $skip ne $1.$3;
$skip='';
print;
}

496
dbug/tests-t.pl Executable file
View File

@ -0,0 +1,496 @@
#!/usr/bin/env perl
#
# A driver program to test DBUG features - runs tests (shell commands)
# from the end of file to invoke tests.c, which does the real dbug work.
#
use Test::More;
$exe=$0;
die unless $exe =~ s/(tests)-t(\.exe)?$/$1$2 /;
# load tests
@tests=();
while (<DATA>) {
if (/^% \.\/tests /) {
push @tests, [ $' ]
} elsif (/^#/) {
next;
} else {
push @{$tests[$#tests]}, $_
}
}
plan skip_all => "because dbug is disabled" if system $exe;
plan tests => scalar(@tests);
for (@tests) {
$t=$exe . shift @$_;
chomp($t);
open F, '-|', $t or die "open($t|): $!";
local $";
$out=join($", <F>); close(F);
# special cases are handled here:
$out =~ s/Memory: 0x[0-9A-Fa-f]+/Memory: 0x####/g if $t =~ /dump/;
# compare ("\n" at the beginning makes better output in case of errors)
is("\n$out","\n@$_", $t);
}
__DATA__
% ./tests -#d
func2: info: s=ok
=> execute
=> evaluate: ON
=> evaluate_if: OFF
main: explain: dbug explained: d
func2: info: s=ok
% ./tests d,ret3
=> evaluate: OFF
=> evaluate_if: OFF
#
## Testing negative lists
#
% ./tests d:-d,ret3
func2: info: s=ko
=> execute
=> evaluate: ON
=> evaluate_if: OFF
main: explain: dbug explained: d:-d,ret3
func2: info: s=ko
% ./tests t:-d,ret3
>main
| >func1
| | >func2
| | | >func3
| | | <func3
| | <func2
| <func1
=> evaluate: OFF
=> evaluate_if: OFF
| >func2
| | >func3
| | <func3
| <func2
<main
% ./tests t:d,info:-d,ret3
>main
| >func1
| | >func2
| | | >func3
| | | <func3
| | | info: s=ko
| | <func2
| <func1
=> evaluate: OFF
=> evaluate_if: OFF
| >func2
| | >func3
| | <func3
| | info: s=ko
| <func2
<main
% ./tests t:d,info:-d,ret3:-f,func2
>main
| >func1
| | | >func3
| | | <func3
| <func1
=> evaluate: OFF
=> evaluate_if: OFF
| | >func3
| | <func3
<main
% ./tests t:d,info:-d,ret3:-f,func2 d,evaluate
=> evaluate: ON
=> evaluate_if: OFF
% ./tests t:d,info:-d,ret3:-f,func2 d,evaluate_if
=> evaluate: OFF
=> evaluate_if: ON
% ./tests t:d:-d,ret3:-f,func2 d,evaluate_if
=> evaluate: OFF
=> evaluate_if: ON
% ./tests t:d:-d,ret3:-f,func2
>main
| >func1
| | | >func3
| | | <func3
| <func1
=> execute
=> evaluate: ON
=> evaluate_if: OFF
| explain: dbug explained: d:-d,ret3:f:-f,func2:t
| | >func3
| | <func3
<main
#
## Adding incremental settings to the brew
#
% ./tests t:d:-d,ret3:-f,func2 +d,evaluate_if
>main
| >func1
| | | >func3
| | | <func3
| <func1
=> evaluate: OFF
=> evaluate_if: ON
| | >func3
| | <func3
<main
#
## DBUG_DUMP
#
% ./tests t:d:-d,ret3:f:-f,func2 +d,dump
>main
| >func1
| | | >func3
| | | <func3
| <func1
| dump: Memory: 0x#### Bytes: (27)
64 2C 64 75 6D 70 3A 2D 64 2C 72 65 74 33 3A 66 3A 2D 66 2C 66 75 6E 63 32 3A
74
=> evaluate: OFF
=> evaluate_if: OFF
| | >func3
| | <func3
<main
% ./tests t:d:-d,ret3:f:-f,func2 +d,dump
>main
| >func1
| | | >func3
| | | <func3
| <func1
| dump: Memory: 0x#### Bytes: (27)
64 2C 64 75 6D 70 3A 2D 64 2C 72 65 74 33 3A 66 3A 2D 66 2C 66 75 6E 63 32 3A
74
=> evaluate: OFF
=> evaluate_if: OFF
| | >func3
| | <func3
<main
% ./tests t:d:-d,ret3:f:-f,func2:+d,dump
>main
| >func1
| | | >func3
| | | <func3
| <func1
| dump: Memory: 0x#### Bytes: (27)
64 2C 64 75 6D 70 3A 2D 64 2C 72 65 74 33 3A 66 3A 2D 66 2C 66 75 6E 63 32 3A
74
=> evaluate: OFF
=> evaluate_if: OFF
| | >func3
| | <func3
<main
% ./tests t:d:-d,ret3:f:-f,func2 +d,dump,explain
>main
| >func1
| | | >func3
| | | <func3
| <func1
| dump: Memory: 0x#### Bytes: (35)
64 2C 64 75 6D 70 2C 65 78 70 6C 61 69 6E 3A 2D 64 2C 72 65 74 33 3A 66 3A 2D
66 2C 66 75 6E 63 32 3A 74
=> evaluate: OFF
=> evaluate_if: OFF
| explain: dbug explained: d,dump,explain:-d,ret3:f:-f,func2:t
| | >func3
| | <func3
<main
% ./tests t:d:-d,ret3:f:-f,func2 +d,dump,explain:P
dbug: >main
dbug-tests: | >func1
dbug-tests: | | | >func3
dbug-tests: | | | <func3
dbug-tests: | <func1
dbug-tests: | dump: Memory: 0x#### Bytes: (37)
64 2C 64 75 6D 70 2C 65 78 70 6C 61 69 6E 3A 2D 64 2C 72 65 74 33 3A 66 3A 2D
66 2C 66 75 6E 63 32 3A 50 3A 74
=> evaluate: OFF
=> evaluate_if: OFF
dbug-tests: | explain: dbug explained: d,dump,explain:-d,ret3:f:-f,func2:P:t
dbug-tests: | | >func3
dbug-tests: | | <func3
dbug-tests: <main
% ./tests t:d:-d,ret3:f:-f,func2 +d,dump,explain:P:F
dbug: tests.c: >main
dbug-tests: tests.c: | >func1
dbug-tests: tests.c: | | | >func3
dbug-tests: tests.c: | | | <func3
dbug-tests: tests.c: | <func1
dbug-tests: tests.c: | dump: Memory: 0x#### Bytes: (39)
64 2C 64 75 6D 70 2C 65 78 70 6C 61 69 6E 3A 2D 64 2C 72 65 74 33 3A 66 3A 2D
66 2C 66 75 6E 63 32 3A 46 3A 50 3A 74
=> evaluate: OFF
=> evaluate_if: OFF
dbug-tests: tests.c: | explain: dbug explained: d,dump,explain:-d,ret3:f:-f,func2:F:P:t
dbug-tests: tests.c: | | >func3
dbug-tests: tests.c: | | <func3
dbug-tests: tests.c: <main
#
## DBUG_EXPLAIN, DBUG_PUSH, DBUG_POP, DBUG_SET
#
% ./tests t:d:-d,ret3:f:-f,func2
>main
| >func1
| | | >func3
| | | <func3
| <func1
=> execute
=> evaluate: ON
=> evaluate_if: OFF
| explain: dbug explained: d:-d,ret3:f:-f,func2:t
| | >func3
| | <func3
<main
% ./tests t:d:-d,ret3
>main
| >func1
| | >func2
| | | >func3
| | | <func3
| | | info: s=ko
| | <func2
| <func1
=> execute
=> evaluate: ON
=> evaluate_if: OFF
| explain: dbug explained: d:-d,ret3:t
| >func2
| | >func3
| | <func3
| | info: s=ko
| <func2
<main
% ./tests d,info:-d,ret3:d,push
func2: info: s=ko
=> evaluate: OFF
=> evaluate_if: OFF
| >func2
| | >func3
| | <func3
| | info: s=ko
| <func2
<main
% ./tests d,info:-d,ret3:d,push,explain
func2: info: s=ko
=> evaluate: OFF
=> evaluate_if: OFF
| explain: dbug explained: d,info,push,explain:-d,ret3:t
| >func2
| | >func3
| | <func3
| | info: s=ko
| <func2
<main
% ./tests d,info:-d,ret3:d,explain
func2: info: s=ko
=> evaluate: OFF
=> evaluate_if: OFF
main: explain: dbug explained: d,info,explain:-d,ret3
func2: info: s=ko
% ./tests d,info:-d,ret3:d,explain,pop
func2: info: s=ko
=> evaluate: OFF
=> evaluate_if: OFF
% ./tests d,info:-d,ret3:d,explain t:d,pop
>main
| >func1
| | >func2
| | | >func3
| | | <func3
| | <func2
| <func1
=> evaluate: OFF
=> evaluate_if: OFF
main: explain: dbug explained: d,info,explain:-d,ret3
func2: info: s=ko
% ./tests d,info:-d,ret3:d,explain,pop +t
>main
| >func1
| | >func2
| | | >func3
| | | <func3
| | | info: s=ko
| | <func2
| <func1
=> evaluate: OFF
=> evaluate_if: OFF
main: explain: dbug explained: d,info,explain,pop:-d,ret3
func2: info: s=ko
% ./tests d,info:-d,ret3:d,explain,set
func2: info: s=ko
=> evaluate: OFF
=> evaluate_if: OFF
tests.c: main: explain: dbug explained: d,info,explain,set:-d,ret3:F
tests.c: func2: info: s=ko
% ./tests d,info:-d,ret3:d,explain,set:t
>main
| >func1
| | >func2
| | | >func3
| | | <func3
| | | info: s=ko
| | <func2
| <func1
=> evaluate: OFF
=> evaluate_if: OFF
tests.c: | explain: dbug explained: d,info,explain,set:-d,ret3:F:t
tests.c: | >func2
tests.c: | | >func3
tests.c: | | <func3
tests.c: | | info: s=ko
tests.c: | <func2
tests.c: <main
% ./tests t d,info:-d,ret3:d,explain,set:t
>main
| >func1
| | >func2
| | | >func3
| | | <func3
| | | info: s=ko
| | <func2
| <func1
=> evaluate: OFF
=> evaluate_if: OFF
tests.c: | explain: dbug explained: d,info,explain,set:-d,ret3:F:t
tests.c: | >func2
tests.c: | | >func3
tests.c: | | <func3
tests.c: | | info: s=ko
tests.c: | <func2
tests.c: <main
% ./tests t d,info:-d,ret3:d,explain,set,pop
func2: info: s=ko
=> evaluate: OFF
=> evaluate_if: OFF
| >func2
| | >func3
| | <func3
| <func2
<main
% ./tests t:f,func2
| | >func2
| | <func2
=> evaluate: OFF
=> evaluate_if: OFF
| >func2
| <func2
#
## Testing SUBDIR rules
#
% ./tests t:-f,func2/:d
>main
| >func1
| <func1
=> execute
=> evaluate: ON
=> evaluate_if: OFF
| explain: dbug explained: d:f:-f,func2/:t
<main
% ./tests t:f,func1/:d
| >func1
| | >func2
| | | >func3
| | | <func3
| | | info: s=ok
| | <func2
| <func1
=> evaluate: OFF
=> evaluate_if: OFF
% ./tests t:f,main/:d,pop
>main
| >func1
| | >func2
| | | >func3
| | | <func3
| | <func2
| <func1
=> evaluate: OFF
=> evaluate_if: OFF
% ./tests f,main/:d,push
=> evaluate: OFF
=> evaluate_if: OFF
| >func2
| | >func3
| | <func3
| <func2
<main
#
## Testing FixTraceFlags() - when we need to traverse the call stack
# (these tests fail with FixTraceFlags() disabled)
#
# delete the INCLUDE rule up the stack
% ./tests t:f,func1/ --push1=t:f,func3/
| >func1
| | >func2
| | | >func3
| | | <func3
| | <func2
=> push1
=> evaluate: OFF
=> evaluate_if: OFF
| | >func3
| | <func3
# delete the EXCLUDE rule up the stack
% ./tests t:-f,func1/ --push1=t
>main
=> push1
| <func1
=> evaluate: OFF
=> evaluate_if: OFF
| >func2
| | >func3
| | <func3
| <func2
<main
# add the INCLUDE rule up the stack
% ./tests t:f,func3 --push1=t:f,main/
| | | >func3
| | | <func3
=> push1
| <func1
=> evaluate: OFF
=> evaluate_if: OFF
| >func2
| | >func3
| | <func3
| <func2
<main
# add the EXCLUDE rule up the stack
% ./tests t --push1=t:-f,main/
>main
| >func1
| | >func2
| | | >func3
| | | <func3
| | <func2
=> push1
=> evaluate: OFF
=> evaluate_if: OFF
# change the defaults
% ./tests t:f,func3 --push1=t
| | | >func3
| | | <func3
=> push1
| <func1
=> evaluate: OFF
=> evaluate_if: OFF
| >func2
| | >func3
| | <func3
| <func2
<main
# repeated keyword
% ./tests d:-d,info,info
=> execute
=> evaluate: ON
=> evaluate_if: OFF
main: explain: dbug explained: d:-d,info
% ./tests d:-d,info/,info
=> execute
=> evaluate: ON
=> evaluate_if: OFF
main: explain: dbug explained: d:-d,info/

87
dbug/tests.c Normal file
View File

@ -0,0 +1,87 @@
/*
A program to test DBUG features. Used by tests-t.pl
*/
char *push1=0;
#include <my_global.h> /* This includes dbug.h */
#include <my_pthread.h>
#include <string.h>
const char *func3()
{
DBUG_ENTER("func3");
DBUG_RETURN(DBUG_EVALUATE("ret3", "ok", "ko"));
}
void func2()
{
const char *s;
DBUG_ENTER("func2");
s=func3();
DBUG_PRINT("info", ("s=%s", s));
DBUG_VOID_RETURN;
}
int func1()
{
DBUG_ENTER("func1");
func2();
if (push1)
{
DBUG_PUSH(push1);
fprintf(DBUG_FILE, "=> push1\n");
}
DBUG_RETURN(10);
}
int main (int argc, char *argv[])
{
int i;
#ifdef DBUG_OFF
return 1;
#endif
if (argc == 1)
return 0;
#if defined(HAVE_PTHREAD_INIT) && defined(THREAD)
pthread_init(); /* Must be called before DBUG_ENTER */
#endif
#ifdef THREAD
my_thread_global_init();
#endif
dup2(1, 2);
for (i = 1; i < argc; i++)
{
if (strncmp(argv[i], "--push1=", 8) == 0)
push1=argv[i]+8;
else
DBUG_PUSH (argv[i]);
}
{
DBUG_ENTER ("main");
DBUG_PROCESS ("dbug-tests");
func1();
DBUG_EXECUTE_IF("dump",
{
char s[1000];
DBUG_EXPLAIN(s, sizeof(s)-1);
DBUG_DUMP("dump", (uchar*)s, strlen(s));
});
DBUG_EXECUTE_IF("push", DBUG_PUSH("+t"); );
DBUG_EXECUTE("execute", fprintf(DBUG_FILE, "=> execute\n"); );
DBUG_EXECUTE_IF("set", DBUG_SET("+F"); );
fprintf(DBUG_FILE, "=> evaluate: %s\n",
DBUG_EVALUATE("evaluate", "ON", "OFF"));
fprintf(DBUG_FILE, "=> evaluate_if: %s\n",
DBUG_EVALUATE_IF("evaluate_if", "ON", "OFF"));
DBUG_EXECUTE_IF("pop", DBUG_POP(); );
{
char s[1000] __attribute__((unused));
DBUG_EXPLAIN(s, sizeof(s)-1);
DBUG_PRINT("explain", ("dbug explained: %s", s));
}
func2();
DBUG_RETURN (0);
}
}

View File

@ -512,7 +512,7 @@ possible since all code preceding the first call to
.B DBUG_PUSH
is
essentially invisible to
.B dbug
.I dbug
(this can be worked around by
inserting a temporary
.B DBUG_PUSH(argv[1])
@ -708,7 +708,7 @@ EX:\ \fCDBUG_PROCESS\ (argv[0]);\fR
.SP 1
.LI DBUG_PUSH\
Sets a new debugger state by pushing the current
.B dbug
.I dbug
state onto an internal stack and setting up the new state using the
debug control string passed as the macro argument. The most common
usage is to set the state specified by a debug control string
@ -769,14 +769,14 @@ the 'd' flag. Used to conditionally execute "dangerous" actions, e.g
to crash the program testing how recovery works, or to introduce an
artificial delay checking for race conditions.
.SP 1
EX:\ \fCDBUG_EXECUTE_IF\ ("crashme",\ abort\ ());\fR
EX:\ \fCDBUG_EXECUTE_IF\ ("crashme",\ DBUG_ABORT()\ ());\fR
.SP 1
.LI DBUG_EVALUATE\
The DBUG_EVALUATE macro is similar to DBUG_EXECUTE, but it can be used in
the expression context. The first argument is the debug keyword that is used to
choose whether the second (keyword is enabled) or the third (keyword is not
enabled) argument is evaluated. When
.B dbug
.I dbug
is compiled off, the third argument is evaluated.
.SP 1
EX:\fC
@ -796,7 +796,7 @@ EX:\fC
.br
if (prepare_transaction () ||
.br
DBUG_EVALUATE ("crashme", (abort (), 0), 0) ||
DBUG_EVALUATE ("crashme", (DBUG_ABORT(), 0), 0) ||
.br
commit_transaction () )\fR
.SP 1
@ -875,6 +875,12 @@ library. So there will be no need to disable asserts separately with NDEBUG.
.SP 1
EX:\ \fCDBUG_ASSERT(\ a\ >\ 0\ );\fR
.SP 1
.LI DBUG_ABORT\
This macro could be used instead of abort(). It flushes DBUG_FILE stream
to ensure that no
.I dbug
output is lost and then calls abort().
.SP 1
.LI DBUG_EXPLAIN\
Generates control string corresponding to the current debug state.
The macro takes two arguments - a buffer to store the result string
@ -910,17 +916,17 @@ via the
.B DBUG_PUSH
or
.B DBUG_SET
macros. Control string consists of colon separate flags. Colons
macros. Control string consists of colon separated flags. Colons
that are part of ':\\', ':/', or '::' are not considered flag
separators. A flag may take an argument or a list of arguments.
If a control string starts from a '+' sign it works
.I incrementally,
that is, it can modify existing state without overriding it. In such a
string every flag may be preceded by a '+' or '-' to enable or disable
a corresponding option in the debugger state. This section summarizes
the currently available debugger options and the flag characters which
enable or disable them. Argument lists enclosed in '[' and ']' are
optional.
that is, it can modify existing state without overriding it. Every
flag may be preceded by a '+' or '-' to enable or disable a
corresponding option in the debugger state or to add or remove
arguments to the list. This section summarizes the currently available
debugger options and the flag characters which enable or disable them.
Argument lists enclosed in '[' and ']' are optional.
.SP 2
.BL 22
.LI a[,file]
@ -936,6 +942,9 @@ a complete log file in case of crashes. This mode is implicit in
multi-threaded environment.
.LI d[,keywords]
Enable output from macros with specified keywords.
Every keyword can be a
.I glob(7)
pattern.
An empty list of keywords implies that all keywords are selected.
.LI D[,time]
Delay for specified time after each output line, to let output drain.
@ -943,7 +952,19 @@ Time is given in tenths of a second (value of 10 is one second).
Default is zero.
.LI f[,functions]
Limit debugger actions to the specified list of functions.
Every function can be a
.I glob(7)
pattern.
An empty list of functions implies that all functions are selected.
Every function in the list may optionally be followed by a '/' -
this will implicitly select all the functions down the call stack.
.SP 1
EX: \fCf,func1,func2/:-f,func3,func4/\fR
.SP 1
This would enable debugger in functions 'func1()', 'func2()' and all
functions called from it (directly or indirectly). But not in
functions 'func3()' or 'func4()' and all functions called from
it.
.LI F
Mark each debugger output line with the name of the source file
containing the macro causing the output.
@ -952,6 +973,9 @@ Mark each debugger output line with the PID (or thread ID) of the
current process.
.LI g,[functions]
Enable profiling for the specified list of functions.
Every function can be a
.I glob(7)
pattern.
An empty list of functions enables profiling for all functions.
See
.B PROFILING\ WITH\ DBUG
@ -970,7 +994,11 @@ Like 'a[,file]' but overwrite old file, do not append.
.LI O[,file]
Like 'A[,file]' but overwrite old file, do not append.
.LI p[,processes]
Limit debugger actions to the specified processes. An empty list
Limit debugger actions to the specified processes.
Every name can be a
.I glob(7)
pattern.
An empty list
implies all processes. This is useful for processes which run child
processes. Note that each debugger output line can be marked with the
name of the current process via the 'P' flag. The process name must

View File

@ -1,139 +0,0 @@
/******************************************************************************
* *
* N O T I C E *
* *
* Copyright Abandoned, 1987, Fred Fish *
* *
* *
* This previously copyrighted work has been placed into the public *
* domain by the author and may be freely used for any purpose, *
* private or commercial. *
* *
* Because of the number of inquiries I was receiving about the use *
* of this product in commercially developed works I have decided to *
* simply make it public domain to further its unrestricted use. I *
* specifically would be most happy to see this material become a *
* part of the standard Unix distributions by AT&T and the Berkeley *
* Computer Science Research Group, and a standard part of the GNU *
* system from the Free Software Foundation. *
* *
* I would appreciate it, as a courtesy, if this notice is left in *
* all copies and derivative works. Thank you. *
* *
* The author makes no warranty of any kind with respect to this *
* product and explicitly disclaims any implied warranties of mer- *
* chantability or fitness for any particular purpose. *
* *
******************************************************************************
*/
/*
* FILE
*
* vargs.h include file for environments without varargs.h
*
* SCCS
*
* @(#)vargs.h 1.2 5/8/88
*
* SYNOPSIS
*
* #include "vargs.h"
*
* DESCRIPTION
*
* This file implements a varargs macro set for use in those
* environments where there is no system supplied varargs. This
* generally works because systems which don't supply a varargs
* package are precisely those which don't strictly need a varargs
* package. Using this one then allows us to minimize source
* code changes. So in some sense, this is a "portable" varargs
* since it is only used for convenience, when it is not strictly
* needed.
*
*/
/*
* These macros allow us to rebuild an argument list on the stack
* given only a va_list. We can use these to fake a function like
* vfprintf, which gets a fixed number of arguments, the last of
* which is a va_list, by rebuilding a stack and calling the variable
* argument form fprintf. Of course this only works when vfprintf
* is not available in the host environment, and thus is not available
* for fprintf to call (which would give us an infinite loop).
*
* Note that ARGS_TYPE is a long, which lets us get several bytes
* at a time while also preventing lots of "possible pointer alignment
* problem" messages from lint. The messages are valid, because this
* IS nonportable, but then we should only be using it in very
* nonrestrictive environments, and using the real varargs where it
* really counts.
*
*/
#define ARG0 a0
#define ARG1 a1
#define ARG2 a2
#define ARG3 a3
#define ARG4 a4
#define ARG5 a5
#define ARG6 a6
#define ARG7 a7
#define ARG8 a8
#define ARG9 a9
#define ARGS_TYPE long
#define ARGS_LIST ARG0,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8,ARG9
#define ARGS_DCL auto ARGS_TYPE ARGS_LIST
/*
* A pointer of type "va_list" points to a section of memory
* containing an array of variable sized arguments of unknown
* number. This pointer is initialized by the va_start
* macro to point to the first byte of the first argument.
* We can then use it to walk through the argument list by
* incrementing it by the size of the argument being referenced.
*/
typedef char *va_list;
/*
* The first variable argument overlays va_alist, which is
* nothing more than a "handle" which allows us to get the
* address of the first argument on the stack. Note that
* by definition, the va_dcl macro includes the terminating
* semicolon, which makes use of va_dcl in the source code
* appear to be missing a semicolon.
*/
#define va_dcl ARGS_TYPE va_alist;
/*
* The va_start macro takes a variable of type "va_list" and
* initializes it. In our case, it initializes a local variable
* of type "pointer to char" to point to the first argument on
* the stack.
*/
#define va_start(list) list = (char *) &va_alist
/*
* The va_end macro is a null operation for our use.
*/
#define va_end(list)
/*
* The va_arg macro is the tricky one. This one takes
* a va_list as the first argument, and a type as the second
* argument, and returns a value of the appropriate type
* while advancing the va_list to the following argument.
* For our case, we first increment the va_list arg by the
* size of the type being recovered, cast the result to
* a pointer of the appropriate type, and then dereference
* that pointer as an array to get the previous arg (which
* is the one we wanted.
*/
#define va_arg(list,type) ((type *) (list += sizeof (type)))[-1]

View File

@ -1,10 +0,0 @@
.deps
.libs
Makefile
Makefile.in
comp_err
my_print_defaults
perror
print_defaults
replace
resolveip

View File

@ -660,7 +660,7 @@ static ha_checksum checksum_format_specifier(const char* msg)
case 'u':
case 'x':
case 's':
chksum= my_checksum(chksum, start, (uint) (p - start));
chksum= my_checksum(chksum, start, (uint) (p + 1 - start));
start= 0; /* Not in format specifier anymore */
break;
@ -1030,8 +1030,10 @@ static char *parse_text_line(char *pos)
{
int i, nr;
char *row= pos;
size_t len;
DBUG_ENTER("parse_text_line");
len= strlen (pos);
while (*pos)
{
if (*pos == '\\')
@ -1039,11 +1041,11 @@ static char *parse_text_line(char *pos)
switch (*++pos) {
case '\\':
case '"':
VOID(strmov(pos - 1, pos));
(void) memmove (pos - 1, pos, len - (row - pos));
break;
case 'n':
pos[-1]= '\n';
VOID(strmov(pos, pos + 1));
(void) memmove (pos, pos + 1, len - (row - pos));
break;
default:
if (*pos >= '0' && *pos < '8')
@ -1053,10 +1055,10 @@ static char *parse_text_line(char *pos)
nr= nr * 8 + (*(pos++) - '0');
pos -= i;
pos[-1]= nr;
VOID(strmov(pos, pos + i));
(void) memmove (pos, pos + i, len - (row - pos));
}
else if (*pos)
VOID(strmov(pos - 1, pos)); /* Remove '\' */
(void) memmove (pos - 1, pos, len - (row - pos)); /* Remove '\' */
}
}
else

View File

@ -189,12 +189,14 @@ int main(int argc, char **argv)
config_file);
}
error= 2;
exit(error);
}
for (argument= arguments+1 ; *argument ; argument++)
puts(*argument);
if (*argument != args_separator) /* skip arguments separator */
puts(*argument);
my_free((char*) load_default_groups,MYF(0));
free_defaults(arguments);
exit(error);
exit(0);
}

View File

@ -311,7 +311,7 @@ static int insert_pointer_name(reg1 POINTER_ARRAY *pa,char * name)
pa->flag[pa->typelib.count]=0; /* Reset flag */
pa->typelib.type_names[pa->typelib.count++]= (char*) (pa->str+pa->length);
pa->typelib.type_names[pa->typelib.count]= NullS; /* Put end-mark */
VOID(strmov((char*) pa->str + pa->length, name));
(void) strmov((char*) pa->str + pa->length, name);
pa->length+=length;
DBUG_RETURN(0);
} /* insert_pointer_name */
@ -433,7 +433,7 @@ static REPLACE *init_replace(char * *from, char * *to,uint count,
free_sets(&sets);
DBUG_RETURN(0);
}
VOID(make_new_set(&sets)); /* Set starting set */
(void) make_new_set(&sets); /* Set starting set */
make_sets_invisible(&sets); /* Hide previus sets */
used_sets=-1;
word_states=make_new_set(&sets); /* Start of new word */

View File

@ -27,7 +27,6 @@
#include <time.h>
#if defined(_WIN32)
#define _WIN32_WINNT 0x0400
#include <windows.h>
#include <wincrypt.h>
#else

View File

@ -1,4 +0,0 @@
Makefile
Makefile.in
my_config.h
mysql_version.h

View File

@ -1,4 +1,4 @@
# Copyright (C) 2000-2006 MySQL AB
# Copyright (C) 2000-2006 MySQL AB, 2009 Sun Microsystems, Inc
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
@ -21,28 +21,34 @@ HEADERS_GEN_MAKE = my_config.h
HEADERS_ABI = mysql.h mysql_com.h mysql_time.h \
my_list.h my_alloc.h typelib.h mysql/plugin.h
pkginclude_HEADERS = $(HEADERS_ABI) my_dbug.h m_string.h my_sys.h \
my_xml.h mysql_embed.h \
my_xml.h mysql_embed.h mysql/services.h \
mysql/service_my_snprintf.h mysql/service_thd_alloc.h \
my_pthread.h my_no_pthread.h \
mysql/psi/psi.h mysql/psi/mysql_thread.h \
mysql/psi/mysql_file.h \
decimal.h errmsg.h my_global.h my_net.h \
my_getopt.h sslopt-longopts.h my_dir.h \
sslopt-vars.h sslopt-case.h sql_common.h keycache.h \
m_ctype.h my_attribute.h $(HEADERS_GEN_CONFIGURE) \
$(HEADERS_GEN_MAKE) probes_mysql.h probes_mysql_nodtrace.h
noinst_HEADERS = config-win.h config-netware.h my_bit.h \
noinst_HEADERS = config-win.h config-netware.h lf.h my_bit.h \
heap.h my_bitmap.h my_uctype.h \
myisam.h myisampack.h myisammrg.h ft_global.h\
mysys_err.h my_base.h help_start.h help_end.h \
my_nosys.h my_alarm.h queues.h rijndael.h sha1.h \
my_aes.h my_tree.h my_trie.h hash.h thr_alarm.h \
thr_lock.h t_ctype.h violite.h my_md5.h base64.h \
my_handler.h my_time.h \
my_handler.h my_time.h service_versions.h \
my_rdtsc.h mysql/psi/psi_abi_v1.h mysql/psi/psi_abi_v2.h \
my_vle.h my_user.h my_atomic.h atomic/nolock.h \
atomic/rwlock.h atomic/x86-gcc.h atomic/x86-msvc.h \
atomic/solaris.h \
atomic/gcc_builtins.h my_libwrap.h my_stacktrace.h
atomic/rwlock.h atomic/x86-gcc.h atomic/generic-msvc.h \
atomic/gcc_builtins.h my_libwrap.h my_stacktrace.h \
atomic/solaris.h
EXTRA_DIST = mysql.h.pp mysql/plugin.h.pp probes_mysql.d.base
EXTRA_DIST = mysql.h.pp mysql/plugin.h.pp probes_mysql.d.base \
mysql/psi/psi_abi_v1.h.pp \
mysql/psi/psi_abi_v2.h.pp
# Remove built files and the symlinked directories
CLEANFILES = $(BUILT_SOURCES) readline openssl probes_mysql.d probes_mysql_nodtrace.h

View File

@ -1,3 +1,6 @@
#ifndef ATOMIC_GCC_BUILTINS_INCLUDED
#define ATOMIC_GCC_BUILTINS_INCLUDED
/* Copyright (C) 2008 MySQL AB
This program is free software; you can redistribute it and/or modify
@ -15,7 +18,7 @@
#define make_atomic_add_body(S) \
v= __sync_fetch_and_add(a, v);
#define make_atomic_swap_body(S) \
#define make_atomic_fas_body(S) \
v= __sync_lock_test_and_set(a, v);
#define make_atomic_cas_body(S) \
int ## S sav; \
@ -25,9 +28,14 @@
#ifdef MY_ATOMIC_MODE_DUMMY
#define make_atomic_load_body(S) ret= *a
#define make_atomic_store_body(S) *a= v
#define MY_ATOMIC_MODE "gcc-builtins-up"
#else
#define MY_ATOMIC_MODE "gcc-builtins-smp"
#define make_atomic_load_body(S) \
ret= __sync_fetch_and_or(a, 0);
#define make_atomic_store_body(S) \
(void) __sync_lock_test_and_set(a, v);
#endif
#endif /* ATOMIC_GCC_BUILTINS_INCLUDED */

View File

@ -0,0 +1,116 @@
/* Copyright (C) 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifndef _atomic_h_cleanup_
#define _atomic_h_cleanup_ "atomic/generic-msvc.h"
/*
We don't implement anything specific for MY_ATOMIC_MODE_DUMMY, always use
intrinsics.
8 and 16-bit atomics are not implemented, but it can be done if necessary.
*/
#undef MY_ATOMIC_HAS_8_16
/*
x86 compilers (both VS2003 or VS2005) never use instrinsics, but generate
function calls to kernel32 instead, even in the optimized build.
We force intrinsics as described in MSDN documentation for
_InterlockedCompareExchange.
*/
#ifdef _M_IX86
#if (_MSC_VER >= 1500)
#include <intrin.h>
#else
C_MODE_START
/*Visual Studio 2003 and earlier do not have prototypes for atomic intrinsics*/
LONG _InterlockedExchange (LONG volatile *Target,LONG Value);
LONG _InterlockedCompareExchange (LONG volatile *Target, LONG Value, LONG Comp);
LONG _InterlockedExchangeAdd (LONG volatile *Addend, LONG Value);
C_MODE_END
#pragma intrinsic(_InterlockedExchangeAdd)
#pragma intrinsic(_InterlockedCompareExchange)
#pragma intrinsic(_InterlockedExchange)
#endif
#define InterlockedExchange _InterlockedExchange
#define InterlockedExchangeAdd _InterlockedExchangeAdd
#define InterlockedCompareExchange _InterlockedCompareExchange
/*
No need to do something special for InterlockedCompareExchangePointer
as it is a #define to InterlockedCompareExchange. The same applies to
InterlockedExchangePointer.
*/
#endif /*_M_IX86*/
#define MY_ATOMIC_MODE "msvc-intrinsics"
#define IL_EXCHG_ADD32(X,Y) InterlockedExchangeAdd((volatile LONG *)(X),(Y))
#define IL_COMP_EXCHG32(X,Y,Z) InterlockedCompareExchange((volatile LONG *)(X),(Y),(Z))
#define IL_COMP_EXCHGptr InterlockedCompareExchangePointer
#define IL_EXCHG32(X,Y) InterlockedExchange((volatile LONG *)(X),(Y))
#define IL_EXCHGptr InterlockedExchangePointer
#define make_atomic_add_body(S) \
v= IL_EXCHG_ADD ## S (a, v)
#define make_atomic_cas_body(S) \
int ## S initial_cmp= *cmp; \
int ## S initial_a= IL_COMP_EXCHG ## S (a, set, initial_cmp); \
if (!(ret= (initial_a == initial_cmp))) *cmp= initial_a;
#define make_atomic_swap_body(S) \
v= IL_EXCHG ## S (a, v)
#define make_atomic_load_body(S) \
ret= 0; /* avoid compiler warning */ \
ret= IL_COMP_EXCHG ## S (a, ret, ret);
/*
my_yield_processor (equivalent of x86 PAUSE instruction) should be used
to improve performance on hyperthreaded CPUs. Intel recommends to use it in
spin loops also on non-HT machines to reduce power consumption (see e.g
http://softwarecommunity.intel.com/articles/eng/2004.htm)
Running benchmarks for spinlocks implemented with InterlockedCompareExchange
and YieldProcessor shows that much better performance is achieved by calling
YieldProcessor in a loop - that is, yielding longer. On Intel boxes setting
loop count in the range 200-300 brought best results.
*/
#ifndef YIELD_LOOPS
#define YIELD_LOOPS 200
#endif
static __inline int my_yield_processor()
{
int i;
for(i=0; i<YIELD_LOOPS; i++)
{
#if (_MSC_VER <= 1310)
/* On older compilers YieldProcessor is not available, use inline assembly*/
__asm { rep nop }
#else
YieldProcessor();
#endif
}
return 1;
}
#define LF_BACKOFF my_yield_processor()
#else /* cleanup */
#undef IL_EXCHG_ADD32
#undef IL_COMP_EXCHG32
#undef IL_COMP_EXCHGptr
#undef IL_EXCHG32
#undef IL_EXCHGptr
#endif

View File

@ -1,3 +1,6 @@
#ifndef ATOMIC_NOLOCK_INCLUDED
#define ATOMIC_NOLOCK_INCLUDED
/* Copyright (C) 2006 MySQL AB
This program is free software; you can redistribute it and/or modify
@ -13,43 +16,36 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#if defined(__i386__) || defined(_M_IX86) || defined(HAVE_GCC_ATOMIC_BUILTINS)
#if defined(__i386__) || defined(_MSC_VER) || defined(__x86_64__) \
|| defined(HAVE_GCC_ATOMIC_BUILTINS)
#ifdef MY_ATOMIC_MODE_DUMMY
# define LOCK ""
#else
# define LOCK "lock"
#endif
#ifdef HAVE_GCC_ATOMIC_BUILTINS
#include "gcc_builtins.h"
#elif __GNUC__
#include "x86-gcc.h"
#elif defined(_MSC_VER)
#include "x86-msvc.h"
#endif
# ifdef MY_ATOMIC_MODE_DUMMY
# define LOCK_prefix ""
# else
# define LOCK_prefix "lock"
# endif
# ifdef HAVE_GCC_ATOMIC_BUILTINS
# include "gcc_builtins.h"
# elif __GNUC__
# include "x86-gcc.h"
# elif defined(_MSC_VER)
# include "generic-msvc.h"
# endif
#elif defined(HAVE_SOLARIS_ATOMIC)
#include "solaris.h"
#endif /* __i386__ || _M_IX86 || HAVE_GCC_ATOMIC_BUILTINS */
#endif
#if defined(make_atomic_cas_body) || defined(MY_ATOMICS_MADE)
/*
* We have atomics that require no locking
*/
#define MY_ATOMIC_NOLOCK
#ifdef __SUNPRO_C
/*
* Sun Studio 12 (and likely earlier) does not accept a typedef struct {}
*/
typedef char my_atomic_rwlock_t;
#else
typedef struct { } my_atomic_rwlock_t;
#endif
Type not used so minimal size (emptry struct has different size between C
and C++, zero-length array is gcc-specific).
*/
typedef char my_atomic_rwlock_t __attribute__ ((unused));
#define my_atomic_rwlock_destroy(name)
#define my_atomic_rwlock_init(name)
#define my_atomic_rwlock_rdlock(name)
@ -59,3 +55,4 @@ typedef struct { } my_atomic_rwlock_t;
#endif
#endif /* ATOMIC_NOLOCK_INCLUDED */

View File

@ -1,4 +1,7 @@
/* Copyright (C) 2006 MySQL AB
#ifndef ATOMIC_RWLOCK_INCLUDED
#define ATOMIC_RWLOCK_INCLUDED
/* Copyright (C) 2006 MySQL AB, 2009 Sun Microsystems, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -13,7 +16,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
typedef struct {pthread_rwlock_t rw;} my_atomic_rwlock_t;
#define MY_ATOMIC_MODE_RWLOCKS 1
#ifdef MY_ATOMIC_MODE_DUMMY
/*
@ -23,6 +26,9 @@ typedef struct {pthread_rwlock_t rw;} my_atomic_rwlock_t;
implementations (another way is to run a UP build on an SMP box).
*/
#warning MY_ATOMIC_MODE_DUMMY and MY_ATOMIC_MODE_RWLOCKS are incompatible
typedef char my_atomic_rwlock_t;
#define my_atomic_rwlock_destroy(name)
#define my_atomic_rwlock_init(name)
#define my_atomic_rwlock_rdlock(name)
@ -30,19 +36,65 @@ typedef struct {pthread_rwlock_t rw;} my_atomic_rwlock_t;
#define my_atomic_rwlock_rdunlock(name)
#define my_atomic_rwlock_wrunlock(name)
#define MY_ATOMIC_MODE "dummy (non-atomic)"
#else
#define my_atomic_rwlock_destroy(name) pthread_rwlock_destroy(& (name)->rw)
#define my_atomic_rwlock_init(name) pthread_rwlock_init(& (name)->rw, 0)
#define my_atomic_rwlock_rdlock(name) pthread_rwlock_rdlock(& (name)->rw)
#define my_atomic_rwlock_wrlock(name) pthread_rwlock_wrlock(& (name)->rw)
#define my_atomic_rwlock_rdunlock(name) pthread_rwlock_unlock(& (name)->rw)
#define my_atomic_rwlock_wrunlock(name) pthread_rwlock_unlock(& (name)->rw)
#define MY_ATOMIC_MODE "rwlocks"
#else /* not MY_ATOMIC_MODE_DUMMY */
typedef struct {pthread_mutex_t rw;} my_atomic_rwlock_t;
#ifndef SAFE_MUTEX
/*
we're using read-write lock macros but map them to mutex locks, and they're
faster. Still, having semantically rich API we can change the
underlying implementation, if necessary.
*/
#define my_atomic_rwlock_destroy(name) pthread_mutex_destroy(& (name)->rw)
#define my_atomic_rwlock_init(name) pthread_mutex_init(& (name)->rw, 0)
#define my_atomic_rwlock_rdlock(name) pthread_mutex_lock(& (name)->rw)
#define my_atomic_rwlock_wrlock(name) pthread_mutex_lock(& (name)->rw)
#define my_atomic_rwlock_rdunlock(name) pthread_mutex_unlock(& (name)->rw)
#define my_atomic_rwlock_wrunlock(name) pthread_mutex_unlock(& (name)->rw)
#else /* SAFE_MUTEX */
/*
SAFE_MUTEX pollutes the compiling name space with macros
that alter pthread_mutex_t, pthread_mutex_init, etc.
Atomic operations should never use the safe mutex wrappers.
Unfortunately, there is no way to have both:
- safe mutex macros expanding pthread_mutex_lock to safe_mutex_lock
- my_atomic macros expanding to unmodified pthread_mutex_lock
inlined in the same compilation unit.
So, in case of SAFE_MUTEX, a function call is required.
Given that SAFE_MUTEX is a debugging facility,
this extra function call is not a performance concern for
production builds.
*/
C_MODE_START
extern void plain_pthread_mutex_init(safe_mutex_t *);
extern void plain_pthread_mutex_destroy(safe_mutex_t *);
extern void plain_pthread_mutex_lock(safe_mutex_t *);
extern void plain_pthread_mutex_unlock(safe_mutex_t *);
C_MODE_END
#define my_atomic_rwlock_destroy(name) plain_pthread_mutex_destroy(&(name)->rw)
#define my_atomic_rwlock_init(name) plain_pthread_mutex_init(&(name)->rw)
#define my_atomic_rwlock_rdlock(name) plain_pthread_mutex_lock(&(name)->rw)
#define my_atomic_rwlock_wrlock(name) plain_pthread_mutex_lock(&(name)->rw)
#define my_atomic_rwlock_rdunlock(name) plain_pthread_mutex_unlock(&(name)->rw)
#define my_atomic_rwlock_wrunlock(name) plain_pthread_mutex_unlock(&(name)->rw)
#endif /* SAFE_MUTEX */
#define MY_ATOMIC_MODE "mutex"
#ifndef MY_ATOMIC_MODE_RWLOCKS
#define MY_ATOMIC_MODE_RWLOCKS 1
#endif
#endif
#define make_atomic_add_body(S) int ## S sav; sav= *a; *a+= v; v=sav;
#define make_atomic_swap_body(S) int ## S sav; sav= *a; *a= v; v=sav;
#define make_atomic_fas_body(S) int ## S sav; sav= *a; *a= v; v=sav;
#define make_atomic_cas_body(S) if ((ret= (*a == *cmp))) *a= set; else *cmp=*a;
#define make_atomic_load_body(S) ret= *a;
#define make_atomic_store_body(S) *a= v;
#endif /* ATOMIC_RWLOCK_INCLUDED */

View File

@ -186,25 +186,25 @@ my_atomic_storeptr(void * volatile *a, void *v)
/* ------------------------------------------------------------------------ */
STATIC_INLINE int8
my_atomic_swap8(int8 volatile *a, int8 v)
my_atomic_fas8(int8 volatile *a, int8 v)
{
return ((int8) atomic_swap_8((volatile uint8_t *)a, (uint8_t)v));
}
STATIC_INLINE int16
my_atomic_swap16(int16 volatile *a, int16 v)
my_atomic_fas16(int16 volatile *a, int16 v)
{
return ((int16) atomic_swap_16((volatile uint16_t *)a, (uint16_t)v));
}
STATIC_INLINE int32
my_atomic_swap32(int32 volatile *a, int32 v)
my_atomic_fas32(int32 volatile *a, int32 v)
{
return ((int32) atomic_swap_32((volatile uint32_t *)a, (uint32_t)v));
}
STATIC_INLINE void *
my_atomic_swapptr(void * volatile *a, void *v)
my_atomic_fasptr(void * volatile *a, void *v)
{
return (atomic_swap_ptr(a, v));
}

View File

@ -1,3 +1,6 @@
#ifndef ATOMIC_X86_GCC_INCLUDED
#define ATOMIC_X86_GCC_INCLUDED
/* Copyright (C) 2006 MySQL AB
This program is free software; you can redistribute it and/or modify
@ -19,10 +22,18 @@
architectures support double-word (128-bit) cas.
*/
#ifdef MY_ATOMIC_NO_XADD
#define MY_ATOMIC_MODE "gcc-x86" LOCK "-no-xadd"
#ifdef __x86_64__
# ifdef MY_ATOMIC_NO_XADD
# define MY_ATOMIC_MODE "gcc-amd64" LOCK_prefix "-no-xadd"
# else
# define MY_ATOMIC_MODE "gcc-amd64" LOCK_prefix
# endif
#else
#define MY_ATOMIC_MODE "gcc-x86" LOCK
# ifdef MY_ATOMIC_NO_XADD
# define MY_ATOMIC_MODE "gcc-x86" LOCK_prefix "-no-xadd"
# else
# define MY_ATOMIC_MODE "gcc-x86" LOCK_prefix
# endif
#endif
/* fix -ansi errors while maintaining readability */
@ -32,12 +43,12 @@
#ifndef MY_ATOMIC_NO_XADD
#define make_atomic_add_body(S) \
asm volatile (LOCK "; xadd %0, %1;" : "+r" (v) , "+m" (*a))
asm volatile (LOCK_prefix "; xadd %0, %1;" : "+r" (v) , "+m" (*a))
#endif
#define make_atomic_swap_body(S) \
asm volatile ("; xchg %0, %1;" : "+q" (v) , "+m" (*a))
#define make_atomic_fas_body(S) \
asm volatile ("xchg %0, %1;" : "+q" (v) , "+m" (*a))
#define make_atomic_cas_body(S) \
asm volatile (LOCK "; cmpxchg %3, %0; setz %2;" \
asm volatile (LOCK_prefix "; cmpxchg %3, %0; setz %2;" \
: "+m" (*a), "+a" (*cmp), "=q" (ret): "r" (set))
#ifdef MY_ATOMIC_MODE_DUMMY
@ -46,13 +57,14 @@
#else
/*
Actually 32-bit reads/writes are always atomic on x86
But we add LOCK here anyway to force memory barriers
But we add LOCK_prefix here anyway to force memory barriers
*/
#define make_atomic_load_body(S) \
ret=0; \
asm volatile (LOCK "; cmpxchg %2, %0" \
asm volatile (LOCK_prefix "; cmpxchg %2, %0" \
: "+m" (*a), "+a" (ret): "r" (ret))
#define make_atomic_store_body(S) \
asm volatile ("; xchg %0, %1;" : "+m" (*a) : "r" (v))
asm volatile ("; xchg %0, %1;" : "+m" (*a), "+r" (v))
#endif
#endif /* ATOMIC_X86_GCC_INCLUDED */

View File

@ -1,96 +0,0 @@
/* Copyright (C) 2006 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/*
XXX 64-bit atomic operations can be implemented using
cmpxchg8b, if necessary
*/
// Would it be better to use intrinsics ?
// (InterlockedCompareExchange, InterlockedCompareExchange16
// InterlockedExchangeAdd, InterlockedExchange)
#ifndef _atomic_h_cleanup_
#define _atomic_h_cleanup_ "atomic/x86-msvc.h"
#define MY_ATOMIC_MODE "msvc-x86" LOCK
#define make_atomic_add_body(S) \
_asm { \
_asm mov reg_ ## S, v \
_asm LOCK xadd *a, reg_ ## S \
_asm movzx v, reg_ ## S \
}
#define make_atomic_cas_body(S) \
_asm { \
_asm mov areg_ ## S, *cmp \
_asm mov reg2_ ## S, set \
_asm LOCK cmpxchg *a, reg2_ ## S \
_asm mov *cmp, areg_ ## S \
_asm setz al \
_asm movzx ret, al \
}
#define make_atomic_swap_body(S) \
_asm { \
_asm mov reg_ ## S, v \
_asm xchg *a, reg_ ## S \
_asm mov v, reg_ ## S \
}
#ifdef MY_ATOMIC_MODE_DUMMY
#define make_atomic_load_body(S) ret=*a
#define make_atomic_store_body(S) *a=v
#else
/*
Actually 32-bit reads/writes are always atomic on x86
But we add LOCK here anyway to force memory barriers
*/
#define make_atomic_load_body(S) \
_asm { \
_asm mov areg_ ## S, 0 \
_asm mov reg2_ ## S, areg_ ## S \
_asm LOCK cmpxchg *a, reg2_ ## S \
_asm mov ret, areg_ ## S \
}
#define make_atomic_store_body(S) \
_asm { \
_asm mov reg_ ## S, v \
_asm xchg *a, reg_ ## S \
}
#endif
#define reg_8 al
#define reg_16 ax
#define reg_32 eax
#define areg_8 al
#define areg_16 ax
#define areg_32 eax
#define reg2_8 bl
#define reg2_16 bx
#define reg2_32 ebx
#else /* cleanup */
#undef reg_8
#undef reg_16
#undef reg_32
#undef areg_8
#undef areg_16
#undef areg_32
#undef reg2_8
#undef reg2_16
#undef reg2_32
#endif

View File

@ -73,7 +73,6 @@ extern "C" {
#undef HAVE_FINITE
#undef HAVE_GETPWNAM
#undef HAVE_GETPWUID
#undef HAVE_PTHREAD_SETSCHEDPARAM
#undef HAVE_READLINK
#undef HAVE_STPCPY
/* changes end */

View File

@ -1,3 +1,6 @@
#ifndef CONFIG_WIN_INCLUDED
#define CONFIG_WIN_INCLUDED
/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.
This program is free software; you can redistribute it and/or modify
@ -17,6 +20,13 @@
#define BIG_TABLES
/*
Minimal version of Windows we should be able to run on.
Currently Windows XP.
*/
#define _WIN32_WINNT 0x0501
#if defined(_MSC_VER) && _MSC_VER >= 1400
/* Avoid endless warnings about sprintf() etc. being unsafe. */
#define _CRT_SECURE_NO_DEPRECATE 1
@ -24,6 +34,7 @@
#include <sys/locking.h>
#include <winsock2.h>
#include <Ws2tcpip.h>
#include <fcntl.h>
#include <io.h>
#include <malloc.h>
@ -85,6 +96,12 @@
#define S_IROTH S_IREAD /* for my_lib */
/* Winsock2 constant (Vista SDK and later)*/
#define IPPROTO_IPV6 41
#ifndef IPV6_V6ONLY
#define IPV6_V6ONLY 27
#endif
#ifdef __BORLANDC__
#define FILE_BINARY O_BINARY /* my_fopen in binary mode */
#define O_TEMPORARY 0
@ -142,12 +159,23 @@ typedef __int64 os_off_t;
#ifdef _WIN64
typedef UINT_PTR rf_SetTimer;
#else
#ifndef HAVE_SIZE_T
typedef unsigned int size_t;
#endif
typedef uint rf_SetTimer;
#endif
#ifndef HAVE_SIZE_T
#ifndef _SIZE_T_DEFINED
typedef SIZE_T size_t;
#define _SIZE_T_DEFINED
#endif
#endif
#ifndef HAVE_SSIZE_T
#ifndef _SSIZE_T_DEFINED
typedef SSIZE_T ssize_t;
#define _SSIZE_T_DEFINED
#endif
#endif
#define Socket_defined
#define my_socket SOCKET
#define SIGPIPE SIGINT
@ -353,7 +381,6 @@ inline ulonglong double2ulonglong(double d)
#define HAVE_OPENSSL 1
#define HAVE_YASSL 1
#define COMMUNITY_SERVER 1
#define ENABLED_PROFILING 1
/*
@ -407,3 +434,5 @@ inline ulonglong double2ulonglong(double d)
#define HAVE_UCA_COLLATIONS 1
#define HAVE_BOOL 1
#endif /* CONFIG_WIN_INCLUDED */

View File

@ -1,3 +1,6 @@
#ifndef ERRMSG_INCLUDED
#define ERRMSG_INCLUDED
/* Copyright (C) 2000 MySQL AB
This program is free software; you can redistribute it and/or modify
@ -97,6 +100,8 @@ extern const char *client_errors[]; /* Error messages */
#define CR_SERVER_LOST_EXTENDED 2055
#define CR_STMT_CLOSED 2056
#define CR_NEW_STMT_METADATA 2057
#define CR_ERROR_LAST /*Copy last error nr:*/ 2057
#define CR_ALREADY_CONNECTED 2058
#define CR_ERROR_LAST /*Copy last error nr:*/ 2058
/* Add error numbers before CR_ERROR_LAST and change it accordingly. */
#endif /* ERRMSG_INCLUDED */

View File

@ -21,40 +21,6 @@
extern "C" {
#endif
/*
There was a problem on MacOSX with a shared object ha_example.so.
It used hash_search(). During build of ha_example.so no libmysys
was specified. Since MacOSX had a hash_search() in the system
library, it built the shared object so that the dynamic linker
linked hash_search() to the system library, which caused a crash
when called. To come around this, we renamed hash_search() to
my_hash_search(), as we did long ago with hash_insert() and
hash_reset(). However, this time we made the move complete with
all names. To keep compatibility, we redefine the old names.
Since every C and C++ file, that uses HASH, needs to include
this file, the change is complete. Both names could be used
in the code, but the my_* versions are recommended now.
*/
#define hash_get_key my_hash_get_key
#define hash_free_key my_hash_free_key
#define hash_init my_hash_init
#define hash_init2 my_hash_init2
#define _hash_init _my_hash_init
#define hash_free my_hash_free
#define hash_reset my_hash_reset
#define hash_element my_hash_element
#define hash_search my_hash_search
#define hash_first my_hash_first
#define hash_next my_hash_next
#define hash_insert my_hash_insert
#define hash_delete my_hash_delete
#define hash_update my_hash_update
#define hash_replace my_hash_replace
#define hash_check my_hash_check
#define hash_clear my_hash_clear
#define hash_inited my_hash_inited
#define hash_init_opt my_hash_init_opt
/*
Overhead to store an element in hash
Can be used to approximate memory consumption for a hash

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2000,2004 MySQL AB
/* Copyright (C) 2000-2004 MySQL AB, 2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -148,7 +148,7 @@ typedef struct st_heap_share
char * name; /* Name of "memory-file" */
#ifdef THREAD
THR_LOCK lock;
pthread_mutex_t intern_lock; /* Locking for use with _locking */
mysql_mutex_t intern_lock; /* Locking for use with _locking */
#endif
my_bool delete_on_close;
LIST open_list;

View File

@ -1,3 +1,6 @@
#ifndef HELP_END_INCLUDED
#define HELP_END_INCLUDED
/* Copyright (C) 2004-2005 MySQL AB
This program is free software; you can redistribute it and/or modify
@ -20,3 +23,4 @@
#undef fputc
#undef putchar
#endif
#endif /* HELP_END_INCLUDED */

View File

@ -1,3 +1,6 @@
#ifndef HELP_START_INCLUDED
#define HELP_START_INCLUDED
/* Copyright (C) 2004-2005 MySQL AB
This program is free software; you can redistribute it and/or modify
@ -22,3 +25,4 @@
#define fputc(s,f) consoleprintf("%c", s)
#define putchar(s) consoleprintf("%c", s)
#endif
#endif /* HELP_START_INCLUDED */

268
include/lf.h Normal file
View File

@ -0,0 +1,268 @@
/* Copyright (C) 2007-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifndef _lf_h
#define _lf_h
#include <my_atomic.h>
C_MODE_START
/*
Helpers to define both func() and _func(), where
func() is a _func() protected by my_atomic_rwlock_wrlock()
*/
#define lock_wrap(f, t, proto_args, args, lock) \
t _ ## f proto_args; \
static inline t f proto_args \
{ \
t ret; \
my_atomic_rwlock_wrlock(lock); \
ret= _ ## f args; \
my_atomic_rwlock_wrunlock(lock); \
return ret; \
}
#define lock_wrap_void(f, proto_args, args, lock) \
void _ ## f proto_args; \
static inline void f proto_args \
{ \
my_atomic_rwlock_wrlock(lock); \
_ ## f args; \
my_atomic_rwlock_wrunlock(lock); \
}
#define nolock_wrap(f, t, proto_args, args) \
t _ ## f proto_args; \
static inline t f proto_args \
{ \
return _ ## f args; \
}
#define nolock_wrap_void(f, proto_args, args) \
void _ ## f proto_args; \
static inline void f proto_args \
{ \
_ ## f args; \
}
/*
wait-free dynamic array, see lf_dynarray.c
4 levels of 256 elements each mean 4311810304 elements in an array - it
should be enough for a while
*/
#define LF_DYNARRAY_LEVEL_LENGTH 256
#define LF_DYNARRAY_LEVELS 4
typedef struct {
void * volatile level[LF_DYNARRAY_LEVELS];
uint size_of_element;
my_atomic_rwlock_t lock;
} LF_DYNARRAY;
typedef int (*lf_dynarray_func)(void *, void *);
void lf_dynarray_init(LF_DYNARRAY *array, uint element_size);
void lf_dynarray_destroy(LF_DYNARRAY *array);
nolock_wrap(lf_dynarray_value, void *,
(LF_DYNARRAY *array, uint idx),
(array, idx))
lock_wrap(lf_dynarray_lvalue, void *,
(LF_DYNARRAY *array, uint idx),
(array, idx),
&array->lock)
nolock_wrap(lf_dynarray_iterate, int,
(LF_DYNARRAY *array, lf_dynarray_func func, void *arg),
(array, func, arg))
/*
pin manager for memory allocator, lf_alloc-pin.c
*/
#define LF_PINBOX_PINS 4
#define LF_PURGATORY_SIZE 10
typedef void lf_pinbox_free_func(void *, void *, void*);
typedef struct {
LF_DYNARRAY pinarray;
lf_pinbox_free_func *free_func;
void *free_func_arg;
uint free_ptr_offset;
uint32 volatile pinstack_top_ver; /* this is a versioned pointer */
uint32 volatile pins_in_array; /* number of elements in array */
} LF_PINBOX;
typedef struct {
void * volatile pin[LF_PINBOX_PINS];
LF_PINBOX *pinbox;
void **stack_ends_here;
void *purgatory;
uint32 purgatory_count;
uint32 volatile link;
/* we want sizeof(LF_PINS) to be 64 to avoid false sharing */
#if SIZEOF_INT*2+SIZEOF_CHARP*(LF_PINBOX_PINS+3) != 64
char pad[64-sizeof(uint32)*2-sizeof(void*)*(LF_PINBOX_PINS+3)];
#endif
} LF_PINS;
/*
shortcut macros to do an atomic_wrlock on a structure that uses pins
(e.g. lf_hash).
*/
#define lf_rwlock_by_pins(PINS) \
my_atomic_rwlock_wrlock(&(PINS)->pinbox->pinarray.lock)
#define lf_rwunlock_by_pins(PINS) \
my_atomic_rwlock_wrunlock(&(PINS)->pinbox->pinarray.lock)
/*
compile-time assert, to require "no less than N" pins
it's enough if it'll fail on at least one compiler, so
we'll enable it on GCC only, which supports zero-length arrays.
*/
#if defined(__GNUC__) && defined(MY_LF_EXTRA_DEBUG)
#define LF_REQUIRE_PINS(N) \
static const char require_pins[LF_PINBOX_PINS-N] \
__attribute__ ((unused)); \
static const int LF_NUM_PINS_IN_THIS_FILE= N;
#define _lf_pin(PINS, PIN, ADDR) \
( \
assert(PIN < LF_NUM_PINS_IN_THIS_FILE), \
my_atomic_storeptr(&(PINS)->pin[PIN], (ADDR)) \
)
#else
#define LF_REQUIRE_PINS(N)
#define _lf_pin(PINS, PIN, ADDR) my_atomic_storeptr(&(PINS)->pin[PIN], (ADDR))
#endif
#define _lf_unpin(PINS, PIN) _lf_pin(PINS, PIN, NULL)
#define lf_pin(PINS, PIN, ADDR) \
do { \
lf_rwlock_by_pins(PINS); \
_lf_pin(PINS, PIN, ADDR); \
lf_rwunlock_by_pins(PINS); \
} while (0)
#define lf_unpin(PINS, PIN) lf_pin(PINS, PIN, NULL)
#define _lf_assert_pin(PINS, PIN) assert((PINS)->pin[PIN] != 0)
#define _lf_assert_unpin(PINS, PIN) assert((PINS)->pin[PIN] == 0)
void lf_pinbox_init(LF_PINBOX *pinbox, uint free_ptr_offset,
lf_pinbox_free_func *free_func, void * free_func_arg);
void lf_pinbox_destroy(LF_PINBOX *pinbox);
lock_wrap(lf_pinbox_get_pins, LF_PINS *,
(LF_PINBOX *pinbox),
(pinbox),
&pinbox->pinarray.lock)
lock_wrap_void(lf_pinbox_put_pins,
(LF_PINS *pins),
(pins),
&pins->pinbox->pinarray.lock)
lock_wrap_void(lf_pinbox_free,
(LF_PINS *pins, void *addr),
(pins, addr),
&pins->pinbox->pinarray.lock)
/*
memory allocator, lf_alloc-pin.c
*/
typedef struct st_lf_allocator {
LF_PINBOX pinbox;
uchar * volatile top;
uint element_size;
uint32 volatile mallocs;
void (*constructor)(uchar *); /* called, when an object is malloc()'ed */
void (*destructor)(uchar *); /* called, when an object is free()'d */
} LF_ALLOCATOR;
void lf_alloc_init(LF_ALLOCATOR *allocator, uint size, uint free_ptr_offset);
void lf_alloc_destroy(LF_ALLOCATOR *allocator);
uint lf_alloc_pool_count(LF_ALLOCATOR *allocator);
/*
shortcut macros to access underlying pinbox functions from an LF_ALLOCATOR
see _lf_pinbox_get_pins() and _lf_pinbox_put_pins()
*/
#define _lf_alloc_free(PINS, PTR) _lf_pinbox_free((PINS), (PTR))
#define lf_alloc_free(PINS, PTR) lf_pinbox_free((PINS), (PTR))
#define _lf_alloc_get_pins(A) _lf_pinbox_get_pins(&(A)->pinbox)
#define lf_alloc_get_pins(A) lf_pinbox_get_pins(&(A)->pinbox)
#define _lf_alloc_put_pins(PINS) _lf_pinbox_put_pins(PINS)
#define lf_alloc_put_pins(PINS) lf_pinbox_put_pins(PINS)
#define lf_alloc_direct_free(ALLOC, ADDR) my_free((uchar*)(ADDR), MYF(0))
lock_wrap(lf_alloc_new, void *,
(LF_PINS *pins),
(pins),
&pins->pinbox->pinarray.lock)
C_MODE_END
/*
extendible hash, lf_hash.c
*/
#include <hash.h>
C_MODE_START
#define LF_HASH_UNIQUE 1
/* lf_hash overhead per element (that is, sizeof(LF_SLIST) */
extern const int LF_HASH_OVERHEAD;
typedef struct {
LF_DYNARRAY array; /* hash itself */
LF_ALLOCATOR alloc; /* allocator for elements */
my_hash_get_key get_key; /* see HASH */
CHARSET_INFO *charset; /* see HASH */
uint key_offset, key_length; /* see HASH */
uint element_size; /* size of memcpy'ed area on insert */
uint flags; /* LF_HASH_UNIQUE, etc */
int32 volatile size; /* size of array */
int32 volatile count; /* number of elements in the hash */
} LF_HASH;
void lf_hash_init(LF_HASH *hash, uint element_size, uint flags,
uint key_offset, uint key_length, my_hash_get_key get_key,
CHARSET_INFO *charset);
void lf_hash_destroy(LF_HASH *hash);
int lf_hash_insert(LF_HASH *hash, LF_PINS *pins, const void *data);
void *lf_hash_search(LF_HASH *hash, LF_PINS *pins, const void *key, uint keylen);
int lf_hash_delete(LF_HASH *hash, LF_PINS *pins, const void *key, uint keylen);
/*
shortcut macros to access underlying pinbox functions from an LF_HASH
see _lf_pinbox_get_pins() and _lf_pinbox_put_pins()
*/
#define _lf_hash_get_pins(HASH) _lf_alloc_get_pins(&(HASH)->alloc)
#define lf_hash_get_pins(HASH) lf_alloc_get_pins(&(HASH)->alloc)
#define _lf_hash_put_pins(PINS) _lf_pinbox_put_pins(PINS)
#define lf_hash_put_pins(PINS) lf_pinbox_put_pins(PINS)
#define lf_hash_search_unpin(PINS) lf_unpin((PINS), 2)
/*
cleanup
*/
#undef lock_wrap_void
#undef lock_wrap
#undef nolock_wrap_void
#undef nolock_wrap
C_MODE_END
#endif

View File

@ -250,20 +250,83 @@ extern size_t my_snprintf(char *to, size_t n, const char *fmt, ...)
/*
LEX_STRING -- a pair of a C-string and its length.
(it's part of the plugin API as a MYSQL_LEX_STRING)
*/
#ifndef _my_plugin_h
/* This definition must match the one given in mysql/plugin.h */
struct st_mysql_lex_string
{
char *str;
size_t length;
};
#endif
#include <mysql/plugin.h>
typedef struct st_mysql_lex_string LEX_STRING;
#define STRING_WITH_LEN(X) (X), ((size_t) (sizeof(X) - 1))
#define USTRING_WITH_LEN(X) ((uchar*) X), ((size_t) (sizeof(X) - 1))
#define C_STRING_WITH_LEN(X) ((char *) (X)), ((size_t) (sizeof(X) - 1))
/* SPACE_INT is a word that contains only spaces */
#if SIZEOF_INT == 4
#define SPACE_INT 0x20202020
#elif SIZEOF_INT == 8
#define SPACE_INT 0x2020202020202020
#else
#error define the appropriate constant for a word full of spaces
#endif
/**
Skip trailing space.
On most systems reading memory in larger chunks (ideally equal to the size of
the chinks that the machine physically reads from memory) causes fewer memory
access loops and hence increased performance.
This is why the 'int' type is used : it's closest to that (according to how
it's defined in C).
So when we determine the amount of whitespace at the end of a string we do
the following :
1. We divide the string into 3 zones :
a) from the start of the string (__start) to the first multiple
of sizeof(int) (__start_words)
b) from the end of the string (__end) to the last multiple of sizeof(int)
(__end_words)
c) a zone that is aligned to sizeof(int) and can be safely accessed
through an int *
2. We start comparing backwards from (c) char-by-char. If all we find is
space then we continue
3. If there are elements in zone (b) we compare them as unsigned ints to a
int mask (SPACE_INT) consisting of all spaces
4. Finally we compare the remaining part (a) of the string char by char.
This covers for the last non-space unsigned int from 3. (if any)
This algorithm works well for relatively larger strings, but it will slow
the things down for smaller strings (because of the additional calculations
and checks compared to the naive method). Thus the barrier of length 20
is added.
@param ptr pointer to the input string
@param len the length of the string
@return the last non-space character
*/
static inline const uchar *skip_trailing_space(const uchar *ptr,size_t len)
{
const uchar *end= ptr + len;
if (len > 20)
{
const uchar *end_words= (const uchar *)(intptr)
(((ulonglong)(intptr)end) / SIZEOF_INT * SIZEOF_INT);
const uchar *start_words= (const uchar *)(intptr)
((((ulonglong)(intptr)ptr) + SIZEOF_INT - 1) / SIZEOF_INT * SIZEOF_INT);
DBUG_ASSERT(((ulonglong)(intptr)ptr) >= SIZEOF_INT);
if (end_words > ptr)
{
while (end > end_words && end[-1] == 0x20)
end--;
if (end[-1] == 0x20 && start_words < end_words)
while (end > start_words && ((unsigned *)end)[-1] == SPACE_INT)
end -= SIZEOF_INT;
}
}
while (end > ptr && end[-1] == 0x20)
end--;
return (end);
}
#endif

View File

@ -1,3 +1,6 @@
#ifndef MY_AES_INCLUDED
#define MY_AES_INCLUDED
/* Copyright (C) 2002 MySQL AB
This program is free software; you can redistribute it and/or modify
@ -63,3 +66,5 @@ int my_aes_decrypt(const char *source, int source_length, char *dest,
int my_aes_get_size(int source_length);
C_MODE_END
#endif /* MY_AES_INCLUDED */

View File

@ -33,15 +33,15 @@ extern ulong my_time_to_wait_for_lock;
#define ALARM_INIT my_have_got_alarm=0 ; \
alarm_old=(uint) alarm(MY_HOW_OFTEN_TO_ALARM); \
alarm_signal=signal(SIGALRM,my_set_alarm_variable);
#define ALARM_END VOID(signal(SIGALRM,alarm_signal)); \
VOID(alarm(alarm_old));
#define ALARM_END (void) signal(SIGALRM,alarm_signal); \
(void) alarm(alarm_old);
#define ALARM_TEST my_have_got_alarm
#ifdef DONT_REMEMBER_SIGNAL
#define ALARM_REINIT VOID(alarm(MY_HOW_OFTEN_TO_ALARM)); \
VOID(signal(SIGALRM,my_set_alarm_variable));\
#define ALARM_REINIT (void) alarm(MY_HOW_OFTEN_TO_ALARM); \
(void) signal(SIGALRM,my_set_alarm_variable);\
my_have_got_alarm=0;
#else
#define ALARM_REINIT VOID(alarm((uint) MY_HOW_OFTEN_TO_ALARM)); \
#define ALARM_REINIT (void) alarm((uint) MY_HOW_OFTEN_TO_ALARM); \
my_have_got_alarm=0;
#endif /* DONT_REMEMBER_SIGNAL */
#else

View File

@ -1,3 +1,6 @@
#ifndef MY_ATOMIC_INCLUDED
#define MY_ATOMIC_INCLUDED
/* Copyright (C) 2006 MySQL AB
This program is free software; you can redistribute it and/or modify
@ -13,9 +16,51 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/*
This header defines five atomic operations:
my_atomic_add#(&var, what)
add 'what' to *var, and return the old value of *var
my_atomic_fas#(&var, what)
'Fetch And Store'
store 'what' in *var, and return the old value of *var
my_atomic_cas#(&var, &old, new)
'Compare And Swap'
if *var is equal to *old, then store 'new' in *var, and return TRUE
otherwise store *var in *old, and return FALSE
my_atomic_load#(&var)
return *var
my_atomic_store#(&var, what)
store 'what' in *var
'#' is substituted by a size suffix - 8, 16, 32, or ptr
(e.g. my_atomic_add8, my_atomic_fas32, my_atomic_casptr).
NOTE This operations are not always atomic, so they always must be
enclosed in my_atomic_rwlock_rdlock(lock)/my_atomic_rwlock_rdunlock(lock)
or my_atomic_rwlock_wrlock(lock)/my_atomic_rwlock_wrunlock(lock).
Hint: if a code block makes intensive use of atomic ops, it make sense
to take/release rwlock once for the whole block, not for every statement.
On architectures where these operations are really atomic, rwlocks will
be optimized away.
8- and 16-bit atomics aren't implemented for windows (see generic-msvc.h),
but can be added, if necessary.
*/
#ifndef my_atomic_rwlock_init
#define intptr void *
/**
On most platforms we implement 8-bit, 16-bit, 32-bit and "pointer"
operations. Thus the symbol below is defined by default; platforms
where we leave out 8-bit or 16-bit operations should undefine it.
*/
#define MY_ATOMIC_HAS_8_16 1
#ifndef MY_ATOMIC_MODE_RWLOCKS
/*
@ -24,129 +69,229 @@
#include "atomic/nolock.h"
#endif
#ifndef MY_ATOMIC_NOLOCK
/*
* Have to use rw-locks for atomic ops
*/
#ifndef make_atomic_cas_body
/* nolock.h was not able to generate even a CAS function, fall back */
#include "atomic/rwlock.h"
#endif
#ifndef MY_ATOMICS_MADE
#else
/* define missing functions by using the already generated ones */
#ifndef make_atomic_add_body
#define make_atomic_add_body(S) \
#define make_atomic_add_body(S) \
int ## S tmp=*a; \
while (!my_atomic_cas ## S(a, &tmp, tmp+v)); \
v=tmp;
#endif
#ifndef make_atomic_fas_body
#define make_atomic_fas_body(S) \
int ## S tmp=*a; \
while (!my_atomic_cas ## S(a, &tmp, v)); \
v=tmp;
#endif
#ifndef make_atomic_load_body
#define make_atomic_load_body(S) \
ret= 0; /* avoid compiler warning */ \
(void)(my_atomic_cas ## S(a, &ret, ret));
#endif
#ifndef make_atomic_store_body
#define make_atomic_store_body(S) \
(void)(my_atomic_fas ## S (a, v));
#endif
#endif
/*
transparent_union doesn't work in g++
Bug ?
Darwin's gcc doesn't want to put pointers in a transparent_union
when built with -arch ppc64. Complains:
warning: 'transparent_union' attribute ignored
*/
#if defined(__GNUC__) && !defined(__cplusplus) && \
! (defined(__APPLE__) && defined(_ARCH_PPC64))
/*
we want to be able to use my_atomic_xxx functions with
both signed and unsigned integers. But gcc will issue a warning
"passing arg N of `my_atomic_XXX' as [un]signed due to prototype"
if the signedness of the argument doesn't match the prototype, or
"pointer targets in passing argument N of my_atomic_XXX differ in signedness"
if int* is used where uint* is expected (or vice versa).
Let's shut these warnings up
*/
#define make_transparent_unions(S) \
typedef union { \
int ## S i; \
uint ## S u; \
} U_ ## S __attribute__ ((transparent_union)); \
typedef union { \
int ## S volatile *i; \
uint ## S volatile *u; \
} Uv_ ## S __attribute__ ((transparent_union));
#define uintptr intptr
make_transparent_unions(8)
make_transparent_unions(16)
make_transparent_unions(32)
make_transparent_unions(ptr)
#undef uintptr
#undef make_transparent_unions
#define a U_a.i
#define cmp U_cmp.i
#define v U_v.i
#define set U_set.i
#else
#define U_8 int8
#define U_16 int16
#define U_32 int32
#define U_ptr intptr
#define Uv_8 int8
#define Uv_16 int16
#define Uv_32 int32
#define Uv_ptr intptr
#define U_a volatile *a
#define U_cmp *cmp
#define U_v v
#define U_set set
#endif /* __GCC__ transparent_union magic */
#ifdef HAVE_INLINE
#define make_atomic_add(S) \
STATIC_INLINE int ## S my_atomic_add ## S( \
int ## S volatile *a, int ## S v) \
{ \
make_atomic_add_body(S); \
return v; \
#define make_atomic_cas(S) \
STATIC_INLINE int my_atomic_cas ## S(Uv_ ## S U_a, \
Uv_ ## S U_cmp, U_ ## S U_set) \
{ \
int8 ret; \
make_atomic_cas_body(S); \
return ret; \
}
#define make_atomic_swap(S) \
STATIC_INLINE int ## S my_atomic_swap ## S( \
int ## S volatile *a, int ## S v) \
{ \
make_atomic_swap_body(S); \
return v; \
#define make_atomic_add(S) \
STATIC_INLINE int ## S my_atomic_add ## S( \
Uv_ ## S U_a, U_ ## S U_v) \
{ \
make_atomic_add_body(S); \
return v; \
}
#define make_atomic_cas(S) \
STATIC_INLINE int my_atomic_cas ## S(int ## S volatile *a, \
int ## S *cmp, int ## S set) \
{ \
int8 ret; \
make_atomic_cas_body(S); \
return ret; \
#define make_atomic_fas(S) \
STATIC_INLINE int ## S my_atomic_fas ## S( \
Uv_ ## S U_a, U_ ## S U_v) \
{ \
make_atomic_fas_body(S); \
return v; \
}
#define make_atomic_load(S) \
STATIC_INLINE int ## S my_atomic_load ## S(int ## S volatile *a) \
{ \
int ## S ret; \
make_atomic_load_body(S); \
return ret; \
#define make_atomic_load(S) \
STATIC_INLINE int ## S my_atomic_load ## S(Uv_ ## S U_a) \
{ \
int ## S ret; \
make_atomic_load_body(S); \
return ret; \
}
#define make_atomic_store(S) \
STATIC_INLINE void my_atomic_store ## S( \
int ## S volatile *a, int ## S v) \
{ \
make_atomic_store_body(S); \
#define make_atomic_store(S) \
STATIC_INLINE void my_atomic_store ## S( \
Uv_ ## S U_a, U_ ## S U_v) \
{ \
make_atomic_store_body(S); \
}
#else /* no inline functions */
#define make_atomic_add(S) \
extern int ## S my_atomic_add ## S(int ## S volatile *a, int ## S v);
#define make_atomic_add(S) \
extern int ## S my_atomic_add ## S(Uv_ ## S U_a, U_ ## S U_v);
#define make_atomic_swap(S) \
extern int ## S my_atomic_swap ## S(int ## S volatile *a, int ## S v);
#define make_atomic_fas(S) \
extern int ## S my_atomic_fas ## S(Uv_ ## S U_a, U_ ## S U_v);
#define make_atomic_cas(S) \
extern int my_atomic_cas ## S(int ## S volatile *a, int ## S *cmp, int ## S set);
#define make_atomic_cas(S) \
extern int my_atomic_cas ## S(Uv_ ## S U_a, Uv_ ## S U_cmp, U_ ## S U_set);
#define make_atomic_load(S) \
extern int ## S my_atomic_load ## S(int ## S volatile *a);
#define make_atomic_load(S) \
extern int ## S my_atomic_load ## S(Uv_ ## S U_a);
#define make_atomic_store(S) \
extern void my_atomic_store ## S(int ## S volatile *a, int ## S v);
#define make_atomic_store(S) \
extern void my_atomic_store ## S(Uv_ ## S U_a, U_ ## S U_v);
#endif /* HAVE_INLINE */
make_atomic_cas( 8)
#ifdef MY_ATOMIC_HAS_8_16
make_atomic_cas(8)
make_atomic_cas(16)
#endif
make_atomic_cas(32)
make_atomic_cas(ptr)
make_atomic_add( 8)
#ifdef MY_ATOMIC_HAS_8_16
make_atomic_add(8)
make_atomic_add(16)
#endif
make_atomic_add(32)
make_atomic_load( 8)
#ifdef MY_ATOMIC_HAS_8_16
make_atomic_load(8)
make_atomic_load(16)
#endif
make_atomic_load(32)
make_atomic_load(ptr)
make_atomic_store( 8)
#ifdef MY_ATOMIC_HAS_8_16
make_atomic_fas(8)
make_atomic_fas(16)
#endif
make_atomic_fas(32)
make_atomic_fas(ptr)
#ifdef MY_ATOMIC_HAS_8_16
make_atomic_store(8)
make_atomic_store(16)
#endif
make_atomic_store(32)
make_atomic_store(ptr)
make_atomic_swap( 8)
make_atomic_swap(16)
make_atomic_swap(32)
make_atomic_swap(ptr)
#undef make_atomic_add
#undef make_atomic_cas
#undef make_atomic_load
#undef make_atomic_store
#undef make_atomic_swap
#undef make_atomic_add_body
#undef make_atomic_cas_body
#undef make_atomic_load_body
#undef make_atomic_store_body
#undef make_atomic_swap_body
#undef intptr
#endif /* MY_ATOMICS_MADE */
#ifdef _atomic_h_cleanup_
#include _atomic_h_cleanup_
#undef _atomic_h_cleanup_
#endif
#undef U_8
#undef U_16
#undef U_32
#undef U_ptr
#undef Uv_8
#undef Uv_16
#undef Uv_32
#undef Uv_ptr
#undef a
#undef cmp
#undef v
#undef set
#undef U_a
#undef U_cmp
#undef U_v
#undef U_set
#undef make_atomic_add
#undef make_atomic_cas
#undef make_atomic_load
#undef make_atomic_store
#undef make_atomic_fas
#undef make_atomic_add_body
#undef make_atomic_cas_body
#undef make_atomic_load_body
#undef make_atomic_store_body
#undef make_atomic_fas_body
#undef intptr
/*
the macro below defines (as an expression) the code that
will be run in spin-loops. Intel manuals recummend to have PAUSE there.
It is expected to be defined in include/atomic/ *.h files
*/
#ifndef LF_BACKOFF
#define LF_BACKOFF (1)
#endif
#define MY_ATOMIC_OK 0
#define MY_ATOMIC_NOT_1CPU 1
extern int my_atomic_initialize();
#endif
#endif /* MY_ATOMIC_INCLUDED */

View File

@ -255,7 +255,17 @@ enum ha_base_keytype {
HA_BINARY_PACK_KEY | HA_FULLTEXT | HA_UNIQUE_CHECK | \
HA_SPATIAL | HA_NULL_ARE_EQUAL | HA_GENERATED_KEY)
#define HA_KEY_HAS_PART_KEY_SEG 65536 /* Key contains partial segments */
/*
Key contains partial segments.
This flag is internal to the MySQL server by design. It is not supposed
neither to be saved in FRM-files, nor to be passed to storage engines.
It is intended to pass information into internal static sort_keys(KEY *,
KEY *) function.
This flag can be calculated -- it's based on key lengths comparison.
*/
#define HA_KEY_HAS_PART_KEY_SEG 65536
/* Automatic bits in key-flag */

View File

@ -1,3 +1,6 @@
#ifndef MY_BIT_INCLUDED
#define MY_BIT_INCLUDED
/*
Some useful bit functions
*/
@ -107,3 +110,5 @@ extern uint my_count_bits(ulonglong v);
extern uint my_count_bits_ushort(ushort v);
#endif /* HAVE_INLINE */
C_MODE_END
#endif /* MY_BIT_INCLUDED */

View File

@ -16,101 +16,64 @@
#ifndef _dbug_h
#define _dbug_h
#if defined(__cplusplus) && !defined(DBUG_OFF)
class Dbug_violation_helper
{
public:
inline Dbug_violation_helper() :
_entered(TRUE)
{ }
inline ~Dbug_violation_helper()
{
assert(!_entered);
}
inline void leave()
{
_entered= FALSE;
}
private:
bool _entered;
};
#endif /* C++ */
#ifdef __cplusplus
#ifdef __cplusplus
extern "C" {
#endif
#if !defined(DBUG_OFF) && !defined(_lint)
struct _db_code_state_;
extern int _db_keyword_(struct _db_code_state_ *cs, const char *keyword);
extern int _db_strict_keyword_(const char *keyword);
struct _db_stack_frame_ {
const char *func; /* function name of the previous stack frame */
const char *file; /* filename of the function of previous frame */
uint level; /* this nesting level, highest bit enables tracing */
struct _db_stack_frame_ *prev; /* pointer to the previous frame */
};
struct _db_code_state_;
extern my_bool _dbug_on_;
extern my_bool _db_keyword_(struct _db_code_state_ *, const char *, int);
extern int _db_explain_(struct _db_code_state_ *cs, char *buf, size_t len);
extern int _db_explain_init_(char *buf, size_t len);
extern void _db_setjmp_(void);
extern void _db_longjmp_(void);
extern int _db_is_pushed_(void);
extern void _db_setjmp_(void);
extern void _db_longjmp_(void);
extern void _db_process_(const char *name);
extern void _db_push_(const char *control);
extern void _db_pop_(void);
extern void _db_set_(struct _db_code_state_ *cs, const char *control);
extern void _db_push_(const char *control);
extern void _db_pop_(void);
extern void _db_set_(const char *control);
extern void _db_set_init_(const char *control);
extern void _db_enter_(const char *_func_,const char *_file_,uint _line_,
const char **_sfunc_,const char **_sfile_,
uint *_slevel_, char ***);
extern void _db_return_(uint _line_,const char **_sfunc_,const char **_sfile_,
uint *_slevel_);
extern void _db_pargs_(uint _line_,const char *keyword);
extern void _db_doprnt_ _VARARGS((const char *format,...))
extern void _db_enter_(const char *_func_, const char *_file_, uint _line_,
struct _db_stack_frame_ *_stack_frame_);
extern void _db_return_(uint _line_, struct _db_stack_frame_ *_stack_frame_);
extern void _db_pargs_(uint _line_,const char *keyword);
extern void _db_doprnt_ _VARARGS((const char *format,...))
ATTRIBUTE_FORMAT(printf, 1, 2);
extern void _db_dump_(uint _line_,const char *keyword,
extern void _db_dump_(uint _line_,const char *keyword,
const unsigned char *memory, size_t length);
extern void _db_end_(void);
extern void _db_lock_file_(void);
extern void _db_unlock_file_(void);
extern FILE *_db_fp_(void);
extern void _db_end_(void);
extern void _db_lock_file_(void);
extern void _db_unlock_file_(void);
extern FILE *_db_fp_(void);
extern void _db_flush_();
extern const char* _db_get_func_(void);
#ifdef __cplusplus
#define DBUG_ENTER(a) \
const char *_db_func_, *_db_file_; \
uint _db_level_; \
char **_db_framep_; \
Dbug_violation_helper dbug_violation_helper; \
_db_enter_ (a, __FILE__, __LINE__, &_db_func_, &_db_file_, \
&_db_level_, &_db_framep_)
#define DBUG_VIOLATION_HELPER_LEAVE dbug_violation_helper.leave()
#else /* C */
#define DBUG_ENTER(a) \
const char *_db_func_, *_db_file_; \
uint _db_level_; \
char **_db_framep_; \
_db_enter_ (a, __FILE__, __LINE__, &_db_func_, &_db_file_, \
&_db_level_, &_db_framep_)
#define DBUG_VIOLATION_HELPER_LEAVE do { } while(0)
#endif /* C++ */
#define DBUG_LEAVE \
DBUG_VIOLATION_HELPER_LEAVE; \
_db_return_ (__LINE__, &_db_func_, &_db_file_, &_db_level_)
#define DBUG_ENTER(a) struct _db_stack_frame_ _db_stack_frame_; \
_db_enter_ (a,__FILE__,__LINE__,&_db_stack_frame_)
#define DBUG_LEAVE _db_return_ (__LINE__, &_db_stack_frame_)
#define DBUG_RETURN(a1) do {DBUG_LEAVE; return(a1);} while(0)
#define DBUG_VOID_RETURN do {DBUG_LEAVE; return;} while(0)
#define DBUG_EXECUTE(keyword,a1) \
do {if (_db_keyword_(0, (keyword))) { a1 }} while(0)
do {if (_db_keyword_(0, (keyword), 0)) { a1 }} while(0)
#define DBUG_EXECUTE_IF(keyword,a1) \
do {if (_db_strict_keyword_ (keyword)) { a1 } } while(0)
do {if (_db_keyword_(0, (keyword), 1)) { a1 }} while(0)
#define DBUG_EVALUATE(keyword,a1,a2) \
(_db_keyword_(0,(keyword)) ? (a1) : (a2))
(_db_keyword_(0,(keyword), 0) ? (a1) : (a2))
#define DBUG_EVALUATE_IF(keyword,a1,a2) \
(_db_strict_keyword_((keyword)) ? (a1) : (a2))
(_db_keyword_(0,(keyword), 1) ? (a1) : (a2))
#define DBUG_PRINT(keyword,arglist) \
do {_db_pargs_(__LINE__,keyword); _db_doprnt_ arglist;} while(0)
#define DBUG_PUSH(a1) _db_push_ (a1)
#define DBUG_POP() _db_pop_ ()
#define DBUG_SET(a1) _db_set_ (0, (a1))
#define DBUG_SET(a1) _db_set_ (a1)
#define DBUG_SET_INITIAL(a1) _db_set_init_ (a1)
#define DBUG_PROCESS(a1) _db_process_(a1)
#define DBUG_FILE _db_fp_()
@ -123,37 +86,66 @@ extern FILE *_db_fp_(void);
#define DBUG_ASSERT(A) assert(A)
#define DBUG_EXPLAIN(buf,len) _db_explain_(0, (buf),(len))
#define DBUG_EXPLAIN_INITIAL(buf,len) _db_explain_init_((buf),(len))
#define IF_DBUG(A) A
#else /* No debugger */
#define DEBUGGER_OFF do { _dbug_on_= 0; } while(0)
#define DEBUGGER_ON do { _dbug_on_= 1; } while(0)
#ifndef __WIN__
#define DBUG_ABORT() (_db_flush_(), abort())
#else
/*
Avoid popup with abort/retry/ignore buttons. When BUG#31745 is fixed we can
call abort() instead of _exit(3) (now it would cause a "test signal" popup).
*/
#include <crtdbg.h>
#define DBUG_ABORT() (_db_flush_(),\
(void)_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE),\
(void)_CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR),\
_exit(3))
#endif
#define DBUG_CHECK_CRASH(func, op) \
do { char _dbuf_[255]; strxnmov(_dbuf_, sizeof(_dbuf_)-1, (func), (op)); \
DBUG_EXECUTE_IF(_dbuf_, DBUG_ABORT()); } while(0)
#define DBUG_CRASH_ENTER(func) \
DBUG_ENTER(func); DBUG_CHECK_CRASH(func, "_crash_enter")
#define DBUG_CRASH_RETURN(val) \
DBUG_CHECK_CRASH(_db_get_func_(), "_crash_return")
#define DBUG_CRASH_VOID_RETURN \
DBUG_CHECK_CRASH (_db_get_func_(), "_crash_return")
#else /* No debugger */
#define DBUG_ENTER(a1)
#define DBUG_LEAVE
#define DBUG_VIOLATION_HELPER_LEAVE
#define DBUG_RETURN(a1) do { return(a1); } while(0)
#define DBUG_VOID_RETURN do { return; } while(0)
#define DBUG_EXECUTE(keyword,a1) do { } while(0)
#define DBUG_EXECUTE_IF(keyword,a1) do { } while(0)
#define DBUG_RETURN(a1) do { return(a1); } while(0)
#define DBUG_VOID_RETURN do { return; } while(0)
#define DBUG_EXECUTE(keyword,a1) do { } while(0)
#define DBUG_EXECUTE_IF(keyword,a1) do { } while(0)
#define DBUG_EVALUATE(keyword,a1,a2) (a2)
#define DBUG_EVALUATE_IF(keyword,a1,a2) (a2)
#define DBUG_PRINT(keyword,arglist) do { } while(0)
#define DBUG_PUSH(a1)
#define DBUG_SET(a1) do { } while(0)
#define DBUG_SET_INITIAL(a1) do { } while(0)
#define DBUG_POP()
#define DBUG_PROCESS(a1)
#define DBUG_PRINT(keyword,arglist) do { } while(0)
#define DBUG_PUSH(a1) do { } while(0)
#define DBUG_SET(a1) do { } while(0)
#define DBUG_SET_INITIAL(a1) do { } while(0)
#define DBUG_POP() do { } while(0)
#define DBUG_PROCESS(a1) do { } while(0)
#define DBUG_SETJMP(a1) setjmp(a1)
#define DBUG_LONGJMP(a1) longjmp(a1)
#define DBUG_DUMP(keyword,a1,a2) do { } while(0)
#define DBUG_END()
#define DBUG_ASSERT(A) do { } while(0)
#define DBUG_LOCK_FILE
#define DBUG_DUMP(keyword,a1,a2) do { } while(0)
#define DBUG_END() do { } while(0)
#define DBUG_ASSERT(A) do { } while(0)
#define DBUG_LOCK_FILE do { } while(0)
#define DBUG_FILE (stderr)
#define DBUG_UNLOCK_FILE
#define DBUG_UNLOCK_FILE do { } while(0)
#define DBUG_EXPLAIN(buf,len)
#define DBUG_EXPLAIN_INITIAL(buf,len)
#define IF_DBUG(A)
#define DEBUGGER_OFF do { } while(0)
#define DEBUGGER_ON do { } while(0)
#define DBUG_ABORT() abort()
#define DBUG_CRASH_ENTER(func)
#define DBUG_CRASH_RETURN(val) do { return(val); } while(0)
#define DBUG_CRASH_VOID_RETURN do { return; } while(0)
#endif
#ifdef __cplusplus
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2000-2003 MySQL AB
/* Copyright (C) 2000-2003 MySQL AB, 2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -83,6 +83,16 @@
#endif
#endif /* _WIN32... */
#ifdef EMBEDDED_LIBRARY
#ifdef WITH_PERFSCHEMA_STORAGE_ENGINE
#undef WITH_PERFSCHEMA_STORAGE_ENGINE
#endif
#endif /* EMBEDDED_LIBRARY */
#ifdef WITH_PERFSCHEMA_STORAGE_ENGINE
#define HAVE_PSI_INTERFACE
#endif /* WITH_PERFSCHEMA_STORAGE_ENGINE */
/* Make it easier to add conditionl code for windows */
#ifdef __WIN__
#define IF_WIN(A,B) (A)
@ -542,17 +552,6 @@ extern "C" int madvise(void *addr, size_t len, int behav);
#define DONT_REMEMBER_SIGNAL
#endif
/* Define void to stop lint from generating "null effekt" comments */
#ifndef DONT_DEFINE_VOID
#ifdef _lint
int __void__;
#define VOID(X) (__void__ = (int) (X))
#else
#undef VOID
#define VOID(X) (X)
#endif
#endif /* DONT_DEFINE_VOID */
#if defined(_lint) || defined(FORCE_INIT_OF_VARS)
#define LINT_INIT(var) var=0 /* No uninitialize-warning */
#else
@ -649,8 +648,6 @@ C_MODE_END
# endif
#endif
#include <my_dbug.h>
#define MIN_ARRAY_SIZE 0 /* Zero or One. Gcc allows zero*/
#define ASCII_BITS_USED 8 /* Bit char used */
#define NEAR_F /* No near function handling */
@ -1177,6 +1174,8 @@ typedef char bool; /* Ordinary boolean values 0 1 */
#define reg16 register
#endif
#include <my_dbug.h>
/*
Sometimes we want to make sure that the variable is not put into
a register in debugging mode so we can see its value in the core

View File

@ -1,3 +1,6 @@
#ifndef MY_LIBWRAP_INCLUDED
#define MY_LIBWRAP_INCLUDED
/* Copyright (C) 2000 MySQL AB
This program is free software; you can redistribute it and/or modify
@ -25,3 +28,4 @@ extern int my_hosts_access(struct request_info *req);
extern char *my_eval_client(struct request_info *req);
#endif /* HAVE_LIBWRAP */
#endif /* MY_LIBWRAP_INCLUDED */

View File

@ -1,3 +1,6 @@
#ifndef MY_MD5_INCLUDED
#define MY_MD5_INCLUDED
/* Copyright (C) 2000 MySQL AB
This program is free software; you can redistribute it and/or modify
@ -52,3 +55,5 @@ do { \
my_MD5Update (&ctx, buf, len); \
my_MD5Final (digest, &ctx); \
} while (0)
#endif /* MY_MD__INCLUDED */

View File

@ -43,7 +43,7 @@ C_MODE_START
#include <sys/ioctl.h>
#endif
#if !defined(__WIN__) && !defined(HAVE_BROKEN_NETINET_INCLUDES) && !defined(__BEOS__) && !defined(__NETWARE__)
#if !defined(__WIN__) && !defined(HAVE_BROKEN_NETINET_INCLUDES) && !defined(__NETWARE__)
#include <netinet/in_systm.h>
#include <netinet/in.h>
#include <netinet/ip.h>
@ -73,11 +73,6 @@ C_MODE_START
#define in_addr_t uint32
#endif
/* On some operating systems (e.g. Solaris) INADDR_NONE is not defined */
#ifndef INADDR_NONE
#define INADDR_NONE -1 /* Error value from inet_addr */
#endif
/* Thread safe or portable version of some functions */
void my_inet_ntoa(struct in_addr in, char *buf);
@ -86,9 +81,6 @@ void my_inet_ntoa(struct in_addr in, char *buf);
Handling of gethostbyname_r()
*/
#if !defined(HPUX10)
struct hostent;
#endif /* HPUX */
#if !defined(HAVE_GETHOSTBYNAME_R)
struct hostent *my_gethostbyname_r(const char *name,
struct hostent *result, char *buffer,
@ -118,11 +110,5 @@ struct hostent *my_gethostbyname_r(const char *name,
#define GETHOSTBYNAME_BUFF_SIZE 2048
#endif
/* On SCO you get a link error when refering to h_errno */
#ifdef SCO
#undef h_errno
#define h_errno errno
#endif
C_MODE_END
#endif

View File

@ -1,4 +1,7 @@
/* Copyright (C) 2000 MySQL AB
#ifndef MY_NO_PTHREAD_INCLUDED
#define MY_NO_PTHREAD_INCLUDED
/* Copyright (C) 2000 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -14,9 +17,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#if !defined(_my_no_pthread_h) && !defined(THREAD)
#define _my_no_pthread_h
#ifndef THREAD
/*
This block is to access some thread-related type definitions
@ -47,4 +48,16 @@
#define rw_unlock(A)
#define rwlock_destroy(A)
#define mysql_mutex_init(A, B, C) do {} while (0)
#define mysql_mutex_lock(A) do {} while (0)
#define mysql_mutex_unlock(A) do {} while (0)
#define mysql_mutex_destroy(A) do {} while (0)
#define mysql_rwlock_init(A, B, C) do {} while (0)
#define mysql_rwlock_rdlock(A) do {} while (0)
#define mysql_rwlock_wrlock(A) do {} while (0)
#define mysql_rwlock_unlock(A) do {} while (0)
#define mysql_rwlock_destroy(A) do {} while (0)
#endif
#endif /* MY_NO_PTHREAD_INCLUDED */

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2000 MySQL AB
/* Copyright (C) 2000-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -35,7 +35,6 @@ typedef DWORD pthread_t;
typedef struct thread_attr {
DWORD dwStackSize ;
DWORD dwCreatingFlag ;
int priority ;
} pthread_attr_t ;
typedef struct { int dummy; } pthread_condattr_t;
@ -100,7 +99,7 @@ struct timespec {
int win_pthread_mutex_trylock(pthread_mutex_t *mutex);
int pthread_create(pthread_t *,pthread_attr_t *,pthread_handler,void *);
int pthread_create(pthread_t *, const pthread_attr_t *, pthread_handler, void *);
int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr);
int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex);
int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
@ -110,7 +109,6 @@ int pthread_cond_broadcast(pthread_cond_t *cond);
int pthread_cond_destroy(pthread_cond_t *cond);
int pthread_attr_init(pthread_attr_t *connect_att);
int pthread_attr_setstacksize(pthread_attr_t *connect_att,DWORD stack);
int pthread_attr_setprio(pthread_attr_t *connect_att,int priority);
int pthread_attr_destroy(pthread_attr_t *connect_att);
struct tm *localtime_r(const time_t *timep,struct tm *tmp);
struct tm *gmtime_r(const time_t *timep,struct tm *tmp);
@ -139,21 +137,21 @@ int pthread_join(pthread_t thread, void **value_ptr);
#define pthread_mutex_init(A,B) (InitializeCriticalSection(A),0)
#define pthread_mutex_lock(A) (EnterCriticalSection(A),0)
#define pthread_mutex_trylock(A) win_pthread_mutex_trylock((A))
#define pthread_mutex_unlock(A) LeaveCriticalSection(A)
#define pthread_mutex_destroy(A) DeleteCriticalSection(A)
#define my_pthread_setprio(A,B) SetThreadPriority(GetCurrentThread(), (B))
#define pthread_mutex_unlock(A) (LeaveCriticalSection(A), 0)
#define pthread_mutex_destroy(A) (DeleteCriticalSection(A), 0)
#define pthread_kill(A,B) pthread_dummy((A) ? 0 : ESRCH)
/* Dummy defines for easier code */
#define pthread_attr_setdetachstate(A,B) pthread_dummy(0)
#define my_pthread_attr_setprio(A,B) pthread_attr_setprio(A,B)
#define pthread_attr_setscope(A,B)
#define pthread_detach_this_thread()
#define pthread_condattr_init(A)
#define pthread_condattr_destroy(A)
#define pthread_yield() SwitchToThread()
#define my_pthread_getprio(thread_id) pthread_dummy(0)
/* per the platform's documentation */
#define pthread_yield() Sleep(0)
#else /* Normal threads */
@ -181,8 +179,6 @@ void my_pthread_exit(void *status);
#define pthread_exit(A) my_pthread_exit(A)
#endif
extern int my_pthread_getprio(pthread_t thread_id);
#define pthread_key(T,V) pthread_key_t V
#define my_pthread_getspecific_ptr(T,V) my_pthread_getspecific(T,(V))
#define my_pthread_setspecific_ptr(T,V) pthread_setspecific(T,(void*) (V))
@ -254,32 +250,6 @@ int sigwait(sigset_t *setp, int *sigp); /* Use our implemention */
#define my_sigset(A,B) signal((A),(B))
#endif
#ifndef my_pthread_setprio
#if defined(HAVE_PTHREAD_SETPRIO_NP) /* FSU threads */
#define my_pthread_setprio(A,B) pthread_setprio_np((A),(B))
#elif defined(HAVE_PTHREAD_SETPRIO)
#define my_pthread_setprio(A,B) pthread_setprio((A),(B))
#elif defined(HAVE_PTHREAD_SETSCHEDPRIO) && !defined (__GNUC__)
/*
Workaround for bug on Solaris where pthread.h have bug in GNU
version of pthread.h => configure says yes, header files says
no. So not used with gcc and issue is Solaris only, so will
be used on Solaris using SunStudio.
*/
#define my_pthread_setprio(A,B) pthread_setschedprio((A),(B))
#else
extern void my_pthread_setprio(pthread_t thread_id,int prior);
#endif
#endif
#ifndef my_pthread_attr_setprio
#ifdef HAVE_PTHREAD_ATTR_SETPRIO
#define my_pthread_attr_setprio(A,B) pthread_attr_setprio((A),(B))
#else
extern void my_pthread_attr_setprio(pthread_attr_t *attr, int priority);
#endif
#endif
#if !defined(HAVE_PTHREAD_ATTR_SETSCOPE) || defined(HAVE_DEC_3_2_THREADS)
#define pthread_attr_setscope(A,B)
#undef HAVE_GETHOSTBYADDR_R /* No definition */
@ -385,6 +355,17 @@ void my_pthread_attr_getstacksize(pthread_attr_t *attrib, size_t *size);
int my_pthread_mutex_trylock(pthread_mutex_t *mutex);
#endif
#if !defined(HAVE_PTHREAD_YIELD_ONE_ARG) && !defined(HAVE_PTHREAD_YIELD_ZERO_ARG)
/* no pthread_yield() available */
#ifdef HAVE_SCHED_YIELD
#define pthread_yield() sched_yield()
#elif defined(HAVE_PTHREAD_YIELD_NP) /* can be Mac OS X */
#define pthread_yield() pthread_yield_np()
#elif defined(HAVE_THR_YIELD)
#define pthread_yield() thr_yield()
#endif
#endif
/*
The defines set_timespec and set_timespec_nsec should be used
for calculating an absolute time at which
@ -649,6 +630,10 @@ extern int pthread_dummy(int);
#endif
#endif
#include <mysql/psi/mysql_thread.h>
#define INSTRUMENT_ME 0
struct st_my_thread_var
{
int thr_errno;
@ -663,6 +648,7 @@ struct st_my_thread_var
my_bool init;
struct st_my_thread_var *next,**prev;
void *opt_info;
void *stack_ends_here;
#ifndef DBUG_OFF
void *dbug;
char name[THREAD_NAME_SIZE+1];
@ -670,6 +656,7 @@ struct st_my_thread_var
};
extern struct st_my_thread_var *_my_thread_var(void) __attribute__ ((const));
extern void **my_thread_var_dbug();
extern uint my_thread_end_wait_time;
#define my_thread_var (_my_thread_var())
#define my_errno my_thread_var->thr_errno

129
include/my_rdtsc.h Normal file
View File

@ -0,0 +1,129 @@
/* Copyright (C) 2008, 2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/*
rdtsc3 -- multi-platform timer code
pgulutzan@mysql.com, 2005-08-29
modified 2008-11-02
*/
#ifndef MY_RDTSC_H
#define MY_RDTSC_H
/**
Characteristics of a timer.
*/
struct my_timer_unit_info
{
/** Routine used for the timer. */
ulonglong routine;
/** Overhead of the timer. */
ulonglong overhead;
/** Frequency of the timer. */
ulonglong frequency;
/** Resolution of the timer. */
ulonglong resolution;
};
/**
Characteristics of all the supported timers.
@sa my_timer_init().
*/
struct my_timer_info
{
/** Characteristics of the cycle timer. */
struct my_timer_unit_info cycles;
/** Characteristics of the nanosecond timer. */
struct my_timer_unit_info nanoseconds;
/** Characteristics of the microsecond timer. */
struct my_timer_unit_info microseconds;
/** Characteristics of the millisecond timer. */
struct my_timer_unit_info milliseconds;
/** Characteristics of the tick timer. */
struct my_timer_unit_info ticks;
};
typedef struct my_timer_info MY_TIMER_INFO;
C_MODE_START
/**
A cycle timer.
@return the current timer value, in cycles.
*/
ulonglong my_timer_cycles(void);
/**
A namoseconds timer.
@return the current timer value, in nanoseconds.
*/
ulonglong my_timer_nanoseconds(void);
/**
A microseconds timer.
@return the current timer value, in microseconds.
*/
ulonglong my_timer_microseconds(void);
/**
A millisecond timer.
@return the current timer value, in milliseconds.
*/
ulonglong my_timer_milliseconds(void);
/**
A ticks timer.
@return the current timer value, in ticks.
*/
ulonglong my_timer_ticks(void);
/**
Timer initialization function.
@param [out] mti the timer characteristics.
*/
void my_timer_init(MY_TIMER_INFO *mti);
C_MODE_END
#define MY_TIMER_ROUTINE_ASM_X86 1
#define MY_TIMER_ROUTINE_ASM_X86_64 2
#define MY_TIMER_ROUTINE_RDTSCLL 3
#define MY_TIMER_ROUTINE_ASM_X86_WIN 4
#define MY_TIMER_ROUTINE_RDTSC 5
#define MY_TIMER_ROUTINE_ASM_IA64 6
#define MY_TIMER_ROUTINE_ASM_PPC 7
#define MY_TIMER_ROUTINE_SGI_CYCLE 8
#define MY_TIMER_ROUTINE_GETHRTIME 9
#define MY_TIMER_ROUTINE_READ_REAL_TIME 10
#define MY_TIMER_ROUTINE_CLOCK_GETTIME 11
#define MY_TIMER_ROUTINE_NXGETTIME 12
#define MY_TIMER_ROUTINE_GETTIMEOFDAY 13
#define MY_TIMER_ROUTINE_QUERYPERFORMANCECOUNTER 14
#define MY_TIMER_ROUTINE_GETTICKCOUNT 15
#define MY_TIMER_ROUTINE_TIME 16
#define MY_TIMER_ROUTINE_TIMES 17
#define MY_TIMER_ROUTINE_FTIME 18
#define MY_TIMER_ROUTINE_ASM_PPC64 19
#define MY_TIMER_ROUTINE_ASM_SUNPRO_SPARC64 20
#define MY_TIMER_ROUTINE_ASM_SUNPRO_SPARC32 21
#define MY_TIMER_ROUTINE_ASM_SUNPRO_I386 22
#define MY_TIMER_ROUTINE_ASM_GCC_SPARC64 23
#define MY_TIMER_ROUTINE_ASM_GCC_SPARC32 24
#define MY_TIMER_ROUTINE_MACH_ABSOLUTE_TIME 25
#define MY_TIMER_ROUTINE_GETSYSTEMTIMEASFILETIME 26
#define MY_TIMER_ROUTINE_ASM_SUNPRO_X86_64 27
#endif

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2000-2003 MySQL AB
/* Copyright (C) 2000-2003 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -60,7 +60,7 @@ extern int NEAR my_errno; /* Last error in mysys */
#define MY_WME 16 /* Write message on error */
#define MY_WAIT_IF_FULL 32 /* Wait and try again if disk full error */
#define MY_IGNORE_BADFD 32 /* my_sync: ignore 'bad descriptor' errors */
#define MY_SYNC_DIR 1024 /* my_create/delete/rename: sync directory */
#define MY_SYNC_DIR 8192 /* my_create/delete/rename: sync directory */
#define MY_RAID 64 /* Support for RAID */
#define MY_FULL_IO 512 /* For my_read - loop intil I/O is complete */
#define MY_DONT_CHECK_FILESIZE 128 /* Option to init_io_cache() */
@ -683,6 +683,8 @@ extern void my_error _VARARGS((int nr,myf MyFlags, ...));
extern void my_printf_error _VARARGS((uint my_err, const char *format,
myf MyFlags, ...))
ATTRIBUTE_FORMAT(printf, 2, 4);
extern void my_printv_error(uint error, const char *format, myf MyFlags,
va_list ap);
extern int my_error_register(const char** (*get_errmsgs) (),
int first, int last);
extern const char **my_error_unregister(int first, int last);
@ -877,6 +879,7 @@ extern void *memdup_root(MEM_ROOT *root,const void *str, size_t len);
extern int get_defaults_options(int argc, char **argv,
char **defaults, char **extra_defaults,
char **group_suffix);
extern const char *args_separator;
extern int my_load_defaults(const char *conf_file, const char **groups,
int *argc, char ***argv, const char ***);
extern int load_defaults(const char *conf_file, const char **groups,
@ -1015,5 +1018,15 @@ void netware_reg_user(const char *ip, const char *user,
const char *application);
#endif
#include <mysql/psi/psi.h>
#ifdef HAVE_PSI_INTERFACE
extern MYSQL_PLUGIN_IMPORT struct PSI_bootstrap *PSI_hook;
void my_init_mysys_psi_keys(void);
#endif
struct st_mysql_file;
extern struct st_mysql_file *mysql_stdin;
C_MODE_END
#endif /* _my_sys_h */

View File

@ -1,3 +1,6 @@
#ifndef MY_UCTYPE_INCLUDED
#define MY_UCTYPE_INCLUDED
/* Copyright (C) 2006 MySQL AB
This program is free software; you can redistribute it and/or modify
@ -1477,3 +1480,4 @@ MY_UNI_CTYPE my_uni_ctype[256]={
};
#endif /* MY_UCTYPE_INCLUDED */

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2000 MySQL AB
/* Copyright (C) 2000 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -432,6 +432,10 @@ typedef struct st_mi_check_param
const char *db_name, *table_name;
const char *op_name;
enum_mi_stats_method stats_method;
#ifdef THREAD
mysql_mutex_t print_msg_mutex;
my_bool need_print_msg_lock;
#endif
} MI_CHECK;
typedef struct st_sort_ft_buf
@ -456,8 +460,8 @@ typedef struct st_sort_info
/* sync things */
uint got_error, threads_running;
#ifdef THREAD
pthread_mutex_t mutex;
pthread_cond_t cond;
mysql_mutex_t mutex;
mysql_cond_t cond;
#endif
} SORT_INFO;

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2000 MySQL AB
/* Copyright (C) 2000 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -75,7 +75,7 @@ typedef struct st_myrg_info
LIST open_list;
QUEUE by_key;
ulong *rec_per_key_part; /* for sql optimizing */
pthread_mutex_t mutex;
mysql_mutex_t mutex;
} MYRG_INFO;

View File

@ -1,3 +1,6 @@
#ifndef MYISAMPACK_INCLUDED
#define MYISAMPACK_INCLUDED
/* Copyright (C) 2000 MySQL AB
This program is free software; you can redistribute it and/or modify
@ -236,3 +239,4 @@
mi_int4store(((T) + 4), A); }}
#define mi_sizekorr(T) mi_uint4korr((uchar*) (T) + 4)
#endif
#endif /* MYISAMPACK_INCLUDED */

View File

@ -188,24 +188,10 @@ struct st_mysql_options {
unsigned long max_allowed_packet;
my_bool use_ssl; /* if to use SSL or not */
my_bool compress,named_pipe;
/*
On connect, find out the replication role of the server, and
establish connections to all the peers
*/
my_bool rpl_probe;
/*
Each call to mysql_real_query() will parse it to tell if it is a read
or a write, and direct it to the slave or the master
*/
my_bool rpl_parse;
/*
If set, never read from a master, only from slave, when doing
a read that is replication-aware
*/
my_bool no_master_reads;
#if !defined(CHECK_EMBEDDED_DIFFERENCES) || defined(EMBEDDED_LIBRARY)
my_bool separate_thread;
#endif
my_bool unused1;
my_bool unused2;
my_bool unused3;
my_bool unused4;
enum mysql_option methods_to_use;
char *client_ip;
/* Refuse client connecting to server if it uses old (pre-4.1.1) protocol */
@ -232,15 +218,6 @@ enum mysql_protocol_type
MYSQL_PROTOCOL_DEFAULT, MYSQL_PROTOCOL_TCP, MYSQL_PROTOCOL_SOCKET,
MYSQL_PROTOCOL_PIPE, MYSQL_PROTOCOL_MEMORY
};
/*
There are three types of queries - the ones that have to go to
the master, the ones that go to a slave, and the adminstrative
type which must happen on the pivot connectioin
*/
enum mysql_rpl_type
{
MYSQL_RPL_MASTER, MYSQL_RPL_SLAVE, MYSQL_RPL_ADMIN
};
typedef struct character_set
{
@ -285,21 +262,8 @@ typedef struct st_mysql
/* session-wide random string */
char scramble[SCRAMBLE_LENGTH+1];
/*
Set if this is the original connection, not a master or a slave we have
added though mysql_rpl_probe() or mysql_set_master()/ mysql_add_slave()
*/
my_bool rpl_pivot;
/*
Pointers to the master, and the next slave connections, points to
itself if lone connection.
*/
struct st_mysql* master, *next_slave;
struct st_mysql* last_used_slave; /* needed for round-robin slave pick */
/* needed for send/read/store/use result to work correctly with replication */
struct st_mysql* last_used_con;
my_bool unused1;
void *unused2, *unused3, *unused4, *unused5;
LIST *stmts; /* list of all statements */
const struct st_mysql_methods *methods;
@ -333,35 +297,12 @@ typedef struct st_mysql_res {
void *extension;
} MYSQL_RES;
#define MAX_MYSQL_MANAGER_ERR 256
#define MAX_MYSQL_MANAGER_MSG 256
#define MANAGER_OK 200
#define MANAGER_INFO 250
#define MANAGER_ACCESS 401
#define MANAGER_CLIENT_ERR 450
#define MANAGER_INTERNAL_ERR 500
#if !defined(MYSQL_SERVER) && !defined(MYSQL_CLIENT)
#define MYSQL_CLIENT
#endif
typedef struct st_mysql_manager
{
NET net;
char *host, *user, *passwd;
char *net_buf, *net_buf_pos, *net_data_end;
unsigned int port;
int cmd_status;
int last_errno;
int net_buf_size;
my_bool free_me;
my_bool eof;
char last_error[MAX_MYSQL_MANAGER_ERR];
void *extension;
} MYSQL_MANAGER;
typedef struct st_mysql_parameters
{
unsigned long *p_max_allowed_packet;
@ -454,16 +395,6 @@ int STDCALL mysql_real_query(MYSQL *mysql, const char *q,
MYSQL_RES * STDCALL mysql_store_result(MYSQL *mysql);
MYSQL_RES * STDCALL mysql_use_result(MYSQL *mysql);
/* perform query on master */
my_bool STDCALL mysql_master_query(MYSQL *mysql, const char *q,
unsigned long length);
my_bool STDCALL mysql_master_send_query(MYSQL *mysql, const char *q,
unsigned long length);
/* perform query on slave */
my_bool STDCALL mysql_slave_query(MYSQL *mysql, const char *q,
unsigned long length);
my_bool STDCALL mysql_slave_send_query(MYSQL *mysql, const char *q,
unsigned long length);
void STDCALL mysql_get_character_set_info(MYSQL *mysql,
MY_CHARSET_INFO *charset);
@ -485,37 +416,6 @@ mysql_set_local_infile_handler(MYSQL *mysql,
void
mysql_set_local_infile_default(MYSQL *mysql);
/*
enable/disable parsing of all queries to decide if they go on master or
slave
*/
void STDCALL mysql_enable_rpl_parse(MYSQL* mysql);
void STDCALL mysql_disable_rpl_parse(MYSQL* mysql);
/* get the value of the parse flag */
int STDCALL mysql_rpl_parse_enabled(MYSQL* mysql);
/* enable/disable reads from master */
void STDCALL mysql_enable_reads_from_master(MYSQL* mysql);
void STDCALL mysql_disable_reads_from_master(MYSQL* mysql);
/* get the value of the master read flag */
my_bool STDCALL mysql_reads_from_master_enabled(MYSQL* mysql);
enum mysql_rpl_type STDCALL mysql_rpl_query_type(const char* q, int len);
/* discover the master and its slaves */
my_bool STDCALL mysql_rpl_probe(MYSQL* mysql);
/* set the master, close/free the old one, if it is not a pivot */
int STDCALL mysql_set_master(MYSQL* mysql, const char* host,
unsigned int port,
const char* user,
const char* passwd);
int STDCALL mysql_add_slave(MYSQL* mysql, const char* host,
unsigned int port,
const char* user,
const char* passwd);
int STDCALL mysql_shutdown(MYSQL *mysql,
enum mysql_enum_shutdown_level
shutdown_level);
@ -562,18 +462,6 @@ void STDCALL mysql_debug(const char *debug);
void STDCALL myodbc_remove_escape(MYSQL *mysql,char *name);
unsigned int STDCALL mysql_thread_safe(void);
my_bool STDCALL mysql_embedded(void);
MYSQL_MANAGER* STDCALL mysql_manager_init(MYSQL_MANAGER* con);
MYSQL_MANAGER* STDCALL mysql_manager_connect(MYSQL_MANAGER* con,
const char* host,
const char* user,
const char* passwd,
unsigned int port);
void STDCALL mysql_manager_close(MYSQL_MANAGER* con);
int STDCALL mysql_manager_command(MYSQL_MANAGER* con,
const char* cmd, int cmd_len);
int STDCALL mysql_manager_fetch_line(MYSQL_MANAGER* con,
char* res_buf,
int res_buf_size);
my_bool STDCALL mysql_read_query_result(MYSQL *mysql);
@ -768,7 +656,7 @@ typedef struct st_mysql_methods
MYSQL_RES * (*use_result)(MYSQL *mysql);
void (*fetch_lengths)(unsigned long *to,
MYSQL_ROW column, unsigned int field_count);
void (*flush_use_result)(MYSQL *mysql);
void (*flush_use_result)(MYSQL *mysql, my_bool flush_all_results);
#if !defined(MYSQL_SERVER) || defined(EMBEDDED_LIBRARY)
MYSQL_FIELD * (*list_fields)(MYSQL *mysql);
my_bool (*read_prepare_result)(MYSQL *mysql, MYSQL_STMT *stmt);
@ -828,6 +716,7 @@ my_bool STDCALL mysql_rollback(MYSQL * mysql);
my_bool STDCALL mysql_autocommit(MYSQL * mysql, my_bool auto_mode);
my_bool STDCALL mysql_more_results(MYSQL *mysql);
int STDCALL mysql_next_result(MYSQL *mysql);
int STDCALL mysql_stmt_next_result(MYSQL_STMT *stmt);
void STDCALL mysql_close(MYSQL *sock);
@ -842,7 +731,6 @@ MYSQL * STDCALL mysql_connect(MYSQL *mysql, const char *host,
const char *user, const char *passwd);
int STDCALL mysql_create_db(MYSQL *mysql, const char *DB);
int STDCALL mysql_drop_db(MYSQL *mysql, const char *DB);
#define mysql_reload(mysql) mysql_refresh((mysql),REFRESH_GRANT)
#endif
#define HAVE_MYSQL_REAL_CONNECT

View File

@ -28,15 +28,15 @@ typedef struct st_net {
unsigned int *return_status;
unsigned char reading_or_writing;
char save_char;
my_bool unused0;
my_bool unused;
my_bool compress;
my_bool unused1;
unsigned char *query_cache_query;
my_bool unused2;
my_bool compress;
my_bool unused3;
unsigned char *unused;
unsigned int last_errno;
unsigned char error;
my_bool unused2;
my_bool return_errno;
my_bool unused4;
my_bool unused5;
char last_error[512];
char sqlstate[5 +1];
void *extension;
@ -277,10 +277,10 @@ struct st_mysql_options {
unsigned long max_allowed_packet;
my_bool use_ssl;
my_bool compress,named_pipe;
my_bool rpl_probe;
my_bool rpl_parse;
my_bool no_master_reads;
my_bool separate_thread;
my_bool unused1;
my_bool unused2;
my_bool unused3;
my_bool unused4;
enum mysql_option methods_to_use;
char *client_ip;
my_bool secure_auth;
@ -301,10 +301,6 @@ enum mysql_protocol_type
MYSQL_PROTOCOL_DEFAULT, MYSQL_PROTOCOL_TCP, MYSQL_PROTOCOL_SOCKET,
MYSQL_PROTOCOL_PIPE, MYSQL_PROTOCOL_MEMORY
};
enum mysql_rpl_type
{
MYSQL_RPL_MASTER, MYSQL_RPL_SLAVE, MYSQL_RPL_ADMIN
};
typedef struct character_set
{
unsigned int number;
@ -344,10 +340,8 @@ typedef struct st_mysql
my_bool free_me;
my_bool reconnect;
char scramble[20 +1];
my_bool rpl_pivot;
struct st_mysql* master, *next_slave;
struct st_mysql* last_used_slave;
struct st_mysql* last_used_con;
my_bool unused1;
void *unused2, *unused3, *unused4, *unused5;
LIST *stmts;
const struct st_mysql_methods *methods;
void *thd;
@ -371,20 +365,6 @@ typedef struct st_mysql_res {
my_bool unbuffered_fetch_cancelled;
void *extension;
} MYSQL_RES;
typedef struct st_mysql_manager
{
NET net;
char *host, *user, *passwd;
char *net_buf, *net_buf_pos, *net_data_end;
unsigned int port;
int cmd_status;
int last_errno;
int net_buf_size;
my_bool free_me;
my_bool eof;
char last_error[256];
void *extension;
} MYSQL_MANAGER;
typedef struct st_mysql_parameters
{
unsigned long *p_max_allowed_packet;
@ -437,14 +417,6 @@ int mysql_real_query(MYSQL *mysql, const char *q,
unsigned long length);
MYSQL_RES * mysql_store_result(MYSQL *mysql);
MYSQL_RES * mysql_use_result(MYSQL *mysql);
my_bool mysql_master_query(MYSQL *mysql, const char *q,
unsigned long length);
my_bool mysql_master_send_query(MYSQL *mysql, const char *q,
unsigned long length);
my_bool mysql_slave_query(MYSQL *mysql, const char *q,
unsigned long length);
my_bool mysql_slave_send_query(MYSQL *mysql, const char *q,
unsigned long length);
void mysql_get_character_set_info(MYSQL *mysql,
MY_CHARSET_INFO *charset);
void
@ -459,22 +431,6 @@ mysql_set_local_infile_handler(MYSQL *mysql,
void *);
void
mysql_set_local_infile_default(MYSQL *mysql);
void mysql_enable_rpl_parse(MYSQL* mysql);
void mysql_disable_rpl_parse(MYSQL* mysql);
int mysql_rpl_parse_enabled(MYSQL* mysql);
void mysql_enable_reads_from_master(MYSQL* mysql);
void mysql_disable_reads_from_master(MYSQL* mysql);
my_bool mysql_reads_from_master_enabled(MYSQL* mysql);
enum mysql_rpl_type mysql_rpl_query_type(const char* q, int len);
my_bool mysql_rpl_probe(MYSQL* mysql);
int mysql_set_master(MYSQL* mysql, const char* host,
unsigned int port,
const char* user,
const char* passwd);
int mysql_add_slave(MYSQL* mysql, const char* host,
unsigned int port,
const char* user,
const char* passwd);
int mysql_shutdown(MYSQL *mysql,
enum mysql_enum_shutdown_level
shutdown_level);
@ -521,18 +477,6 @@ void mysql_debug(const char *debug);
void myodbc_remove_escape(MYSQL *mysql,char *name);
unsigned int mysql_thread_safe(void);
my_bool mysql_embedded(void);
MYSQL_MANAGER* mysql_manager_init(MYSQL_MANAGER* con);
MYSQL_MANAGER* mysql_manager_connect(MYSQL_MANAGER* con,
const char* host,
const char* user,
const char* passwd,
unsigned int port);
void mysql_manager_close(MYSQL_MANAGER* con);
int mysql_manager_command(MYSQL_MANAGER* con,
const char* cmd, int cmd_len);
int mysql_manager_fetch_line(MYSQL_MANAGER* con,
char* res_buf,
int res_buf_size);
my_bool mysql_read_query_result(MYSQL *mysql);
enum enum_mysql_stmt_state
{
@ -616,7 +560,7 @@ typedef struct st_mysql_methods
MYSQL_RES * (*use_result)(MYSQL *mysql);
void (*fetch_lengths)(unsigned long *to,
MYSQL_ROW column, unsigned int field_count);
void (*flush_use_result)(MYSQL *mysql);
void (*flush_use_result)(MYSQL *mysql, my_bool flush_all_results);
MYSQL_FIELD * (*list_fields)(MYSQL *mysql);
my_bool (*read_prepare_result)(MYSQL *mysql, MYSQL_STMT *stmt);
int (*stmt_execute)(MYSQL_STMT *stmt);
@ -671,4 +615,5 @@ my_bool mysql_rollback(MYSQL * mysql);
my_bool mysql_autocommit(MYSQL * mysql, my_bool auto_mode);
my_bool mysql_more_results(MYSQL *mysql);
int mysql_next_result(MYSQL *mysql);
int mysql_stmt_next_result(MYSQL_STMT *stmt);
void mysql_close(MYSQL *sock);

Some files were not shown because too many files have changed in this diff Show More