Merge work:/home/bk/mysql-4.0
into serg.mysql.com:/usr/home/serg/Abk/mysql-4.0
25
.bzrignore
|
@ -7,6 +7,7 @@
|
|||
*.la
|
||||
*.lo
|
||||
*.o
|
||||
*.reject
|
||||
*.spec
|
||||
*/*_pure_*warnings
|
||||
*/.pure
|
||||
|
@ -152,6 +153,8 @@ client/mysqlbinlog
|
|||
client/mysqlcheck
|
||||
client/mysqldump
|
||||
client/mysqlimport
|
||||
client/mysqlmanager-pwgen
|
||||
client/mysqlmanagerc
|
||||
client/mysqlshow
|
||||
client/mysqltest
|
||||
client/mysys_priv.h
|
||||
|
@ -203,6 +206,17 @@ libmysqld/backup_dir
|
|||
libmysqld/convert.cc
|
||||
libmysqld/derror.cc
|
||||
libmysqld/errmsg.c
|
||||
libmysqld/examples/completion_hash.cc
|
||||
libmysqld/examples/completion_hash.h
|
||||
libmysqld/examples/my_readline.h
|
||||
libmysqld/examples/mysql
|
||||
libmysqld/examples/mysql.cc
|
||||
libmysqld/examples/mysqltest
|
||||
libmysqld/examples/mysqltest.c
|
||||
libmysqld/examples/readline.cc
|
||||
libmysqld/examples/sql_string.cc
|
||||
libmysqld/examples/sql_string.h
|
||||
libmysqld/examples/test-gdbinit
|
||||
libmysqld/field.cc
|
||||
libmysqld/field_conv.cc
|
||||
libmysqld/filesort.cc
|
||||
|
@ -326,6 +340,7 @@ scripts/make_binary_distribution
|
|||
scripts/msql2mysql
|
||||
scripts/mysql_config
|
||||
scripts/mysql_convert_table_format
|
||||
scripts/mysql_explain_log
|
||||
scripts/mysql_find_rows
|
||||
scripts/mysql_fix_privilege_tables
|
||||
scripts/mysql_install_db
|
||||
|
@ -402,13 +417,3 @@ vio/test-ssl
|
|||
vio/test-sslclient
|
||||
vio/test-sslserver
|
||||
vio/viotest-ssl
|
||||
libmysqld/examples/completion_hash.cc
|
||||
libmysqld/examples/completion_hash.h
|
||||
libmysqld/examples/my_readline.h
|
||||
libmysqld/examples/mysql.cc
|
||||
libmysqld/examples/mysqltest.c
|
||||
libmysqld/examples/readline.cc
|
||||
libmysqld/examples/sql_string.cc
|
||||
libmysqld/examples/sql_string.h
|
||||
libmysqld/examples/mysql
|
||||
libmysqld/examples/mysqltest
|
||||
|
|
13
BUILD/compile-ia64-debug-max
Executable file
|
@ -0,0 +1,13 @@
|
|||
gmake -k clean || true
|
||||
/bin/rm -f */.deps/*.P config.cache
|
||||
|
||||
aclocal && autoheader && aclocal && automake && autoconf
|
||||
(cd bdb/dist && sh s_all)
|
||||
(cd innobase && aclocal && autoheader && aclocal && automake && autoconf)
|
||||
if [ -d gemini ]
|
||||
then
|
||||
(cd gemini && aclocal && autoheader && aclocal && automake && autoconf)
|
||||
fi
|
||||
|
||||
CC=ecc CFLAGS="-w1 -DEXTRA_DEBUG -DSAFEMALLOC -DSAFE_MUTEX -O2" CXX=ecc CXXFLAGS="-w1 -DEXTRA_DEBUG -DSAFEMALLOC -DSAFE_MUTEX -O2" ./configure --prefix=/usr/local/mysql --with-extra-charsets=complex --enable-thread-safe-client --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static --with-debug --with-innodb --with-embedded-server
|
||||
gmake
|
|
@ -8,6 +8,6 @@ extra_configs="$pentium_configs"
|
|||
strip=yes
|
||||
|
||||
extra_configs="$extra_configs --with-innodb --with-berkeley-db \
|
||||
--enable-thread-safe-client"
|
||||
--enable-thread-safe-client --with-openssl --with-vio"
|
||||
|
||||
. "$path/FINISH.sh"
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
Administrator@fred.
|
||||
Miguel@light.local
|
||||
Sinisa@sinisa.nasamreza.org
|
||||
davida@isil.mysql.com
|
||||
heikki@donna.mysql.fi
|
||||
|
@ -26,5 +28,6 @@ tim@threads.polyesthetic.msg
|
|||
tim@white.box
|
||||
tim@work.mysql.com
|
||||
tonu@hundin.mysql.fi
|
||||
tonu@volk.internalnet
|
||||
tonu@x153.internalnet
|
||||
tonu@x3.internalnet
|
||||
|
|
|
@ -65,6 +65,7 @@ aclocal; autoheader; aclocal; automake; autoconf
|
|||
--enable-thread-safe-client \
|
||||
--with-berkeley-db \
|
||||
--with-innodb \
|
||||
--with-vio \
|
||||
--without-pstack \
|
||||
--with-extra-tools \
|
||||
--with-embedded-server
|
||||
|
|
|
@ -4,10 +4,10 @@ use Getopt::Long;
|
|||
$opt_distribution=$opt_user=$opt_result=$opt_config_options=$opt_config_env="";
|
||||
$opt_dbd_options=$opt_perl_options=$opt_suffix="";
|
||||
$opt_tmp=$version_suffix="";
|
||||
$opt_help=$opt_Information=$opt_no_delete=$opt_delete=$opt_debug=$opt_stage=$opt_rsh_mail=$opt_no_test=$opt_no_perl=$opt_with_low_memory=$opt_fast_benchmark=$opt_static_client=$opt_static_server=$opt_static_perl=$opt_sur=$opt_with_small_disk=$opt_local_perl=$opt_tcpip=$opt_build_thread=$opt_no_mysqltest=$opt_use_old_distribution=$opt_enable_shared=$opt_no_crash_me=$opt_no_strip=0;
|
||||
$opt_help=$opt_Information=$opt_delete=$opt_debug=$opt_stage=$opt_rsh_mail=$opt_no_test=$opt_no_perl=$opt_with_low_memory=$opt_fast_benchmark=$opt_static_client=$opt_static_server=$opt_static_perl=$opt_sur=$opt_with_small_disk=$opt_local_perl=$opt_tcpip=$opt_build_thread=$opt_no_mysqltest=$opt_use_old_distribution=$opt_enable_shared=$opt_no_crash_me=$opt_no_strip=0;
|
||||
$opt_innodb=$opt_bdb=0;
|
||||
|
||||
GetOptions("Information","help","distribution=s","user=s","result=s","no-delete","delete","no-test","no-mysqltest","perl-files=s","debug","config-options=s","config-env=s","stage=i","rsh-mail","with-low-memory","fast-benchmark","tmp=s","static-client","static-server","static-perl","no-perl","local-perl","perl-options=s","sur","with-small-disk","dbd-options=s","tcpip","suffix=s","build-thread=i","innodb","bdb","use-old-distribution","enable-shared","no-crash-me","no-strip") || usage();
|
||||
GetOptions("Information","help","distribution=s","user=s","result=s","delete","no-test","no-mysqltest","perl-files=s","debug","config-options=s","config-env=s","stage=i","rsh-mail","with-low-memory","fast-benchmark","tmp=s","static-client","static-server","static-perl","no-perl","local-perl","perl-options=s","sur","with-small-disk","dbd-options=s","tcpip","suffix=s","build-thread=i","innodb","bdb","use-old-distribution","enable-shared","no-crash-me","no-strip") || usage();
|
||||
|
||||
usage() if ($opt_help || $opt_Information);
|
||||
usage() if (!$opt_distribution);
|
||||
|
@ -105,14 +105,31 @@ $|=1;
|
|||
safe_cd("$host");
|
||||
if ($opt_stage == 0 && ! $opt_use_old_distribution)
|
||||
{
|
||||
my ($name);
|
||||
safe_system("gunzip < $opt_distribution | $tar xf -");
|
||||
|
||||
# Fix file times; This is needed because the time for files may be
|
||||
# in the future
|
||||
system("touch timestamp; find $var -newer timestamp -print | xargs touch; rm -f timestamp");
|
||||
sleep(2);
|
||||
# Ensure that files we don't want to rebuild are newer than other files
|
||||
foreach $name ("configure",
|
||||
"Docs/include.texi",
|
||||
"Docs/*.html", "Docs/manual.txt", "Docs/mysql.info",
|
||||
"sql/sql_yacc.h", "sql/sql_yacc.cc")
|
||||
{
|
||||
system("touch $name");
|
||||
}
|
||||
}
|
||||
|
||||
safe_cd($ver);
|
||||
if ($opt_stage <= 1)
|
||||
{
|
||||
$opt_config_options.=" --with-low-memory" if ($opt_with_low_memory);
|
||||
# Fix files if this is in another timezone than work.mysql.com
|
||||
unlink("config.cache");
|
||||
unlink("bdb/build_unix/config.cache");
|
||||
unlink("innobase/config.cache");
|
||||
log_system("$make clean") if ($opt_use_old_distribution);
|
||||
if ($opt_static_server)
|
||||
{
|
||||
|
@ -143,7 +160,7 @@ if ($opt_stage <= 1)
|
|||
|
||||
if ($opt_stage <= 2)
|
||||
{
|
||||
unlink($opt_distribution) if (!$opt_delete && !$opt_use_old_distribution);
|
||||
unlink($opt_distribution) if ($opt_delete && !$opt_use_old_distribution);
|
||||
safe_system("$make");
|
||||
}
|
||||
|
||||
|
|
|
@ -210,7 +210,7 @@ if [ $? != 0 ]; then
|
|||
tail $log
|
||||
fi
|
||||
|
||||
if [ ! x$local_build=x1 ]; then
|
||||
if [ x$local_build != x1 ]; then
|
||||
|
||||
# Build perl RPM (we currently need to be root to do this and that is
|
||||
# not possible)
|
||||
|
@ -228,5 +228,3 @@ if [ ! x$local_build=x1 ]; then
|
|||
#scp $owner@$bmachine:$rpmdir/SRPMS/Perl*-*.rpm $bpath/NEW-RPMS
|
||||
fi
|
||||
) > $log 2>&1
|
||||
|
||||
|
||||
|
|
0
Docs/Flags/belgium.gif
Executable file → Normal file
Before Width: | Height: | Size: 181 B After Width: | Height: | Size: 181 B |
258
Docs/Flags/mexico.eps
Normal file
|
@ -0,0 +1,258 @@
|
|||
%!PS-Adobe-3.0 EPSF-3.0
|
||||
%%Creator: Adobe Photoshop Version 5.5
|
||||
%%Title: mexico.eps
|
||||
%%CreationDate: Fri Sep 21 2001 22:25:39
|
||||
%%BoundingBox: 0 0 32 22
|
||||
%%HiResBoundingBox: 0 0 32 22
|
||||
%%SuppressDotGainCompensation
|
||||
%%EndComments
|
||||
%%BeginProlog
|
||||
%%EndProlog
|
||||
%%BeginSetup
|
||||
%%EndSetup
|
||||
%ImageData: 32 22 8 3 1 32 2 "beginimage"
|
||||
%BeginPhotoshop: 1362
|
||||
% 3842494D03ED000000000010004800000001000200480000000100023842494D
|
||||
% 040D000000000004000000783842494D03F30000000000080000000000000000
|
||||
% 3842494D040A00000000000100003842494D271000000000000A000100000000
|
||||
% 000000023842494D03F5000000000048002F66660001006C6666000600000000
|
||||
% 0001002F6666000100A1999A0006000000000001003200000001005A00000006
|
||||
% 000000000001003500000001002D000000060000000000013842494D03F80000
|
||||
% 000000700000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF03E80000
|
||||
% 0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF03E800000000FFFF
|
||||
% FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF03E800000000FFFFFFFFFFFF
|
||||
% FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF03E800003842494D0408000000000010
|
||||
% 000000010000024000000240000000003842494D041400000000000400000001
|
||||
% 3842494D040C0000000003D30000000100000020000000160000006000000840
|
||||
% 000003B700180001FFD8FFE000104A46494600010201004800480000FFEE000E
|
||||
% 41646F626500648000000001FFDB0084000C08080809080C09090C110B0A0B11
|
||||
% 150F0C0C0F1518131315131318110C0C0C0C0C0C110C0C0C0C0C0C0C0C0C0C0C
|
||||
% 0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C010D0B0B0D0E0D100E0E10140E0E0E
|
||||
% 14140E0E0E0E14110C0C0C0C0C11110C0C0C0C0C0C110C0C0C0C0C0C0C0C0C0C
|
||||
% 0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0CFFC0001108001600200301220002
|
||||
% 1101031101FFDD00040002FFC4013F0000010501010101010100000000000000
|
||||
% 030001020405060708090A0B0100010501010101010100000000000000010002
|
||||
% 030405060708090A0B1000010401030204020507060805030C33010002110304
|
||||
% 211231054151611322718132061491A1B14223241552C16233347282D1430725
|
||||
% 9253F0E1F163733516A2B283264493546445C2A3743617D255E265F2B384C3D3
|
||||
% 75E3F3462794A485B495C4D4E4F4A5B5C5D5E5F55666768696A6B6C6D6E6F637
|
||||
% 475767778797A7B7C7D7E7F71100020201020404030405060707060535010002
|
||||
% 1103213112044151617122130532819114A1B14223C152D1F0332462E1728292
|
||||
% 435315637334F1250616A2B283072635C2D2449354A317644555367465E2F2B3
|
||||
% 84C3D375E3F34694A485B495C4D4E4F4A5B5C5D5E5F55666768696A6B6C6D6E6
|
||||
% F62737475767778797A7B7C7FFDA000C03010002110311003F00C0E9FD3F01F8
|
||||
% 18CF7E354E73AA61738B1A4925AD924ED5DF7D48FAB9F57B2BA55B664F4BC3BD
|
||||
% E321CD0EB28ADE40D951DBB9EC3E2B88E9BFF2762FFC4D7FF52D5D5626366E5F
|
||||
% D4DCBC6C663ACAECC87FACDAC6E798AE934D6DAFD3BFD8EBB66F7B2B7FFA2FD1
|
||||
% 5175F9B8791CAE490E625649AE3D2DC3E42723CE484A4787D7B9B5FF00C62743
|
||||
% FABD8FF57F1B27A7F4FC3A4DB92C8BA8A6A6EE63ABB9FA59533DD5BBDAE5E6B9
|
||||
% 38D8EDC7B48A9808638821A2661779D7FA6E574BFA974E1DDEA1ADB9ED7566D9
|
||||
% 6B8175377AF5328F7FA74D776ED967ABFACD9EB5FF00CCBEABAFE1F2BFA2DDFD
|
||||
% 477E42AD649C8E489D4588E8FA0FC371E33C84CF0C654725488ECFFFD0C0E9F9
|
||||
% 37370319A312D7015300703541F6B7DC375CD72EFBEA4754CDABA55ADAFA4666
|
||||
% 40390E3BEB7E2000ECABDBFA7CEA5FFF0045785A4B2F94E1FBC9AE1FD2DB8EFF
|
||||
% 00E738BC8F0FDEE55C37EBF97DCE2FF9DE97DABFC64752CCBFA1D0CB7A565E2B
|
||||
% 465308B2D7629693E9DFECFD5B3721FBBFB0BCCF26D79C7B41A5E0163B525903
|
||||
% 4F2B160A4ACE6AF746DD3F79EEFE1BC7F709571D7EB3E5F6B87FE7FADFFFD900
|
||||
% 3842494D03FD000000000006010000000000
|
||||
%EndPhotoshop
|
||||
gsave % EPS gsave
|
||||
/hascolor
|
||||
/deviceinfo where
|
||||
{pop deviceinfo /Colors known
|
||||
{deviceinfo /Colors get exec 1 gt}
|
||||
{false} ifelse}
|
||||
{/statusdict where
|
||||
{pop statusdict /processcolors known
|
||||
{statusdict /processcolors get exec 1 gt}
|
||||
{false} ifelse}
|
||||
{false} ifelse}
|
||||
ifelse
|
||||
def
|
||||
40 dict begin
|
||||
/_image systemdict /image get def
|
||||
/_setgray systemdict /setgray get def
|
||||
/_currentgray systemdict /currentgray get def
|
||||
/_settransfer systemdict /settransfer get def
|
||||
/_currenttransfer systemdict /currenttransfer get def
|
||||
/blank 0 _currenttransfer exec
|
||||
1 _currenttransfer exec eq def
|
||||
/negative blank
|
||||
{0 _currenttransfer exec 0.5 lt}
|
||||
{0 _currenttransfer exec 1 _currenttransfer exec gt}
|
||||
ifelse def
|
||||
/inverted? negative def
|
||||
/level2 systemdict /languagelevel known
|
||||
{languagelevel 2 ge} {false} ifelse def
|
||||
/level3 systemdict /languagelevel known
|
||||
{languagelevel 3 ge} {false} ifelse def
|
||||
/foureq {4 index eq 8 1 roll
|
||||
4 index eq 8 1 roll
|
||||
4 index eq 8 1 roll
|
||||
4 index eq 8 1 roll
|
||||
pop pop pop pop and and and} def
|
||||
hascolor {/band 0 def} {/band 5 def} ifelse
|
||||
/setcmykcolor where {pop
|
||||
1 0 0 0 setcmykcolor _currentgray 1 exch sub
|
||||
0 1 0 0 setcmykcolor _currentgray 1 exch sub
|
||||
0 0 1 0 setcmykcolor _currentgray 1 exch sub
|
||||
0 0 0 1 setcmykcolor _currentgray 1 exch sub
|
||||
4 {4 copy} repeat
|
||||
1 0 0 0 foureq {/band 1 store} if
|
||||
0 1 0 0 foureq {/band 2 store} if
|
||||
0 0 1 0 foureq {/band 3 store} if
|
||||
0 0 0 1 foureq {/band 4 store} if
|
||||
0 0 0 0 foureq {/band 6 store} if} if
|
||||
blank {/band 6 store} if
|
||||
gsave % Image Header gsave
|
||||
/rows 22 def
|
||||
/cols 32 def
|
||||
32 22 scale
|
||||
level2 {
|
||||
band 0 eq {
|
||||
/DeviceRGB
|
||||
} {/DeviceGray} ifelse
|
||||
setcolorspace currentdict /PhotoshopDuotoneColorSpace undef currentdict /PhotoshopDuotoneAltColorSpace undef } if
|
||||
/picstr1 32 string def
|
||||
/picstr2 32 string def
|
||||
/picstr3 32 string def
|
||||
/picstr4 32 string def
|
||||
/readdata {currentfile exch readhexstring pop} def
|
||||
/image2 level2 {/image load def} {{begin
|
||||
Width Height BitsPerComponent ImageMatrix
|
||||
Decode length 2 eq
|
||||
{/DataSource load image} if
|
||||
Decode length 6 eq
|
||||
{DataSource 0 get DataSource 1 get DataSource 2 get
|
||||
true 3 colorimage} if
|
||||
Decode length 8 eq
|
||||
{DataSource 0 get DataSource 1 get
|
||||
DataSource 2 get DataSource 3 get
|
||||
true 4 colorimage} if
|
||||
end} def} ifelse
|
||||
/_image2 level2 {/_image load def} {{begin
|
||||
Width Height BitsPerComponent ImageMatrix
|
||||
/DataSource load _image end} def} ifelse
|
||||
/beginimage {
|
||||
band 0 eq band 4 eq or band 5 eq or
|
||||
{image2}
|
||||
{negative {{pop 0}} {{pop 1}} ifelse
|
||||
_settransfer _image2} ifelse
|
||||
} def
|
||||
12 dict begin
|
||||
/ImageType 1 def
|
||||
/Width cols def
|
||||
/Height rows def
|
||||
/ImageMatrix [cols 0 0 rows neg 0 rows] def
|
||||
/BitsPerComponent 8 def
|
||||
band 0 eq
|
||||
{/Decode [0 1 0 1 0 1] def
|
||||
/MultipleDataSources true def
|
||||
/DataSource [
|
||||
{picstr1 readdata}
|
||||
{picstr2 readdata}
|
||||
{picstr3 readdata picstr4 readdata pop}
|
||||
] def}
|
||||
{/Decode [0 1] def
|
||||
/DataSource {
|
||||
picstr1 readdata pop
|
||||
picstr2 readdata pop
|
||||
picstr3 readdata pop
|
||||
picstr4 readdata
|
||||
} def}
|
||||
ifelse
|
||||
currentdict end
|
||||
%%BeginBinary: 5821
|
||||
beginimage
|
||||
0000000000000000000000000000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000000000000000000000000000
|
||||
0000000000000000000000FFFFFFFFFFFFFFFFFFFFC6C6C6C6C6C6C6C6C6C600
|
||||
00B5B5B5B5B5B5B5B5B5B5FFFFFFFFFFFFFFFFFFFF0000000000000000000000
|
||||
0000000000000000000000FFFFFFFFFFFFFFFFFFFF0000000000000000000000
|
||||
006B6B6B6B6B6B6B6B6B6BFFFFFFFFFFFFFFFFFFFF3B3B3B3B3B3B3B3B3B3B00
|
||||
0000000000000000000000FFFFFFFFFFFFFFFFFFFFC6C6C6C6C6C6C6C6C6C600
|
||||
00B5B5B5B5B5B5B5B5B5B5FFFFFFFFFFFFFFFFFFFF0000000000000000000000
|
||||
0000000000000000000000FFFFFFFFFFFFFFFFFFFF0000000000000000000000
|
||||
006B6B6B6B6B6B6B6B6B6BFFFFFFFFFFFFFFFFFFFF3B3B3B3B3B3B3B3B3B3B00
|
||||
0000000000000000000000FFFFFFFFFFFFFFFFFFFFC6C6C6C6C6C6C6C6C6C600
|
||||
00B5B5B5B5B5B5B5B5B5B5FFFFFFFFFFFFFFFFFFFF0000000000000000000000
|
||||
0000000000000000000000FFFFFFFFFFFFFFFFFFFF0000000000000000000000
|
||||
006B6B6B6B6B6B6B6B6B6BFFFFFFFFFFFFFFFFFFFF3B3B3B3B3B3B3B3B3B3B00
|
||||
0000000000000000000000FFFFFFFFFFFFFFFFFFFFC6C6C6C6C6C6C6C6C6C600
|
||||
00B5B5B5B5B5B5B5B5B5B5FFFFFFFFFFFFFFFFFFFF0000000000000000000000
|
||||
0000000000000000000000FFFFFFFFFFFFFFFFFFFF0000000000000000000000
|
||||
006B6B6B6B6B6B6B6B6B6BFFFFFFFFFFFFFFFFFFFF3B3B3B3B3B3B3B3B3B3B00
|
||||
0000000000000000000000FFFFFFFFFFFFFFFFFFFFC6C6C6C6C6C6C6C6C6C600
|
||||
00B5B5B5B5B5B5B5B5B5B5FFFFFFFFFFFFFFFFFFFF0000000000000000000000
|
||||
0000000000000000000000FFFFFFFFFFFFFFFFFFFF0000000000000000000000
|
||||
006B6B6B6B6B6B6B6B6B6BFFFFFFFFFFFFFFFFFFFF3B3B3B3B3B3B3B3B3B3B00
|
||||
0000000000000000000000FFFFFFFFFFFFFFFFFFFFC6C6C6C6C6C6C6C6C6C600
|
||||
00B5B5B5B5B5B5B5B5B5B5FFFFFFFFFFFFFFFFFFFF0000000000000000000000
|
||||
0000000000000000000000FFFFFFFFFFFFFFFFFFFF0000000000000000000000
|
||||
006B6B6B6B6B6B6B6B6B6BFFFFFFFFFFFFFFFFFFFF3B3B3B3B3B3B3B3B3B3B00
|
||||
0000000000000000000000FFFFFFFFFF94FFFFFFFFC6C6C6C6C6C6C6C6C6C600
|
||||
00B5B5B5B5B5B5B5B5B5B5FFFFFFFFFF42FFFFFFFF0000000000000000000000
|
||||
0000000000000000000000FFFFFFFFFF00FFFFFFFF0000000000000000000000
|
||||
006B6B6B6B6B6B6B6B6B6BFFFFFFFFFF53FFFFFFFF3B3B3B3B3B3B3B3B3B3B00
|
||||
0000000000000000000000FFFFFF6B427B5AFFFFFFC6C6C6C6C6C6C6C6C6C600
|
||||
00B5B5B5B5B5B5B5B5B5B5FFFFFF6B183929FFFFFF0000000000000000000000
|
||||
0000000000000000000000FFFFFF73000000FFFFFF0000000000000000000000
|
||||
006B6B6B6B6B6B6B6B6B6BFFFFFF6C224733FFFFFF3B3B3B3B3B3B3B3B3B3B00
|
||||
0000000000000000000000FFFFFF319C397B6BFFFFC6C6C6C6C6C6C6C6C6C600
|
||||
00B5B5B5B5B5B5B5B5B5B5FFFFFF9C42213931FFFF0000000000000000000000
|
||||
0000000000000000000000FFFFFF0000000000FFFF0000000000000000000000
|
||||
006B6B6B6B6B6B6B6B6B6BFFFFFF6B5625473DFFFF3B3B3B3B3B3B3B3B3B3B00
|
||||
0000000000000000000000FFFF8C6B39945A63FFFFC6C6C6C6C6C6C6C6C6C600
|
||||
00B5B5B5B5B5B5B5B5B5B5FFFF8431184A2931FFFF0000000000000000000000
|
||||
0000000000000000000000FFFF840000001010FFFF0000000000000000000000
|
||||
006B6B6B6B6B6B6B6B6B6BFFFF863D1F58353CFFFF3B3B3B3B3B3B3B3B3B3B00
|
||||
0000000000000000000000FFFF00FF94637B94FFFFC6C6C6C6C6C6C6C6C6C600
|
||||
00B5B5B5B5B5B5B5B5B5B5FFFF5AFF4A294A94FFFF0000000000000000000000
|
||||
0000000000000000000000FFFF10FF00000094FFFF0000000000000000000000
|
||||
006B6B6B6B6B6B6B6B6B6BFFFF37FF58365194FFFF3B3B3B3B3B3B3B3B3B3B00
|
||||
0000000000000000000000FF21FF1810EFEFB518FFC6C6C6C6C6C6C6C6C6C600
|
||||
00B5B5B5B5B5B5B5B5B5B5FF73FF6B7B9CEFAD84FF0000000000000000000000
|
||||
0000000000000000000000FF00FF000800EFA500FF0000000000000000000000
|
||||
006B6B6B6B6B6B6B6B6B6BFF4EFF464EA4EFAF55FF3B3B3B3B3B3B3B3B3B3B00
|
||||
0000000000000000000000FFFF21FF9494FF21FFFFC6C6C6C6C6C6C6C6C6C600
|
||||
00B5B5B5B5B5B5B5B5B5B5FFFF73FF4242FF63FFFF0000000000000000000000
|
||||
0000000000000000000000FFFF00FF0000FF00FFFF0000000000000000000000
|
||||
006B6B6B6B6B6B6B6B6B6BFFFF4EFF5353FF44FFFF3B3B3B3B3B3B3B3B3B3B00
|
||||
0000000000000000000000FFFFFF2121D621FFFFFFC6C6C6C6C6C6C6C6C6C600
|
||||
00B5B5B5B5B5B5B5B5B5B5FFFFFF6373DE63FFFFFF0000000000000000000000
|
||||
0000000000000000000000FFFFFF0000CE00FFFFFF0000000000000000000000
|
||||
006B6B6B6B6B6B6B6B6B6BFFFFFF444EDA44FFFFFF3B3B3B3B3B3B3B3B3B3B00
|
||||
0000000000000000000000FFFFFFFFFFFFFFFFFFFFC6C6C6C6C6C6C6C6C6C600
|
||||
00B5B5B5B5B5B5B5B5B5B5FFFFFFFFFFFFFFFFFFFF0000000000000000000000
|
||||
0000000000000000000000FFFFFFFFFFFFFFFFFFFF0000000000000000000000
|
||||
006B6B6B6B6B6B6B6B6B6BFFFFFFFFFFFFFFFFFFFF3B3B3B3B3B3B3B3B3B3B00
|
||||
0000000000000000000000FFFFFFFFFFFFFFFFFFFFC6C6C6C6C6C6C6C6C6C600
|
||||
00B5B5B5B5B5B5B5B5B5B5FFFFFFFFFFFFFFFFFFFF0000000000000000000000
|
||||
0000000000000000000000FFFFFFFFFFFFFFFFFFFF0000000000000000000000
|
||||
006B6B6B6B6B6B6B6B6B6BFFFFFFFFFFFFFFFFFFFF3B3B3B3B3B3B3B3B3B3B00
|
||||
0000000000000000000000FFFFFFFFFFFFFFFFFFFFC6C6C6C6C6C6C6C6C6C600
|
||||
00B5B5B5B5B5B5B5B5B5B5FFFFFFFFFFFFFFFFFFFF0000000000000000000000
|
||||
0000000000000000000000FFFFFFFFFFFFFFFFFFFF0000000000000000000000
|
||||
006B6B6B6B6B6B6B6B6B6BFFFFFFFFFFFFFFFFFFFF3B3B3B3B3B3B3B3B3B3B00
|
||||
0000000000000000000000FFFFFFFFFFFFFFFFFFFFC6C6C6C6C6C6C6C6C6C600
|
||||
00B5B5B5B5B5B5B5B5B5B5FFFFFFFFFFFFFFFFFFFF0000000000000000000000
|
||||
0000000000000000000000FFFFFFFFFFFFFFFFFFFF0000000000000000000000
|
||||
006B6B6B6B6B6B6B6B6B6BFFFFFFFFFFFFFFFFFFFF3B3B3B3B3B3B3B3B3B3B00
|
||||
0000000000000000000000FFFFFFFFFFFFFFFFFFFFC6C6C6C6C6C6C6C6C6C600
|
||||
00B5B5B5B5B5B5B5B5B5B5FFFFFFFFFFFFFFFFFFFF0000000000000000000000
|
||||
0000000000000000000000FFFFFFFFFFFFFFFFFFFF0000000000000000000000
|
||||
006B6B6B6B6B6B6B6B6B6BFFFFFFFFFFFFFFFFFFFF3B3B3B3B3B3B3B3B3B3B00
|
||||
0000000000000000000000FFFFFFFFFFFFFFFFFFFFC6C6C6C6C6C6C6C6C6C600
|
||||
00B5B5B5B5B5B5B5B5B5B5FFFFFFFFFFFFFFFFFFFF0000000000000000000000
|
||||
0000000000000000000000FFFFFFFFFFFFFFFFFFFF0000000000000000000000
|
||||
006B6B6B6B6B6B6B6B6B6BFFFFFFFFFFFFFFFFFFFF3B3B3B3B3B3B3B3B3B3B00
|
||||
0000000000000000000000000000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000000000000000000000000000
|
||||
|
||||
%%EndBinary
|
||||
grestore end % Image Trailer grestore
|
||||
grestore % EPS grestore
|
BIN
Docs/Flags/mexico.gif
Normal file
After Width: | Height: | Size: 269 B |
0
Docs/Flags/mexico.txt
Normal file
BIN
Docs/Flags/philippines.eps
Executable file → Normal file
0
Docs/Flags/philippines.gif
Executable file → Normal file
Before Width: | Height: | Size: 306 B After Width: | Height: | Size: 306 B |
0
Docs/Flags/turkey.gif
Executable file → Normal file
Before Width: | Height: | Size: 169 B After Width: | Height: | Size: 169 B |
|
@ -3187,7 +3187,7 @@ encounter per year, but we are as always very flexible towards our customers!
|
|||
@c @image{Flags/estonia} Estonia [Tradenet] @
|
||||
@c @uref{http://mysql.tradenet.ee, WWW}
|
||||
@item
|
||||
@c EMAIL: tonu@spamm.ee (Tonu Samuel)
|
||||
@c EMAIL: tonu@spam.ee (Tonu Samuel)
|
||||
@image{Flags/estonia} Estonia [OKinteractive] @
|
||||
@uref{http://mysql.mirror.ok.ee, WWW}
|
||||
@item
|
||||
|
|
2120
Docs/manual.texi
88
acinclude.m4
|
@ -663,7 +663,7 @@ if test "$cpu_vendor" = "AuthenticAMD"; then
|
|||
fi
|
||||
elif test "$cpu_vendor" = "GenuineIntel"; then
|
||||
if test $cpu_family>=6; then
|
||||
cpu_set=" pentiumpro pentium i486 i386";
|
||||
cpu_set="pentiumpro pentium i486 i386";
|
||||
elif test $cpu_family=5; then
|
||||
cpu_set="pentium i486 i386";
|
||||
elif test $cpu_family=4; then
|
||||
|
@ -682,16 +682,15 @@ done
|
|||
if test "$mysql_cv_cpu" = "unknown"
|
||||
then
|
||||
CFLAGS="$ac_save_CFLAGS"
|
||||
AC_MSG_RESULT(none)
|
||||
AC_MSG_RESULT(none)
|
||||
else
|
||||
AC_MSG_RESULT($mysql_cv_cpu)
|
||||
AC_MSG_RESULT($mysql_cv_cpu)
|
||||
fi
|
||||
]))
|
||||
|
||||
AC_DEFUN(MYSQL_CHECK_VIO, [
|
||||
AC_ARG_WITH([vio],
|
||||
[\
|
||||
--with-vio Include the Virtual IO support],
|
||||
[ --with-vio Include the Virtual IO support],
|
||||
[vio="$withval"],
|
||||
[vio=no])
|
||||
|
||||
|
@ -708,30 +707,55 @@ AC_DEFUN(MYSQL_CHECK_VIO, [
|
|||
AC_SUBST([vio_libs])
|
||||
])
|
||||
|
||||
AC_DEFUN(MYSQL_FIND_OPENSSL, [
|
||||
for d in /usr/ssl/include /usr/local/ssl/include /usr/include/openssl \
|
||||
/usr/include/ssl /opt/ssl/include /opt/openssl/include ; do
|
||||
if test -f $d/ssl.h ; then
|
||||
OPENSSL_INCLUDE=$d
|
||||
fi
|
||||
done
|
||||
|
||||
for d in /usr/ssl/lib /usr/local/ssl/lib /usr/lib/openssl \
|
||||
/usr/lib /opt/ssl/lib /opt/openssl/lib ; do
|
||||
if test -f $d/libssl.a ; then
|
||||
OPENSSL_LIB=$d
|
||||
fi
|
||||
done
|
||||
|
||||
if test -z "$OPENSSL_LIB" -o -z "$OPENSSL_INCLUDE" ; then
|
||||
echo "Could not find an installation of OpenSSL"
|
||||
if test -n "$OPENSSL_LIB" ; then
|
||||
if test "$IS_LINUX" = "true"; then
|
||||
echo "Looks like you've forgotted to install OpenSSL development RPM"
|
||||
fi
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
||||
])
|
||||
|
||||
AC_DEFUN(MYSQL_CHECK_OPENSSL, [
|
||||
AC_MSG_CHECKING(for OpenSSL)
|
||||
AC_ARG_WITH([openssl],
|
||||
[\
|
||||
--with-openssl Include the OpenSSL support],
|
||||
[ --with-openssl Include the OpenSSL support],
|
||||
[openssl="$withval"],
|
||||
[openssl=no])
|
||||
|
||||
openssl_libs=""
|
||||
openssl_includes=""
|
||||
if test "$openssl" = "yes"
|
||||
then
|
||||
if test -n "$vio_dir"
|
||||
then
|
||||
AC_MSG_RESULT(yes)
|
||||
openssl_libs="-lssl -lcrypto -L/usr/local/ssl/lib"
|
||||
openssl_includes="-I/usr/local/ssl/include"
|
||||
else
|
||||
AC_MSG_ERROR([OpenSSL requires Virtual IO support (--with-vio)])
|
||||
fi
|
||||
MYSQL_FIND_OPENSSL
|
||||
#force VIO use
|
||||
vio_dir="vio"
|
||||
vio_libs="../vio/libvio.la"
|
||||
AC_DEFINE(HAVE_VIO)
|
||||
AC_MSG_RESULT(yes)
|
||||
openssl_libs="-L$OPENSSL_LIB -lssl -lcrypto"
|
||||
openssl_includes="-I$OPENSSL_INCLUDE"
|
||||
AC_DEFINE(HAVE_OPENSSL)
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
openssl_libs=""
|
||||
openssl_includes=""
|
||||
fi
|
||||
NON_THREADED_CLIENT_LIBS="$NON_THREADED_CLIENT_LIBS $openssl_libs"
|
||||
AC_SUBST(openssl_libs)
|
||||
|
@ -750,23 +774,27 @@ dnl Call MYSQL_CHECK_ORBIT even if mysqlfs == no, so that @orbit_*@
|
|||
dnl get substituted.
|
||||
MYSQL_CHECK_ORBIT
|
||||
|
||||
AC_MSG_CHECKING(if we should build MySQLFS)
|
||||
fs_dirs=""
|
||||
if test "$mysqlfs" = "yes"
|
||||
then
|
||||
if test -n "$orbit_exec_prefix"
|
||||
then
|
||||
fs_dirs=fs
|
||||
AC_MSG_RESULT([yes])
|
||||
else
|
||||
AC_MSG_ERROR([mysqlfs requires ORBit, the CORBA ORB])
|
||||
AC_MSG_RESULT(disabled because ORBIT, the CORBA ORB, was not found)
|
||||
fi
|
||||
else
|
||||
fs_dirs=
|
||||
AC_MSG_RESULT([no])
|
||||
fi
|
||||
AC_SUBST([fs_dirs])
|
||||
])
|
||||
|
||||
AC_DEFUN(MYSQL_CHECK_ORBIT, [
|
||||
AC_MSG_CHECKING(for ORBit)
|
||||
if test `which orbit-config`
|
||||
orbit_config_path=`which orbit-config`
|
||||
if test -n "$orbit_config_path"
|
||||
then
|
||||
orbit_exec_prefix=`orbit-config --exec-prefix`
|
||||
orbit_includes=`orbit-config --cflags server`
|
||||
|
@ -852,6 +880,7 @@ dnl echo "DBG2: [$mode] bdb='$bdb'; incl='$bdb_includes'; lib='$bdb_libs'"
|
|||
no )
|
||||
bdb_includes=
|
||||
bdb_libs=
|
||||
bdb_libs_with_path=
|
||||
;;
|
||||
supplied-two )
|
||||
MYSQL_CHECK_INSTALLED_BDB([$bdb_includes], [$bdb_libs])
|
||||
|
@ -881,6 +910,7 @@ dnl echo "DBG2: [$mode] bdb='$bdb'; incl='$bdb_includes'; lib='$bdb_libs'"
|
|||
esac
|
||||
bdb_includes=
|
||||
bdb_libs=
|
||||
bdb_libs_with_path=
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
|
@ -909,6 +939,7 @@ dnl echo "DBG3: [$mode] bdb='$bdb'; incl='$bdb_includes'; lib='$bdb_libs'"
|
|||
|
||||
AC_SUBST(bdb_includes)
|
||||
AC_SUBST(bdb_libs)
|
||||
AC_SUBST(bdb_libs_with_path)
|
||||
])
|
||||
|
||||
AC_DEFUN([MYSQL_CHECK_INSTALLED_BDB], [
|
||||
|
@ -929,6 +960,7 @@ dnl echo ["MYSQL_CHECK_INSTALLED_BDB ($1) ($2)"]
|
|||
MYSQL_TOP_BUILDDIR([lib])
|
||||
bdb_includes="-I$inc"
|
||||
bdb_libs="-L$lib -ldb"
|
||||
bdb_libs_with_path="$lib/libdb.a"
|
||||
])
|
||||
LDFLAGS="$save_LDFLAGS"
|
||||
else
|
||||
|
@ -957,6 +989,7 @@ dnl echo ["MYSQL_CHECK_BDB_DIR ($1)"]
|
|||
MYSQL_TOP_BUILDDIR([dir])
|
||||
bdb_includes="-I$dir/build_unix"
|
||||
bdb_libs="-L$dir/build_unix -ldb"
|
||||
bdb_libs_with_path="$dir/build_unix/libdb.a"
|
||||
else
|
||||
bdb_dir_ok="$bdb_version_ok"
|
||||
fi
|
||||
|
@ -1053,9 +1086,9 @@ dnl ---------------------------------------------------------------------------
|
|||
AC_DEFUN([MYSQL_CHECK_INNODB], [
|
||||
AC_ARG_WITH([innodb],
|
||||
[\
|
||||
--with-innodb Use Innodb],
|
||||
--without-innodb Do not include the InnoDB table handler],
|
||||
[innodb="$withval"],
|
||||
[innodb=no])
|
||||
[innodb=yes])
|
||||
|
||||
AC_MSG_CHECKING([for Innodb])
|
||||
|
||||
|
@ -1068,6 +1101,7 @@ AC_DEFUN([MYSQL_CHECK_INNODB], [
|
|||
AC_DEFINE(HAVE_INNOBASE_DB)
|
||||
have_innodb="yes"
|
||||
innodb_includes="-I../innobase/include"
|
||||
innodb_system_libs=""
|
||||
dnl Some libs are listed several times, in order for gcc to sort out
|
||||
dnl circular references.
|
||||
innodb_libs="\
|
||||
|
@ -1108,7 +1142,7 @@ dnl circular references.
|
|||
\$(top_builddir)/innobase/os/libos.a\
|
||||
\$(top_builddir)/innobase/ut/libut.a"
|
||||
|
||||
AC_CHECK_LIB(rt, aio_read, [innodb_libs="$innodb_libs -lrt"])
|
||||
AC_CHECK_LIB(rt, aio_read, [innodb_system_libs="-lrt"])
|
||||
;;
|
||||
* )
|
||||
AC_MSG_RESULT([Not using Innodb])
|
||||
|
@ -1117,6 +1151,7 @@ dnl circular references.
|
|||
|
||||
AC_SUBST(innodb_includes)
|
||||
AC_SUBST(innodb_libs)
|
||||
AC_SUBST(innodb_system_libs)
|
||||
])
|
||||
|
||||
dnl ---------------------------------------------------------------------------
|
||||
|
@ -1131,7 +1166,7 @@ dnl ---------------------------------------------------------------------------
|
|||
AC_DEFUN([MYSQL_CHECK_GEMINI], [
|
||||
AC_ARG_WITH([gemini],
|
||||
[\
|
||||
--with-gemini[=DIR] Use Gemini DB located in DIR],
|
||||
--with-gemini[=DIR] Use Gemini DB located in DIR],
|
||||
[gemini="$withval"],
|
||||
[gemini=no])
|
||||
|
||||
|
@ -1152,8 +1187,7 @@ dnl echo "DBG_GEM1: gemini='$gemini'"
|
|||
gemini_libs="\
|
||||
../gemini/api/libapi.a\
|
||||
../gemini/db/libdb.a\
|
||||
../gemini/dbut/libdbut.a\
|
||||
../gemini/vst/libvst.a"
|
||||
../gemini/dbut/libdbut.a"
|
||||
AC_MSG_RESULT([Using Gemini DB])
|
||||
;;
|
||||
esac
|
||||
|
@ -1251,7 +1285,7 @@ changequote([, ])dnl
|
|||
AC_DEFUN(AC_SYS_LARGEFILE,
|
||||
[AC_REQUIRE([AC_CANONICAL_HOST])
|
||||
AC_ARG_ENABLE(largefile,
|
||||
[ --disable-large-files Omit support for large files])
|
||||
[ --disable-largefile Omit support for large files])
|
||||
if test "$enable_largefile" != no; then
|
||||
AC_CHECK_TOOL(GETCONF, getconf)
|
||||
AC_SYS_LARGEFILE_FLAGS(CFLAGS)
|
||||
|
|
|
@ -19,13 +19,13 @@
|
|||
INCLUDES = -I$(srcdir)/../include $(openssl_includes) \
|
||||
-I../include -I$(srcdir)/.. -I$(top_srcdir) \
|
||||
-I..
|
||||
noinst_HEADERS = client_priv.h
|
||||
LIBS = @CLIENT_LIBS@
|
||||
LDADD = @CLIENT_EXTRA_LDFLAGS@ ../libmysql/libmysqlclient.la
|
||||
bin_PROGRAMS = mysql mysqladmin mysqlcheck mysqlshow \
|
||||
mysqldump mysqlimport mysqltest mysqlbinlog
|
||||
mysqldump mysqlimport mysqltest mysqlbinlog mysqlmanagerc mysqlmanager-pwgen
|
||||
noinst_PROGRAMS = insert_test select_test thread_test
|
||||
noinst_HEADERS = sql_string.h completion_hash.h my_readline.h
|
||||
noinst_HEADERS = sql_string.h completion_hash.h my_readline.h \
|
||||
client_priv.h
|
||||
mysql_SOURCES = mysql.cc readline.cc sql_string.cc completion_hash.cc
|
||||
mysql_LDADD = @readline_link@ @TERMCAP_LIB@ $(LDADD) $(CXXLDFLAGS)
|
||||
mysql_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
|
||||
|
@ -36,14 +36,16 @@ mysqldump_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
|
|||
mysqlimport_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
|
||||
insert_test_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
|
||||
select_test_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
|
||||
mysqltest_SOURCES= mysqltest.c
|
||||
mysqltest_SOURCES= mysqltest.c
|
||||
mysqltest_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
|
||||
mysqlbinlog_SOURCES = mysqlbinlog.cc
|
||||
mysqlbinlog_SOURCES = mysqlbinlog.cc
|
||||
mysqlbinlog_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
|
||||
sql_src= log_event.h log_event.cc
|
||||
mysqlmanagerc_SOURCES = mysqlmanagerc.c
|
||||
mysqlmanagerc_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
|
||||
sql_src=log_event.h log_event.cc
|
||||
|
||||
# Fix for mit-threads
|
||||
DEFS= -DUNDEF_THREADS_HACK
|
||||
DEFS = -DUNDEF_THREADS_HACK
|
||||
|
||||
link_sources:
|
||||
for f in $(sql_src) ; do \
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include <my_global.h>
|
||||
#include <my_sys.h>
|
||||
#include <m_string.h>
|
||||
#include <mysql_embed.h>
|
||||
#include <mysql.h>
|
||||
#include <errmsg.h>
|
||||
#include <getopt.h>
|
||||
|
|
|
@ -47,10 +47,12 @@ int completion_hash_init(HashTable *ht, uint nSize)
|
|||
ht->arBuckets = (Bucket **) my_malloc(nSize* sizeof(Bucket *),
|
||||
MYF(MY_ZEROFILL | MY_WME));
|
||||
|
||||
if (!ht->arBuckets) {
|
||||
if (!ht->arBuckets)
|
||||
{
|
||||
ht->initialized = 0;
|
||||
return FAILURE;
|
||||
}
|
||||
init_alloc_root(&ht->mem_root, 8192, 0);
|
||||
ht->pHashFunction = hashpjw;
|
||||
ht->nTableSize = nSize;
|
||||
ht->initialized = 1;
|
||||
|
@ -78,8 +80,7 @@ int completion_hash_update(HashTable *ht, char *arKey, uint nKeyLength,
|
|||
if (!memcmp(p->arKey, arKey, nKeyLength)) {
|
||||
entry *n;
|
||||
|
||||
n = (entry *) my_malloc(sizeof(entry),
|
||||
MYF(MY_WME));
|
||||
n = (entry *) alloc_root(&ht->mem_root,sizeof(entry));
|
||||
n->pNext = p->pData;
|
||||
n->str = str;
|
||||
p->pData = n;
|
||||
|
@ -91,20 +92,16 @@ int completion_hash_update(HashTable *ht, char *arKey, uint nKeyLength,
|
|||
p = p->pNext;
|
||||
}
|
||||
|
||||
p = (Bucket *) my_malloc(sizeof(Bucket),MYF(MY_WME));
|
||||
|
||||
if (!p) {
|
||||
if (!(p = (Bucket *) alloc_root(&ht->mem_root, sizeof(Bucket))))
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
p->arKey = arKey;
|
||||
p->nKeyLength = nKeyLength;
|
||||
p->h = h;
|
||||
|
||||
p->pData = (entry*) my_malloc(sizeof(entry),MYF(MY_WME));
|
||||
if (!p->pData) {
|
||||
my_free((gptr) p,MYF(0));
|
||||
if (!(p->pData = (entry*) alloc_root(&ht->mem_root, sizeof(entry))))
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
p->pData->str = str;
|
||||
p->pData->pNext = 0;
|
||||
p->count = 1;
|
||||
|
@ -209,24 +206,7 @@ Bucket *find_longest_match(HashTable *ht, char *str, uint length,
|
|||
|
||||
void completion_hash_clean(HashTable *ht)
|
||||
{
|
||||
uint i;
|
||||
entry *e, *t;
|
||||
Bucket *b, *tmp;
|
||||
|
||||
for (i=0; i<ht->nTableSize; i++) {
|
||||
b = ht->arBuckets[i];
|
||||
while (b) {
|
||||
e = b->pData;
|
||||
while (e) {
|
||||
t = e;
|
||||
e = e->pNext;
|
||||
my_free((gptr) t,MYF(0));
|
||||
}
|
||||
tmp = b;
|
||||
b = b->pNext;
|
||||
my_free((gptr) tmp,MYF(0));
|
||||
}
|
||||
}
|
||||
free_root(&ht->mem_root,MYF(0));
|
||||
bzero((char*) ht->arBuckets,ht->nTableSize*sizeof(Bucket *));
|
||||
}
|
||||
|
||||
|
@ -241,9 +221,7 @@ void completion_hash_free(HashTable *ht)
|
|||
void add_word(HashTable *ht,char *str)
|
||||
{
|
||||
int i;
|
||||
int length= (int) strlen(str);
|
||||
|
||||
for (i=1; i<=length; i++) {
|
||||
char *pos=str;
|
||||
for (i=1; *pos; i++, pos++)
|
||||
completion_hash_update(ht, str, i, str);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,26 +22,29 @@
|
|||
#define FAILURE 1
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <my_sys.h>
|
||||
|
||||
typedef struct _entry {
|
||||
char *str;
|
||||
struct _entry *pNext;
|
||||
} entry;
|
||||
|
||||
typedef struct bucket {
|
||||
uint h; /* Used for numeric indexing */
|
||||
char *arKey;
|
||||
uint nKeyLength;
|
||||
uint count;
|
||||
entry *pData;
|
||||
struct bucket *pNext;
|
||||
typedef struct bucket
|
||||
{
|
||||
uint h; /* Used for numeric indexing */
|
||||
char *arKey;
|
||||
uint nKeyLength;
|
||||
uint count;
|
||||
entry *pData;
|
||||
struct bucket *pNext;
|
||||
} Bucket;
|
||||
|
||||
typedef struct hashtable {
|
||||
uint nTableSize;
|
||||
uint initialized;
|
||||
uint(*pHashFunction) (char *arKey, uint nKeyLength);
|
||||
Bucket **arBuckets;
|
||||
uint nTableSize;
|
||||
uint initialized;
|
||||
MEM_ROOT mem_root;
|
||||
uint(*pHashFunction) (char *arKey, uint nKeyLength);
|
||||
Bucket **arBuckets;
|
||||
} HashTable;
|
||||
|
||||
extern int completion_hash_init(HashTable *ht, uint nSize);
|
||||
|
@ -54,4 +57,4 @@ extern void completion_hash_clean(HashTable *ht);
|
|||
extern int completion_hash_exists(HashTable *ht, char *arKey, uint nKeyLength);
|
||||
extern void completion_hash_free(HashTable *ht);
|
||||
|
||||
#endif /* _HASH_ */
|
||||
#endif /* _HASH_ */
|
||||
|
|
119
client/mysql.cc
|
@ -24,6 +24,7 @@
|
|||
* Jani Tolonen <jani@mysql.com>
|
||||
* Matt Wagner <mwagner@mysql.com>
|
||||
* Jeremy Cole <jcole@mysql.com>
|
||||
* Tonu Samuel <tonu@mysql.com>
|
||||
*
|
||||
**/
|
||||
|
||||
|
@ -74,7 +75,6 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
#undef bcmp // Fix problem with new readline
|
||||
#undef bzero
|
||||
#if defined( __WIN__) || defined(OS2)
|
||||
#include <conio.h>
|
||||
#else
|
||||
|
@ -137,6 +137,7 @@ static const char *xmlmeta[] = {
|
|||
static char default_pager[FN_REFLEN];
|
||||
char pager[FN_REFLEN], outfile[FN_REFLEN];
|
||||
FILE *PAGER, *OUTFILE;
|
||||
MEM_ROOT hash_mem_root;
|
||||
|
||||
#include "sslopt-vars.h"
|
||||
|
||||
|
@ -243,7 +244,8 @@ static COMMANDS commands[] = {
|
|||
};
|
||||
|
||||
static const char *load_default_groups[]= { "mysql","client",0 };
|
||||
static const char *server_default_groups[]= { "server", "mysql_SERVER", 0 };
|
||||
static const char *server_default_groups[]=
|
||||
{ "server", "embedded", "mysql_SERVER", 0 };
|
||||
|
||||
#ifdef HAVE_READLINE
|
||||
extern "C" void add_history(char *command); /* From readline directory */
|
||||
|
@ -271,7 +273,6 @@ int main(int argc,char *argv[])
|
|||
{
|
||||
char buff[80];
|
||||
|
||||
mysql_server_init(0, NULL, server_default_groups);
|
||||
MY_INIT(argv[0]);
|
||||
DBUG_ENTER("main");
|
||||
DBUG_PROCESS(argv[0]);
|
||||
|
@ -302,7 +303,10 @@ int main(int argc,char *argv[])
|
|||
!(status.line_buff=batch_readline_init(max_allowed_packet+512,stdin)))
|
||||
exit(1);
|
||||
glob_buffer.realloc(512);
|
||||
completion_hash_init(&ht,50);
|
||||
mysql_server_init(0, NULL, (char**) server_default_groups);
|
||||
completion_hash_init(&ht, 128);
|
||||
init_alloc_root(&hash_mem_root, 16384, 0);
|
||||
bzero((char*) &mysql, sizeof(mysql));
|
||||
if (sql_connect(current_host,current_db,current_user,opt_password,
|
||||
opt_silent))
|
||||
{
|
||||
|
@ -326,11 +330,13 @@ int main(int argc,char *argv[])
|
|||
put_info((char*) glob_buffer.ptr(),INFO_INFO);
|
||||
|
||||
#ifdef HAVE_OPENSSL
|
||||
if(mysql.net.vio->ssl_ && SSL_get_cipher(mysql.net.vio->ssl_)) {
|
||||
if (mysql.net.vio->ssl_ && SSL_get_cipher(mysql.net.vio->ssl_))
|
||||
{
|
||||
sprintf((char*) glob_buffer.ptr(),
|
||||
"SSL cipher in use is %s\n", SSL_get_cipher(mysql.net.vio->ssl_));
|
||||
"SSL cipher in use is %s\n", SSL_get_cipher(mysql.net.vio->ssl_));
|
||||
put_info((char*) glob_buffer.ptr(),INFO_INFO);
|
||||
} else
|
||||
}
|
||||
else
|
||||
put_info("SSL is not in use\n",INFO_INFO);
|
||||
#endif /* HAVE_OPENSSL */
|
||||
|
||||
|
@ -365,7 +371,6 @@ int main(int argc,char *argv[])
|
|||
if (opt_outfile)
|
||||
end_tee();
|
||||
mysql_end(0);
|
||||
mysql_server_end();
|
||||
#ifndef _lint
|
||||
DBUG_RETURN(0); // Keep compiler happy
|
||||
#endif
|
||||
|
@ -373,13 +378,7 @@ int main(int argc,char *argv[])
|
|||
|
||||
sig_handler mysql_end(int sig)
|
||||
{
|
||||
if (connected)
|
||||
mysql_close(&mysql);
|
||||
#ifdef HAVE_OPENSSL
|
||||
else
|
||||
mysql_ssl_clear(&mysql); /* SSL data structres should be freed
|
||||
even if connection was not made */
|
||||
#endif
|
||||
mysql_close(&mysql);
|
||||
#ifdef HAVE_READLINE
|
||||
if (!status.batch && !quick && !opt_html && !opt_xml)
|
||||
{
|
||||
|
@ -390,6 +389,8 @@ sig_handler mysql_end(int sig)
|
|||
}
|
||||
batch_readline_end(status.line_buff);
|
||||
completion_hash_free(&ht);
|
||||
free_root(&hash_mem_root,MYF(0));
|
||||
|
||||
#endif
|
||||
if (sig >= 0)
|
||||
put_info(sig ? "Aborted" : "Bye", INFO_RESULT);
|
||||
|
@ -401,6 +402,7 @@ sig_handler mysql_end(int sig)
|
|||
my_free(current_db,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(current_host,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(current_user,MYF(MY_ALLOW_ZERO_PTR));
|
||||
mysql_server_end();
|
||||
my_end(info_flag ? MY_CHECK_ERROR | MY_GIVE_INFO : 0);
|
||||
exit(status.exit_status);
|
||||
}
|
||||
|
@ -970,7 +972,7 @@ static bool add_line(String &buffer,char *line,char *in_string)
|
|||
{ // mSQL or postgreSQL style command ?
|
||||
if (!(inchar = (uchar) *++pos))
|
||||
break; // readline adds one '\'
|
||||
if (*in_string || inchar == 'N')
|
||||
if (*in_string || inchar == 'N') // \N is short for NULL
|
||||
{ // Don't allow commands in string
|
||||
*out++='\\';
|
||||
*out++= (char) inchar;
|
||||
|
@ -1172,7 +1174,8 @@ static char *new_command_generator(char *text,int state)
|
|||
static void build_completion_hash(bool skip_rehash,bool write_info)
|
||||
{
|
||||
COMMANDS *cmd=commands;
|
||||
static MYSQL_RES *databases=0,*tables=0,*fields;
|
||||
MYSQL_RES *databases=0,*tables=0;
|
||||
MYSQL_RES *fields;
|
||||
static char ***field_names= 0;
|
||||
MYSQL_ROW database_row,table_row;
|
||||
MYSQL_FIELD *sql_field;
|
||||
|
@ -1183,16 +1186,11 @@ static void build_completion_hash(bool skip_rehash,bool write_info)
|
|||
if (status.batch || quick || !current_db)
|
||||
DBUG_VOID_RETURN; // We don't need completion in batches
|
||||
|
||||
completion_hash_clean(&ht);
|
||||
if (tables)
|
||||
{
|
||||
mysql_free_result(tables);
|
||||
tables=0;
|
||||
}
|
||||
if (databases) {
|
||||
mysql_free_result(databases);
|
||||
databases=0;
|
||||
}
|
||||
|
||||
/* hash SQL commands */
|
||||
while (cmd->name) {
|
||||
|
@ -1202,16 +1200,28 @@ static void build_completion_hash(bool skip_rehash,bool write_info)
|
|||
if (skip_rehash)
|
||||
DBUG_VOID_RETURN;
|
||||
|
||||
/* Free old used memory */
|
||||
if (field_names)
|
||||
field_names=0;
|
||||
completion_hash_clean(&ht);
|
||||
free_root(&hash_mem_root,MYF(0));
|
||||
|
||||
/* hash MySQL functions (to be implemented) */
|
||||
|
||||
/* hash all database names */
|
||||
if (mysql_query(&mysql,"show databases")==0) {
|
||||
if (mysql_query(&mysql,"show databases") == 0)
|
||||
{
|
||||
if (!(databases = mysql_store_result(&mysql)))
|
||||
put_info(mysql_error(&mysql),INFO_INFO);
|
||||
else
|
||||
{
|
||||
while ((database_row=mysql_fetch_row(databases)))
|
||||
add_word(&ht,(char*) database_row[0]);
|
||||
{
|
||||
char *str=strdup_root(&hash_mem_root, (char*) database_row[0]);
|
||||
if (str)
|
||||
add_word(&ht,(char*) str);
|
||||
}
|
||||
mysql_free_result(databases);
|
||||
}
|
||||
}
|
||||
/* hash all table names */
|
||||
|
@ -1229,22 +1239,13 @@ You can turn off this feature to get a quicker startup with -A\n\n");
|
|||
}
|
||||
while ((table_row=mysql_fetch_row(tables)))
|
||||
{
|
||||
if (!completion_hash_exists(&ht,(char*) table_row[0],
|
||||
(uint) strlen((const char*) table_row[0])))
|
||||
add_word(&ht,table_row[0]);
|
||||
char *str=strdup_root(&hash_mem_root, (char*) table_row[0]);
|
||||
if (str &&
|
||||
!completion_hash_exists(&ht,(char*) str, (uint) strlen(str)))
|
||||
add_word(&ht,str);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (field_names) {
|
||||
for (i=0; field_names[i]; i++) {
|
||||
for (j=0; field_names[i][j]; j++) {
|
||||
my_free(field_names[i][j],MYF(0));
|
||||
}
|
||||
my_free((gptr) field_names[i],MYF(0));
|
||||
}
|
||||
my_free((gptr) field_names,MYF(0));
|
||||
}
|
||||
field_names=0;
|
||||
|
||||
/* hash all field names, both with the table prefix and without it */
|
||||
if (!tables) /* no tables */
|
||||
|
@ -1252,36 +1253,37 @@ You can turn off this feature to get a quicker startup with -A\n\n");
|
|||
DBUG_VOID_RETURN;
|
||||
}
|
||||
mysql_data_seek(tables,0);
|
||||
field_names = (char ***) my_malloc(sizeof(char **) *
|
||||
(uint) (mysql_num_rows(tables)+1),
|
||||
MYF(MY_WME));
|
||||
if (!field_names)
|
||||
if (!(field_names= (char ***) alloc_root(&hash_mem_root,sizeof(char **) *
|
||||
(uint) (mysql_num_rows(tables)+1))))
|
||||
{
|
||||
mysql_free_result(tables);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
i=0;
|
||||
while ((table_row=mysql_fetch_row(tables)))
|
||||
{
|
||||
if ((fields=mysql_list_fields(&mysql,(const char*) table_row[0],NullS)))
|
||||
{
|
||||
num_fields=mysql_num_fields(fields);
|
||||
field_names[i] = (char **) my_malloc(sizeof(char *)*(num_fields*2+1),
|
||||
MYF(0));
|
||||
if (!field_names[i])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!(field_names[i] = (char **) alloc_root(&hash_mem_root,
|
||||
sizeof(char *) *
|
||||
(num_fields*2+1))))
|
||||
break;
|
||||
field_names[i][num_fields*2]='\0';
|
||||
j=0;
|
||||
while ((sql_field=mysql_fetch_field(fields)))
|
||||
{
|
||||
sprintf(buf,"%s.%s",table_row[0],sql_field->name);
|
||||
field_names[i][j] = my_strdup(buf,MYF(0));
|
||||
field_names[i][j] = strdup_root(&hash_mem_root,buf);
|
||||
add_word(&ht,field_names[i][j]);
|
||||
field_names[i][num_fields+j] = my_strdup(sql_field->name,MYF(0));
|
||||
field_names[i][num_fields+j] = strdup_root(&hash_mem_root,
|
||||
sql_field->name);
|
||||
if (!completion_hash_exists(&ht,field_names[i][num_fields+j],
|
||||
(uint) strlen(field_names[i][num_fields+j])))
|
||||
add_word(&ht,field_names[i][num_fields+j]);
|
||||
j++;
|
||||
}
|
||||
mysql_free_result(fields);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1291,6 +1293,7 @@ You can turn off this feature to get a quicker startup with -A\n\n");
|
|||
}
|
||||
i++;
|
||||
}
|
||||
mysql_free_result(tables);
|
||||
field_names[i]=0; // End pointer
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
@ -2208,16 +2211,8 @@ static int
|
|||
sql_real_connect(char *host,char *database,char *user,char *password,
|
||||
uint silent)
|
||||
{
|
||||
if (connected)
|
||||
{ /* if old is open, close it first */
|
||||
mysql_close(&mysql);
|
||||
connected= 0;
|
||||
}
|
||||
#ifdef HAVE_OPENSSL
|
||||
else
|
||||
mysql_ssl_clear(&mysql); /* SSL data structres should be freed
|
||||
even if connection was not made */
|
||||
#endif
|
||||
mysql_close(&mysql);
|
||||
connected= 0;
|
||||
mysql_init(&mysql);
|
||||
if (opt_connect_timeout)
|
||||
{
|
||||
|
@ -2230,7 +2225,7 @@ sql_real_connect(char *host,char *database,char *user,char *password,
|
|||
#ifdef HAVE_OPENSSL
|
||||
if (opt_use_ssl)
|
||||
mysql_ssl_set(&mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca,
|
||||
opt_ssl_capath);
|
||||
opt_ssl_capath, opt_ssl_cipher);
|
||||
#endif
|
||||
if (safe_updates)
|
||||
{
|
||||
|
@ -2569,7 +2564,7 @@ static void mysql_end_timer(ulong start_time,char *buff)
|
|||
strmov(strend(buff),")");
|
||||
}
|
||||
|
||||
#ifndef EMBEDDED_SERVER
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
/* Keep sql_string library happy */
|
||||
|
||||
gptr sql_alloc(unsigned int Size)
|
||||
|
@ -2581,4 +2576,4 @@ void sql_element_free(void *ptr)
|
|||
{
|
||||
my_free((gptr) ptr,MYF(0));
|
||||
}
|
||||
#endif /* EMBEDDED_SERVER */
|
||||
#endif /* EMBEDDED_LIBRARY */
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include <my_pthread.h> /* because of signal() */
|
||||
#endif
|
||||
|
||||
#define ADMIN_VERSION "8.21"
|
||||
#define ADMIN_VERSION "8.22"
|
||||
#define MAX_MYSQL_VAR 64
|
||||
#define SHUTDOWN_DEF_TIMEOUT 3600 /* Wait for shutdown */
|
||||
#define MAX_TRUNC_LENGTH 3
|
||||
|
@ -51,7 +51,7 @@ static void print_version(void);
|
|||
static void usage(void);
|
||||
static my_bool sql_connect(MYSQL *mysql,const char *host, const char *user,
|
||||
const char *password,uint wait);
|
||||
static my_bool execute_commands(MYSQL *mysql,int argc, char **argv);
|
||||
static int execute_commands(MYSQL *mysql,int argc, char **argv);
|
||||
static int drop_db(MYSQL *mysql,const char *db);
|
||||
static sig_handler endprog(int signal_number);
|
||||
static void nice_time(ulong sec,char *buff);
|
||||
|
@ -265,7 +265,7 @@ int main(int argc,char *argv[])
|
|||
#ifdef HAVE_OPENSSL
|
||||
if (opt_use_ssl)
|
||||
mysql_ssl_set(&mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca,
|
||||
opt_ssl_capath);
|
||||
opt_ssl_capath, opt_ssl_cipher);
|
||||
#endif /* HAVE_OPENSSL */
|
||||
if (sql_connect(&mysql,host,user,opt_password,option_wait))
|
||||
error = 1;
|
||||
|
@ -275,16 +275,24 @@ int main(int argc,char *argv[])
|
|||
while (!interrupted)
|
||||
{
|
||||
new_line = 0;
|
||||
if (execute_commands(&mysql,argc,commands) && !option_force)
|
||||
if ((error=execute_commands(&mysql,argc,commands)))
|
||||
{
|
||||
if (option_wait && !interrupted)
|
||||
if (error > 0)
|
||||
break; /* Wrong command error */
|
||||
if (!option_force)
|
||||
{
|
||||
mysql_close(&mysql);
|
||||
if (!sql_connect(&mysql,host,user,opt_password,option_wait))
|
||||
continue; /* Retry */
|
||||
if (option_wait && !interrupted)
|
||||
{
|
||||
mysql_close(&mysql);
|
||||
if (!sql_connect(&mysql,host,user,opt_password,option_wait))
|
||||
{
|
||||
sleep(1); /* Don't retry too rapidly */
|
||||
continue; /* Retry */
|
||||
}
|
||||
}
|
||||
error=1;
|
||||
break;
|
||||
}
|
||||
error=1;
|
||||
break;
|
||||
}
|
||||
if (interval)
|
||||
{
|
||||
|
@ -301,7 +309,7 @@ int main(int argc,char *argv[])
|
|||
my_free(user,MYF(MY_ALLOW_ZERO_PTR));
|
||||
free_defaults(argv);
|
||||
my_end(0);
|
||||
exit(error);
|
||||
exit(error ? 1 : 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -383,8 +391,14 @@ static my_bool sql_connect(MYSQL *mysql,const char *host, const char *user,
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Execute a command.
|
||||
Return 0 on ok
|
||||
-1 on retryable error
|
||||
1 on fatal error
|
||||
*/
|
||||
|
||||
static my_bool execute_commands(MYSQL *mysql,int argc, char **argv)
|
||||
static int execute_commands(MYSQL *mysql,int argc, char **argv)
|
||||
{
|
||||
char *status;
|
||||
|
||||
|
@ -404,7 +418,7 @@ static my_bool execute_commands(MYSQL *mysql,int argc, char **argv)
|
|||
{
|
||||
my_printf_error(0,"CREATE DATABASE failed; error: '%-.200s'",
|
||||
MYF(ME_BELL), mysql_error(mysql));
|
||||
return 1;
|
||||
return -1;
|
||||
}
|
||||
argc--; argv++;
|
||||
break;
|
||||
|
@ -417,7 +431,7 @@ static my_bool execute_commands(MYSQL *mysql,int argc, char **argv)
|
|||
return 1;
|
||||
}
|
||||
if (drop_db(mysql,argv[1]))
|
||||
return 1;
|
||||
return -1;
|
||||
argc--; argv++;
|
||||
break;
|
||||
}
|
||||
|
@ -433,7 +447,7 @@ static my_bool execute_commands(MYSQL *mysql,int argc, char **argv)
|
|||
{
|
||||
my_printf_error(0,"shutdown failed; error: '%s'",MYF(ME_BELL),
|
||||
mysql_error(mysql));
|
||||
return 1;
|
||||
return -1;
|
||||
}
|
||||
mysql_close(mysql); /* Close connection to avoid error messages */
|
||||
if (got_pidfile)
|
||||
|
@ -450,7 +464,7 @@ static my_bool execute_commands(MYSQL *mysql,int argc, char **argv)
|
|||
{
|
||||
my_printf_error(0,"reload failed; error: '%s'",MYF(ME_BELL),
|
||||
mysql_error(mysql));
|
||||
return 1;
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
case ADMIN_REFRESH:
|
||||
|
@ -461,7 +475,7 @@ static my_bool execute_commands(MYSQL *mysql,int argc, char **argv)
|
|||
{
|
||||
my_printf_error(0,"refresh failed; error: '%s'",MYF(ME_BELL),
|
||||
mysql_error(mysql));
|
||||
return 1;
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
case ADMIN_FLUSH_THREADS:
|
||||
|
@ -469,7 +483,7 @@ static my_bool execute_commands(MYSQL *mysql,int argc, char **argv)
|
|||
{
|
||||
my_printf_error(0,"refresh failed; error: '%s'",MYF(ME_BELL),
|
||||
mysql_error(mysql));
|
||||
return 1;
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
case ADMIN_VER:
|
||||
|
@ -513,7 +527,7 @@ static my_bool execute_commands(MYSQL *mysql,int argc, char **argv)
|
|||
{
|
||||
my_printf_error(0,"process list failed; error: '%s'",MYF(ME_BELL),
|
||||
mysql_error(mysql));
|
||||
return 1;
|
||||
return -1;
|
||||
}
|
||||
print_header(result);
|
||||
while ((row=mysql_fetch_row(result)))
|
||||
|
@ -552,7 +566,7 @@ static my_bool execute_commands(MYSQL *mysql,int argc, char **argv)
|
|||
}
|
||||
argc--; argv++;
|
||||
if (error)
|
||||
return error;
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
case ADMIN_DEBUG:
|
||||
|
@ -560,7 +574,7 @@ static my_bool execute_commands(MYSQL *mysql,int argc, char **argv)
|
|||
{
|
||||
my_printf_error(0,"debug failed; error: '%s'",MYF(ME_BELL),
|
||||
mysql_error(mysql));
|
||||
return 1;
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
case ADMIN_VARIABLES:
|
||||
|
@ -574,7 +588,7 @@ static my_bool execute_commands(MYSQL *mysql,int argc, char **argv)
|
|||
{
|
||||
my_printf_error(0,"unable to show variables; error: '%s'",MYF(ME_BELL),
|
||||
mysql_error(mysql));
|
||||
return 1;
|
||||
return -1;
|
||||
}
|
||||
print_header(res);
|
||||
while ((row=mysql_fetch_row(res)))
|
||||
|
@ -596,7 +610,7 @@ static my_bool execute_commands(MYSQL *mysql,int argc, char **argv)
|
|||
{
|
||||
my_printf_error(0, "unable to show status; error: '%s'", MYF(ME_BELL),
|
||||
mysql_error(mysql));
|
||||
return 1;
|
||||
return -1;
|
||||
}
|
||||
if (!opt_vertical)
|
||||
print_header(res);
|
||||
|
@ -646,7 +660,7 @@ static my_bool execute_commands(MYSQL *mysql,int argc, char **argv)
|
|||
{
|
||||
my_printf_error(0,"refresh failed; error: '%s'",MYF(ME_BELL),
|
||||
mysql_error(mysql));
|
||||
return 1;
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -656,7 +670,7 @@ static my_bool execute_commands(MYSQL *mysql,int argc, char **argv)
|
|||
{
|
||||
my_printf_error(0,"refresh failed; error: '%s'",MYF(ME_BELL),
|
||||
mysql_error(mysql));
|
||||
return 1;
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -666,7 +680,7 @@ static my_bool execute_commands(MYSQL *mysql,int argc, char **argv)
|
|||
{
|
||||
my_printf_error(0,"refresh failed; error: '%s'",MYF(ME_BELL),
|
||||
mysql_error(mysql));
|
||||
return 1;
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -676,7 +690,7 @@ static my_bool execute_commands(MYSQL *mysql,int argc, char **argv)
|
|||
{
|
||||
my_printf_error(0,"refresh failed; error: '%s'",MYF(ME_BELL),
|
||||
mysql_error(mysql));
|
||||
return 1;
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -684,7 +698,7 @@ static my_bool execute_commands(MYSQL *mysql,int argc, char **argv)
|
|||
{
|
||||
char buff[128],crypted_pw[33];
|
||||
|
||||
if(argc < 2)
|
||||
if (argc < 2)
|
||||
{
|
||||
my_printf_error(0,"Too few arguments to change password",MYF(ME_BELL));
|
||||
return 1;
|
||||
|
@ -699,13 +713,13 @@ static my_bool execute_commands(MYSQL *mysql,int argc, char **argv)
|
|||
{
|
||||
my_printf_error(0, "Can't turn off logging; error: '%s'",
|
||||
MYF(ME_BELL),mysql_error(mysql));
|
||||
return 1;
|
||||
return -1;
|
||||
}
|
||||
if (mysql_query(mysql,buff))
|
||||
{
|
||||
my_printf_error(0,"unable to change password; error: '%s'",
|
||||
MYF(ME_BELL),mysql_error(mysql));
|
||||
return 1;
|
||||
return -1;
|
||||
}
|
||||
argc--; argv++;
|
||||
break;
|
||||
|
@ -716,7 +730,7 @@ static my_bool execute_commands(MYSQL *mysql,int argc, char **argv)
|
|||
{
|
||||
my_printf_error(0, "Error starting slave: %s", MYF(ME_BELL),
|
||||
mysql_error(mysql));
|
||||
return 1;
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
puts("Slave started");
|
||||
|
@ -726,7 +740,7 @@ static my_bool execute_commands(MYSQL *mysql,int argc, char **argv)
|
|||
{
|
||||
my_printf_error(0, "Error stopping slave: %s", MYF(ME_BELL),
|
||||
mysql_error(mysql));
|
||||
return 1;
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
puts("Slave stopped");
|
||||
|
@ -751,7 +765,7 @@ static my_bool execute_commands(MYSQL *mysql,int argc, char **argv)
|
|||
{
|
||||
my_printf_error(0,"mysqld doesn't answer to ping, error: '%s'",
|
||||
MYF(ME_BELL),mysql_error(mysql));
|
||||
return 1;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
mysql->reconnect=1; /* Automatic reconnect is default */
|
||||
|
@ -914,7 +928,7 @@ static void print_header(MYSQL_RES *result)
|
|||
putchar('|');
|
||||
while ((field = mysql_fetch_field(result)))
|
||||
{
|
||||
printf(" %-*s|",field->max_length+1,field->name);
|
||||
printf(" %-*s|",(int) field->max_length+1,field->name);
|
||||
}
|
||||
putchar('\n');
|
||||
print_top(result);
|
||||
|
@ -969,11 +983,11 @@ static void print_relative_row(MYSQL_RES *result, MYSQL_ROW cur, uint row)
|
|||
|
||||
mysql_field_seek(result, 0);
|
||||
field = mysql_fetch_field(result);
|
||||
printf("| %-*s|", field->max_length + 1, cur[0]);
|
||||
printf("| %-*s|", (int) field->max_length + 1, cur[0]);
|
||||
|
||||
field = mysql_fetch_field(result);
|
||||
tmp = cur[1] ? strtoull(cur[1], NULL, 0) : (ulonglong) 0;
|
||||
printf(" %-*s|\n", field->max_length + 1,
|
||||
printf(" %-*s|\n", (int) field->max_length + 1,
|
||||
llstr((tmp - last_values[row]), buff));
|
||||
last_values[row] = tmp;
|
||||
}
|
||||
|
|
|
@ -23,15 +23,6 @@
|
|||
|
||||
#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | CLIENT_LOCAL_FILES)
|
||||
|
||||
#ifndef OS2
|
||||
extern "C"
|
||||
{
|
||||
int simple_command(MYSQL *mysql,enum enum_server_command command,
|
||||
const char *arg, uint length, my_bool skipp_check);
|
||||
uint net_safe_read(MYSQL* mysql);
|
||||
}
|
||||
#endif
|
||||
|
||||
char server_version[SERVER_VERSION_LENGTH];
|
||||
uint32 server_id = 0;
|
||||
|
||||
|
@ -321,6 +312,7 @@ static void dump_remote_log_entries(const char* logname)
|
|||
|
||||
for(;;)
|
||||
{
|
||||
const char *error;
|
||||
len = net_safe_read(mysql);
|
||||
if (len == packet_error)
|
||||
die("Error reading packet from server: %s", mysql_error(mysql));
|
||||
|
@ -330,8 +322,8 @@ static void dump_remote_log_entries(const char* logname)
|
|||
len, net->read_pos[5]));
|
||||
Log_event * ev = Log_event::read_log_event(
|
||||
(const char*) net->read_pos + 1 ,
|
||||
len - 1);
|
||||
if(ev)
|
||||
len - 1, &error);
|
||||
if (ev)
|
||||
{
|
||||
ev->print(result_file, short_form, last_db);
|
||||
if(ev->get_type_code() == LOAD_EVENT)
|
||||
|
|
|
@ -591,7 +591,7 @@ static int dbConnect(char *host, char *user, char *passwd)
|
|||
#ifdef HAVE_OPENSSL
|
||||
if (opt_use_ssl)
|
||||
mysql_ssl_set(&mysql_connection, opt_ssl_key, opt_ssl_cert, opt_ssl_ca,
|
||||
opt_ssl_capath);
|
||||
opt_ssl_capath, opt_ssl_cipher);
|
||||
#endif
|
||||
if (!(sock = mysql_real_connect(&mysql_connection, host, user, passwd,
|
||||
NULL, opt_mysql_port, opt_mysql_unix_port, 0)))
|
||||
|
|
|
@ -18,26 +18,22 @@
|
|||
**
|
||||
** The author's original notes follow :-
|
||||
**
|
||||
** ******************************************************
|
||||
** * *
|
||||
** * AUTHOR: Igor Romanenko (igor@frog.kiev.ua) *
|
||||
** * DATE: December 3, 1994 *
|
||||
** * WARRANTY: None, expressed, impressed, implied *
|
||||
** * or other *
|
||||
** * STATUS: Public domain *
|
||||
** * Adapted and optimized for MySQL by *
|
||||
** * Michael Widenius, Sinisa Milivojevic, Jani Tolonen *
|
||||
** * -w --where added 9/10/98 by Jim Faucette *
|
||||
** * slave code by David Saez Padros <david@ols.es> *
|
||||
** * *
|
||||
** ******************************************************
|
||||
*/
|
||||
/* SSL by
|
||||
** Andrei Errapart <andreie@no.spam.ee>
|
||||
** Tõnu Samuel <tonu@please.do.not.remove.this.spam.ee>
|
||||
** AUTHOR: Igor Romanenko (igor@frog.kiev.ua)
|
||||
** DATE: December 3, 1994
|
||||
** WARRANTY: None, expressed, impressed, implied
|
||||
** or other
|
||||
** STATUS: Public domain
|
||||
** Adapted and optimized for MySQL by
|
||||
** Michael Widenius, Sinisa Milivojevic, Jani Tolonen
|
||||
** -w --where added 9/10/98 by Jim Faucette
|
||||
** slave code by David Saez Padros <david@ols.es>
|
||||
** master/autocommit code by Brian Aker <brian@tangent.org>
|
||||
** SSL by
|
||||
** Andrei Errapart <andreie@no.spam.ee>
|
||||
** Tõnu Samuel <tonu@please.do.not.remove.this.spam.ee>
|
||||
**/
|
||||
|
||||
#define DUMP_VERSION "8.16"
|
||||
#define DUMP_VERSION "8.17"
|
||||
|
||||
#include <my_global.h>
|
||||
#include <my_sys.h>
|
||||
|
@ -73,7 +69,7 @@ static my_bool verbose=0,tFlag=0,cFlag=0,dFlag=0,quick=0, extended_insert = 0,
|
|||
lock_tables=0,ignore_errors=0,flush_logs=0,replace=0,
|
||||
ignore=0,opt_drop=0,opt_keywords=0,opt_lock=0,opt_compress=0,
|
||||
opt_delayed=0,create_options=0,opt_quoted=0,opt_databases=0,
|
||||
opt_alldbs=0,opt_create_db=0,opt_first_slave=0;
|
||||
opt_alldbs=0,opt_create_db=0,opt_first_slave=0, opt_autocommit=0, opt_master_data;
|
||||
static MYSQL mysql_connection,*sock=0;
|
||||
static char insert_pat[12 * 1024],*opt_password=0,*current_user=0,
|
||||
*current_host=0,*path=0,*fields_terminated=0,
|
||||
|
@ -89,7 +85,8 @@ FILE *md_result_file;
|
|||
|
||||
enum md_options {OPT_FTB=256, OPT_LTB, OPT_ENC, OPT_O_ENC, OPT_ESC,
|
||||
OPT_KEYWORDS, OPT_LOCKS, OPT_DROP, OPT_OPTIMIZE, OPT_DELAYED,
|
||||
OPT_TABLES, MD_OPT_CHARSETS_DIR, MD_OPT_DEFAULT_CHARSET};
|
||||
OPT_TABLES, MD_OPT_CHARSETS_DIR, MD_OPT_DEFAULT_CHARSET,
|
||||
OPT_AUTOCOMMIT, OPT_MASTER_DATA};
|
||||
|
||||
static struct option long_options[] =
|
||||
{
|
||||
|
@ -117,6 +114,8 @@ static struct option long_options[] =
|
|||
{"host", required_argument, 0, 'h'},
|
||||
{"lines-terminated-by", required_argument, 0, (int) OPT_LTB},
|
||||
{"lock-tables", no_argument, 0, 'l'},
|
||||
{"master-data", no_argument, 0, OPT_MASTER_DATA},
|
||||
{"no-autocommit", no_argument, 0, OPT_AUTOCOMMIT},
|
||||
{"no-create-db", no_argument, 0, 'n'},
|
||||
{"no-create-info", no_argument, 0, 't'},
|
||||
{"no-data", no_argument, 0, 'd'},
|
||||
|
@ -205,11 +204,15 @@ static void usage(void)
|
|||
--add-locks Add locks around insert statements.\n\
|
||||
--allow-keywords Allow creation of column names that are keywords.\n\
|
||||
--delayed-insert Insert rows with INSERT DELAYED.\n\
|
||||
--master-data This will cause the master position and filename to \n\
|
||||
be appended to your output. This will automagically \n\
|
||||
enable --first-slave.\n\
|
||||
-F, --flush-logs Flush logs file in server before starting dump.\n\
|
||||
-f, --force Continue even if we get an sql-error.\n\
|
||||
-h, --host=... Connect to host.\n");
|
||||
puts("\
|
||||
-l, --lock-tables Lock all tables for read.\n\
|
||||
--no-autocommit Wrap tables with autocommit/commit statements.\n\
|
||||
-n, --no-create-db 'CREATE DATABASE /*!32312 IF NOT EXISTS*/ db_name;'\n\
|
||||
will not be put in the output. The above line will\n\
|
||||
be added otherwise, if --databases or\n\
|
||||
|
@ -249,6 +252,7 @@ puts("\
|
|||
-v, --verbose Print info about the various stages.\n\
|
||||
-V, --version Output version information and exit.\n\
|
||||
-w, --where= dump only selected records; QUOTES mandatory!\n\
|
||||
-x, --first-slave Locks all tables across all databases.\n\
|
||||
EXAMPLES: \"--where=user=\'jimf\'\" \"-wuserid>1\" \"-wuserid<1\"\n\
|
||||
Use -T (--tab=...) with --fields-...\n\
|
||||
--fields-terminated-by=...\n\
|
||||
|
@ -274,7 +278,7 @@ puts("\
|
|||
|
||||
static void write_heder(FILE *sql_file, char *db_name)
|
||||
{
|
||||
fprintf(sql_file, "-- MySQL dump %s\n#\n", DUMP_VERSION);
|
||||
fprintf(sql_file, "-- MySQL dump %s\n--\n", DUMP_VERSION);
|
||||
fprintf(sql_file, "-- Host: %s Database: %s\n",
|
||||
current_host ? current_host : "localhost", db_name ? db_name : "");
|
||||
fputs("---------------------------------------------------------\n",
|
||||
|
@ -298,6 +302,13 @@ static int get_options(int *argc,char ***argv)
|
|||
long_options, &option_index)) != EOF)
|
||||
{
|
||||
switch(c) {
|
||||
case OPT_MASTER_DATA:
|
||||
opt_master_data=1;
|
||||
opt_first_slave=1;
|
||||
break;
|
||||
case OPT_AUTOCOMMIT:
|
||||
opt_autocommit=1;
|
||||
break;
|
||||
case 'a':
|
||||
create_options=1;
|
||||
break;
|
||||
|
@ -523,7 +534,7 @@ static int dbConnect(char *host, char *user,char *passwd)
|
|||
#ifdef HAVE_OPENSSL
|
||||
if (opt_use_ssl)
|
||||
mysql_ssl_set(&mysql_connection, opt_ssl_key, opt_ssl_cert, opt_ssl_ca,
|
||||
opt_ssl_capath);
|
||||
opt_ssl_capath, opt_ssl_cipher);
|
||||
#endif
|
||||
if (!(sock= mysql_real_connect(&mysql_connection,host,user,passwd,
|
||||
NULL,opt_mysql_port,opt_mysql_unix_port,
|
||||
|
@ -632,8 +643,7 @@ static uint getTableStructure(char *table, char* db)
|
|||
if (path)
|
||||
{
|
||||
char filename[FN_REFLEN], tmp_path[FN_REFLEN];
|
||||
strmov(tmp_path,path);
|
||||
convert_dirname(tmp_path);
|
||||
convert_dirname(tmp_path,path,NullS);
|
||||
sql_file= my_fopen(fn_format(filename, table, tmp_path, ".sql", 4),
|
||||
O_WRONLY, MYF(MY_WME));
|
||||
if (!sql_file) /* If file couldn't be opened */
|
||||
|
@ -643,7 +653,7 @@ static uint getTableStructure(char *table, char* db)
|
|||
}
|
||||
write_heder(sql_file, db);
|
||||
}
|
||||
fprintf(sql_file, "\n#\n# Table structure for table '%s'\n#\n\n", table);
|
||||
fprintf(sql_file, "\n--\n-- Table structure for table '%s'\n--\n\n",table);
|
||||
if (opt_drop)
|
||||
fprintf(sql_file, "DROP TABLE IF EXISTS %s;\n",table_name);
|
||||
|
||||
|
@ -705,8 +715,7 @@ static uint getTableStructure(char *table, char* db)
|
|||
if (path)
|
||||
{
|
||||
char filename[FN_REFLEN], tmp_path[FN_REFLEN];
|
||||
strmov(tmp_path,path);
|
||||
convert_dirname(tmp_path);
|
||||
convert_dirname(tmp_path,path,NullS);
|
||||
sql_file= my_fopen(fn_format(filename, table, tmp_path, ".sql", 4),
|
||||
O_WRONLY, MYF(MY_WME));
|
||||
if (!sql_file) /* If file couldn't be opened */
|
||||
|
@ -716,7 +725,7 @@ static uint getTableStructure(char *table, char* db)
|
|||
}
|
||||
write_heder(sql_file, db);
|
||||
}
|
||||
fprintf(sql_file, "\n#\n# Table structure for table '%s'\n#\n\n", table);
|
||||
fprintf(sql_file, "\n--\n-- Table structure for table '%s'\n--\n\n",table);
|
||||
if (opt_drop)
|
||||
fprintf(sql_file, "DROP TABLE IF EXISTS %s;\n",table_name);
|
||||
fprintf(sql_file, "CREATE TABLE %s (\n", table_name);
|
||||
|
@ -938,8 +947,7 @@ static void dumpTable(uint numFields, char *table)
|
|||
if (path)
|
||||
{
|
||||
char filename[FN_REFLEN], tmp_path[FN_REFLEN];
|
||||
strmov(tmp_path, path);
|
||||
convert_dirname(tmp_path);
|
||||
convert_dirname(tmp_path,path,NullS);
|
||||
my_load_path(tmp_path, tmp_path, NULL);
|
||||
fn_format(filename, table, tmp_path, ".txt", 4);
|
||||
my_delete(filename, MYF(0)); /* 'INTO OUTFILE' doesn't work, if
|
||||
|
@ -973,7 +981,7 @@ static void dumpTable(uint numFields, char *table)
|
|||
}
|
||||
else
|
||||
{
|
||||
fprintf(md_result_file,"\n#\n# Dumping data for table '%s'\n", table);
|
||||
fprintf(md_result_file,"\n--\n-- Dumping data for table '%s'\n--\n", table);
|
||||
sprintf(query, "SELECT * FROM %s", quote_name(table,table_buff));
|
||||
if (where)
|
||||
{
|
||||
|
@ -1014,6 +1022,9 @@ static void dumpTable(uint numFields, char *table)
|
|||
rownr=0;
|
||||
init_length=(uint) strlen(insert_pat)+4;
|
||||
|
||||
if (opt_autocommit)
|
||||
fprintf(md_result_file, "set autocommit=0;\n");
|
||||
|
||||
while ((row=mysql_fetch_row(res)))
|
||||
{
|
||||
uint i;
|
||||
|
@ -1140,6 +1151,8 @@ static void dumpTable(uint numFields, char *table)
|
|||
if (opt_lock)
|
||||
fputs("UNLOCK TABLES;\n", md_result_file);
|
||||
mysql_free_result(res);
|
||||
if (opt_autocommit)
|
||||
fprintf(md_result_file, "commit;\n");
|
||||
}
|
||||
} /* dumpTable */
|
||||
|
||||
|
@ -1214,7 +1227,7 @@ static int init_dumping(char *database)
|
|||
{
|
||||
if (opt_databases || opt_alldbs)
|
||||
{
|
||||
fprintf(md_result_file,"\n#\n# Current Database: %s\n#\n", database);
|
||||
fprintf(md_result_file,"\n--\n-- Current Database: %s\n--\n", database);
|
||||
if (!opt_create_db)
|
||||
fprintf(md_result_file,"\nCREATE DATABASE /*!32312 IF NOT EXISTS*/ %s;\n",
|
||||
database);
|
||||
|
@ -1242,7 +1255,7 @@ static int dump_all_tables_in_db(char *database)
|
|||
init_dynamic_string(&query, "LOCK TABLES ", 256, 1024);
|
||||
for (numrows=0 ; (table = getTableName(1)) ; numrows++)
|
||||
{
|
||||
dynstr_append(&query, quote_name(table,table_buff));
|
||||
dynstr_append(&query, quote_name(table, table_buff));
|
||||
dynstr_append(&query, " READ /*!32311 LOCAL */,");
|
||||
}
|
||||
if (numrows && mysql_real_query(sock, query.str, query.length-1))
|
||||
|
@ -1284,7 +1297,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
|
|||
init_dynamic_string(&query, "LOCK TABLES ", 256, 1024);
|
||||
for (i=0 ; i < tables ; i++)
|
||||
{
|
||||
dynstr_append(&query, quote_name(table_names[i],table_buff));
|
||||
dynstr_append(&query, quote_name(table_names[i], table_buff));
|
||||
dynstr_append(&query, " READ /*!32311 LOCAL */,");
|
||||
}
|
||||
if (mysql_real_query(sock, query.str, query.length-1))
|
||||
|
@ -1340,6 +1353,9 @@ static void print_value(FILE *file, MYSQL_RES *result, MYSQL_ROW row,
|
|||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
MYSQL_ROW row;
|
||||
MYSQL_RES *master;
|
||||
|
||||
MY_INIT(argv[0]);
|
||||
/*
|
||||
** Check out the args
|
||||
|
@ -1376,6 +1392,28 @@ int main(int argc, char **argv)
|
|||
|
||||
if (opt_first_slave)
|
||||
{
|
||||
if (opt_master_data)
|
||||
{
|
||||
if (mysql_query(sock, "SHOW MASTER STATUS") ||
|
||||
!(master = mysql_store_result(sock)))
|
||||
{
|
||||
my_printf_error(0, "Error: Couldn't execute 'SHOW MASTER STATUS': %s",
|
||||
MYF(0), mysql_error(sock));
|
||||
}
|
||||
else
|
||||
{
|
||||
row = mysql_fetch_row(master);
|
||||
if(row[0] && row[1]) {
|
||||
fprintf(md_result_file,
|
||||
"\n--\n-- Position to start replication from\n--\n\n");
|
||||
fprintf(md_result_file,
|
||||
"CHANGE MASTER TO MASTER_LOG_FILE='%s' ;\n", row[0]);
|
||||
fprintf(md_result_file, "CHANGE MASTER TO MASTER_LOG_POS=%s ;\n",
|
||||
row[1]);
|
||||
}
|
||||
mysql_free_result(master);
|
||||
}
|
||||
}
|
||||
if (mysql_query(sock, "FLUSH MASTER"))
|
||||
{
|
||||
my_printf_error(0, "Error: Couldn't execute 'FLUSH MASTER': %s",
|
||||
|
|
|
@ -400,7 +400,7 @@ static MYSQL *db_connect(char *host, char *database, char *user, char *passwd)
|
|||
#ifdef HAVE_OPENSSL
|
||||
if (opt_use_ssl)
|
||||
mysql_ssl_set(&mysql_connection, opt_ssl_key, opt_ssl_cert, opt_ssl_ca,
|
||||
opt_ssl_capath);
|
||||
opt_ssl_capath, opt_ssl_cipher);
|
||||
#endif
|
||||
if (!(sock= mysql_real_connect(&mysql_connection,host,user,passwd,
|
||||
database,opt_mysql_port,opt_mysql_unix_port,
|
||||
|
|
153
client/mysqlmanager-pwgen.c
Normal file
|
@ -0,0 +1,153 @@
|
|||
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult 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; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
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 */
|
||||
|
||||
#define MANAGER_PWGEN_VERSION "1.0"
|
||||
|
||||
#include <my_global.h>
|
||||
#include <m_ctype.h>
|
||||
#include <my_sys.h>
|
||||
#include <m_string.h>
|
||||
#include <mysql_version.h>
|
||||
#include <errno.h>
|
||||
#include <getopt.h>
|
||||
#include <md5.h>
|
||||
|
||||
const char* outfile=0,*user="root";
|
||||
|
||||
struct option long_options[] =
|
||||
{
|
||||
{"output-file",required_argument,0,'o'},
|
||||
{"user",required_argument,0,'u'},
|
||||
{"help",no_argument,0,'?'},
|
||||
{"version",no_argument,0,'V'},
|
||||
{0,0,0,0}
|
||||
};
|
||||
|
||||
static void die(const char* fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
DBUG_ENTER("die");
|
||||
va_start(args, fmt);
|
||||
if (fmt)
|
||||
{
|
||||
fprintf(stderr, "%s: ", my_progname);
|
||||
vfprintf(stderr, fmt, args);
|
||||
fprintf(stderr, "\n");
|
||||
fflush(stderr);
|
||||
}
|
||||
va_end(args);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static void print_version(void)
|
||||
{
|
||||
printf("%s Ver %s Distrib %s, for %s (%s)\n",my_progname,
|
||||
MANAGER_PWGEN_VERSION,
|
||||
MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE);
|
||||
}
|
||||
|
||||
void usage()
|
||||
{
|
||||
print_version();
|
||||
printf("MySQL AB, by Sasha\n");
|
||||
printf("This software comes with ABSOLUTELY NO WARRANTY\n\n");
|
||||
printf("Generates a password file to be used by mysqltest.\n\n");
|
||||
printf("Usage: %s [OPTIONS]\n", my_progname);
|
||||
printf("-?,--help Display this message and exit\n\
|
||||
-V,--version Display version info\n\
|
||||
-u,--user= Put given user in the password file\n\
|
||||
-o,--output-file= Write the output to the file with the given name\n");
|
||||
}
|
||||
|
||||
int parse_args(int argc, char** argv)
|
||||
{
|
||||
int c,option_index=0;
|
||||
while ((c=getopt_long(argc,argv,"?Vu:o:",long_options,&option_index))
|
||||
!= EOF)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case 'o':
|
||||
outfile=optarg;
|
||||
break;
|
||||
case 'u':
|
||||
user=optarg;
|
||||
break;
|
||||
case '?':
|
||||
usage();
|
||||
exit(0);
|
||||
case 'V':
|
||||
print_version();
|
||||
exit(0);
|
||||
default:
|
||||
usage();
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void get_pass(char* pw, int len)
|
||||
{
|
||||
FILE* fp;
|
||||
char* pw_end=pw+len;
|
||||
/* /dev/random is more secure than rand() because the seed is easy to
|
||||
predict, so we resort to rand() only if /dev/random is not available */
|
||||
if ((fp=fopen("/dev/random","r")))
|
||||
{
|
||||
fread(pw,len,1,fp);
|
||||
fclose(fp);
|
||||
while (pw<pw_end)
|
||||
{
|
||||
*pw++='a'+((uint)*pw % 26);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
srand(time(NULL));
|
||||
while (pw<pw_end)
|
||||
*pw++='a'+((uint)rand() % 26);
|
||||
}
|
||||
*pw_end=0;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
FILE* fp;
|
||||
my_MD5_CTX context;
|
||||
uchar digest[16];
|
||||
char pw[17];
|
||||
uint i;
|
||||
|
||||
MY_INIT(argv[0]);
|
||||
parse_args(argc,argv);
|
||||
if (!outfile)
|
||||
die("Missing --output-file");
|
||||
|
||||
if (!(fp=fopen(outfile,"w")))
|
||||
die("Could not open '%s'(errno=%d)",outfile,errno);
|
||||
get_pass(pw,sizeof(pw)-1);
|
||||
my_MD5Init(&context);
|
||||
my_MD5Update(&context,pw,sizeof(pw)-1);
|
||||
my_MD5Final(digest,&context);
|
||||
fprintf(fp,"%s:",user);
|
||||
for (i=0;i<sizeof(digest);i++)
|
||||
fprintf(fp,"%02x",digest[i]);
|
||||
fprintf(fp,"\n");
|
||||
fclose(fp);
|
||||
printf("%s\n",pw);
|
||||
return 0;
|
||||
}
|
192
client/mysqlmanagerc.c
Normal file
|
@ -0,0 +1,192 @@
|
|||
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult 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; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
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 */
|
||||
|
||||
#define MANAGER_CLIENT_VERSION "1.0"
|
||||
|
||||
#include <my_global.h>
|
||||
#include <my_sys.h>
|
||||
#include <m_string.h>
|
||||
#include <mysql.h>
|
||||
#include <mysql_version.h>
|
||||
#include <m_ctype.h>
|
||||
#ifdef OS2
|
||||
#include <config-os2.h>
|
||||
#else
|
||||
#include <my_config.h>
|
||||
#endif
|
||||
#include <my_dir.h>
|
||||
#include <hash.h>
|
||||
#include <mysqld_error.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <getopt.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <violite.h>
|
||||
|
||||
#ifndef MYSQL_MANAGER_PORT
|
||||
#define MYSQL_MANAGER_PORT 23546
|
||||
#endif
|
||||
|
||||
static void die(const char* fmt, ...);
|
||||
|
||||
const char* user="root",*host="localhost";
|
||||
char* pass=0;
|
||||
int quiet=0;
|
||||
uint port=MYSQL_MANAGER_PORT;
|
||||
static const char *load_default_groups[]= { "mysqlmanagerc",0 };
|
||||
char** default_argv;
|
||||
MYSQL_MANAGER *manager;
|
||||
FILE* fp, *fp_out;
|
||||
|
||||
struct option long_options[] =
|
||||
{
|
||||
{"host",required_argument,0,'h'},
|
||||
{"user",required_argument,0,'u'},
|
||||
{"password",optional_argument,0,'p',},
|
||||
{"port",required_argument,0,'P'},
|
||||
{"help",no_argument,0,'?'},
|
||||
{"version",no_argument,0,'V'},
|
||||
{"quiet",no_argument,0,'q'},
|
||||
{0,0,0,0}
|
||||
};
|
||||
|
||||
static void die(const char* fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
DBUG_ENTER("die");
|
||||
va_start(args, fmt);
|
||||
if (fmt)
|
||||
{
|
||||
fprintf(stderr, "%s: ", my_progname);
|
||||
vfprintf(stderr, fmt, args);
|
||||
fprintf(stderr, "\n");
|
||||
fflush(stderr);
|
||||
}
|
||||
va_end(args);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static void print_version(void)
|
||||
{
|
||||
printf("%s Ver %s Distrib %s, for %s (%s)\n",my_progname,
|
||||
MANAGER_CLIENT_VERSION,
|
||||
MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE);
|
||||
}
|
||||
|
||||
void usage()
|
||||
{
|
||||
print_version();
|
||||
printf("MySQL AB, by Sasha\n");
|
||||
printf("This software comes with ABSOLUTELY NO WARRANTY\n\n");
|
||||
printf("Command-line client for MySQL manager daemon.\n\n");
|
||||
printf("Usage: %s [OPTIONS] < command_file\n", my_progname);
|
||||
printf("\n\
|
||||
-?, --help Display this help and exit.\n");
|
||||
printf("\
|
||||
-h, --host=... Connect to host.\n\
|
||||
-u, --user=... User for login.\n\
|
||||
-p[password], --password[=...]\n\
|
||||
Password to use when connecting to server.\n\
|
||||
-P, --port=... Port number to use for connection.\n\
|
||||
-q, --quiet, --silent Suppress all normal output.\n\
|
||||
-V, --version Output version information and exit.\n\
|
||||
--no-defaults Don't read default options from any options file.\n\n");
|
||||
}
|
||||
int parse_args(int argc, char **argv)
|
||||
{
|
||||
int c, option_index = 0;
|
||||
my_bool tty_password=0;
|
||||
|
||||
load_defaults("my",load_default_groups,&argc,&argv);
|
||||
default_argv= argv;
|
||||
|
||||
while ((c = getopt_long(argc, argv, "h:p::u:P:?Vq",
|
||||
long_options, &option_index)) != EOF)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case 'h':
|
||||
host=optarg;
|
||||
break;
|
||||
case 'u':
|
||||
user=optarg;
|
||||
break;
|
||||
case 'p':
|
||||
if (optarg)
|
||||
{
|
||||
my_free(pass,MYF(MY_ALLOW_ZERO_PTR));
|
||||
pass=my_strdup(optarg,MYF(MY_FAE));
|
||||
while (*optarg) *optarg++= 'x'; /* Destroy argument */
|
||||
}
|
||||
else
|
||||
tty_password=1;
|
||||
break;
|
||||
case 'P':
|
||||
port=atoi(optarg);
|
||||
break;
|
||||
case 'q':
|
||||
quiet=1;
|
||||
break;
|
||||
case 'V':
|
||||
print_version();
|
||||
exit(0);
|
||||
case '?':
|
||||
usage();
|
||||
exit(0);
|
||||
default:
|
||||
usage();
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
MY_INIT(argv[0]);
|
||||
fp=stdin;
|
||||
fp_out=stdout;
|
||||
parse_args(argc,argv);
|
||||
if (!(manager=mysql_manager_init(0)))
|
||||
die("Failed in mysql_manager_init()");
|
||||
if (!mysql_manager_connect(manager,host,user,pass,port))
|
||||
die("Could not connect to MySQL manager: %s(%d)",manager->last_error,
|
||||
manager->last_errno);
|
||||
for (;!feof(fp);)
|
||||
{
|
||||
char buf[4096];
|
||||
if (!fgets(buf,sizeof(buf),fp))
|
||||
break;
|
||||
if (!quiet)
|
||||
fprintf(fp_out,"<<%s",buf);
|
||||
if (mysql_manager_command(manager,buf,strlen(buf)))
|
||||
die("Error in command: %s(%d)",manager->last_error,manager->last_errno);
|
||||
while (!manager->eof)
|
||||
{
|
||||
if (mysql_manager_fetch_line(manager,buf,sizeof(buf)))
|
||||
die("Error fetching result line: %s(%d)", manager->last_error,
|
||||
manager->last_errno);
|
||||
if (!quiet)
|
||||
fprintf(fp_out,">>%s\n",buf);
|
||||
}
|
||||
}
|
||||
mysql_manager_close(manager);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -87,7 +87,7 @@ int main(int argc, char **argv)
|
|||
#ifdef HAVE_OPENSSL
|
||||
if (opt_use_ssl)
|
||||
mysql_ssl_set(&mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca,
|
||||
opt_ssl_capath);
|
||||
opt_ssl_capath, opt_ssl_cipher);
|
||||
#endif
|
||||
if (!(mysql_real_connect(&mysql,host,user,opt_password,
|
||||
argv[0],opt_mysql_port,opt_mysql_unix_port,
|
||||
|
@ -713,7 +713,7 @@ static void print_res_header(MYSQL_RES *result)
|
|||
putchar('|');
|
||||
while ((field = mysql_fetch_field(result)))
|
||||
{
|
||||
printf(" %-*s|",field->max_length+1,field->name);
|
||||
printf(" %-*s|",(int) field->max_length+1,field->name);
|
||||
}
|
||||
putchar('\n');
|
||||
print_res_top(result);
|
||||
|
|
|
@ -43,22 +43,18 @@
|
|||
|
||||
**********************************************************************/
|
||||
|
||||
#define MTEST_VERSION "1.10"
|
||||
#define MTEST_VERSION "1.11"
|
||||
|
||||
#include <my_global.h>
|
||||
#include <mysql_embed.h>
|
||||
#include <my_sys.h>
|
||||
#include <m_string.h>
|
||||
#include <mysql.h>
|
||||
#include <mysql_version.h>
|
||||
#include <mysqld_error.h>
|
||||
#include <m_ctype.h>
|
||||
#ifdef OS2
|
||||
#include <config-os2.h>
|
||||
#else
|
||||
#include <my_config.h>
|
||||
#endif
|
||||
#include <my_dir.h>
|
||||
#include <hash.h>
|
||||
#include <mysqld_error.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <getopt.h>
|
||||
|
@ -84,12 +80,23 @@
|
|||
* the server - to solve the problem, we try again
|
||||
* after some sleep if connection fails the first
|
||||
* time */
|
||||
#ifndef MYSQL_MANAGER_PORT
|
||||
#define MYSQL_MANAGER_PORT 23546
|
||||
#endif
|
||||
|
||||
enum {OPT_MANAGER_USER=256,OPT_MANAGER_HOST,OPT_MANAGER_PASSWD,
|
||||
OPT_MANAGER_PORT,OPT_MANAGER_WAIT_TIMEOUT};
|
||||
|
||||
static int record = 0, verbose = 0, silent = 0, opt_sleep=0;
|
||||
static char *db = 0, *pass=0;
|
||||
const char* user = 0, *host = 0, *unix_sock = 0;
|
||||
static int port = 0, opt_big_test=0;
|
||||
const char* user = 0, *host = 0, *unix_sock = 0, *opt_basedir="./";
|
||||
static int port = 0, opt_big_test=0, opt_compress=0;
|
||||
static uint start_lineno, *lineno;
|
||||
const char* manager_user="root",*manager_host="localhost";
|
||||
char *manager_pass=0;
|
||||
int manager_port=MYSQL_MANAGER_PORT;
|
||||
int manager_wait_timeout=3;
|
||||
MYSQL_MANAGER* manager=0;
|
||||
|
||||
static char **default_argv;
|
||||
static const char *load_default_groups[]= { "mysqltest","client",0 };
|
||||
|
@ -127,6 +134,8 @@ typedef struct
|
|||
int read_lines,current_line;
|
||||
} PARSER;
|
||||
|
||||
MYSQL_RES *last_result=0;
|
||||
|
||||
PARSER parser;
|
||||
MASTER_POS master_pos;
|
||||
int* block_ok; /* set to 0 if the current block should not be executed */
|
||||
|
@ -143,11 +152,13 @@ typedef struct
|
|||
int int_val;
|
||||
int alloced_len;
|
||||
int int_dirty; /* do not update string if int is updated until first read */
|
||||
int alloced;
|
||||
} VAR;
|
||||
|
||||
VAR var_reg[10];
|
||||
/*Perl/shell-like variable registers */
|
||||
HASH var_hash;
|
||||
int disable_query_log=0;
|
||||
|
||||
struct connection cons[MAX_CONS];
|
||||
struct connection* cur_con, *next_con, *cons_end;
|
||||
|
@ -169,6 +180,8 @@ Q_DIRTY_CLOSE, Q_REPLACE,
|
|||
Q_PING, Q_EVAL,
|
||||
Q_RPL_PROBE, Q_ENABLE_RPL_PARSE,
|
||||
Q_DISABLE_RPL_PARSE, Q_EVAL_RESULT,
|
||||
Q_ENABLE_QUERY_LOG, Q_DISABLE_QUERY_LOG,
|
||||
Q_SERVER_START, Q_SERVER_STOP,
|
||||
Q_UNKNOWN, /* Unknown command. */
|
||||
Q_COMMENT, /* Comments, ignored. */
|
||||
Q_COMMENT_WITH_COMMAND
|
||||
|
@ -200,6 +213,8 @@ const char *command_names[] = {
|
|||
"ping", "eval",
|
||||
"rpl_probe", "enable_rpl_parse",
|
||||
"disable_rpl_parse", "eval_result",
|
||||
"enable_query_log", "disable_query_log",
|
||||
"server_start", "server_stop",
|
||||
0
|
||||
};
|
||||
|
||||
|
@ -222,6 +237,7 @@ void reject_dump(const char* record_file, char* buf, int size);
|
|||
int close_connection(struct st_query* q);
|
||||
VAR* var_get(const char* var_name, const char** var_name_end, int raw);
|
||||
int eval_expr(VAR* v, const char* p, const char** p_end);
|
||||
static int read_server_arguments(const char* name);
|
||||
|
||||
/* Definitions for replace */
|
||||
|
||||
|
@ -243,6 +259,7 @@ static int initialize_replace_buffer(void);
|
|||
static void free_replace_buffer(void);
|
||||
static void do_eval(DYNAMIC_STRING* query_eval, const char* query);
|
||||
void str_to_file(const char* fname, char* str, int size);
|
||||
int do_server_op(struct st_query* q,const char* op);
|
||||
|
||||
struct st_replace *glob_replace;
|
||||
static char *out_buff;
|
||||
|
@ -250,13 +267,26 @@ static uint out_length;
|
|||
static int eval_result = 0;
|
||||
|
||||
/* Disable functions that only exist in MySQL 4.0 */
|
||||
#if MYSQL_VERSION_ID < 40000
|
||||
static void mysql_enable_rpl_parse(MYSQL* mysql __attribute__((unused))) {}
|
||||
static void mysql_disable_rpl_parse(MYSQL* mysql __attribute__((unused))) {}
|
||||
static int mysql_rpl_parse_enabled(MYSQL* mysql __attribute__((unused))) { return 1; }
|
||||
static int mysql_rpl_probe(MYSQL *mysql __attribute__((unused))) { return 1; }
|
||||
#if MYSQL_VERSION_ID < 40000 || defined(EMBEDDED_LIBRARY)
|
||||
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; }
|
||||
int mysql_rpl_probe(MYSQL *mysql __attribute__((unused))) { return 1; }
|
||||
#endif
|
||||
|
||||
#define MAX_SERVER_ARGS 20
|
||||
|
||||
static int embedded_server_arg_count=0;
|
||||
static char *embedded_server_args[MAX_SERVER_ARGS];
|
||||
|
||||
static const char *embedded_server_groups[] = {
|
||||
"server",
|
||||
"embedded",
|
||||
"mysqltest_SERVER",
|
||||
NullS
|
||||
};
|
||||
|
||||
|
||||
static void do_eval(DYNAMIC_STRING* query_eval, const char* query)
|
||||
{
|
||||
const char* p;
|
||||
|
@ -300,6 +330,8 @@ static void do_eval(DYNAMIC_STRING* query_eval, const char* query)
|
|||
static void close_cons()
|
||||
{
|
||||
DBUG_ENTER("close_cons");
|
||||
if (last_result)
|
||||
mysql_free_result(last_result);
|
||||
for (--next_con; next_con >= cons; --next_con)
|
||||
{
|
||||
mysql_close(&next_con->mysql);
|
||||
|
@ -310,17 +342,23 @@ static void close_cons()
|
|||
|
||||
static void close_files()
|
||||
{
|
||||
do
|
||||
DBUG_ENTER("close_files");
|
||||
for (; cur_file != file_stack ; cur_file--)
|
||||
{
|
||||
if (*cur_file != stdin && *cur_file)
|
||||
my_fclose(*cur_file,MYF(0));
|
||||
} while (cur_file-- != file_stack);
|
||||
}
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
static void free_used_memory()
|
||||
{
|
||||
uint i;
|
||||
DBUG_ENTER("free_used_memory");
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
if (manager)
|
||||
mysql_manager_close(manager);
|
||||
#endif
|
||||
close_cons();
|
||||
close_files();
|
||||
hash_free(&var_hash);
|
||||
|
@ -336,10 +374,13 @@ static void free_used_memory()
|
|||
if(var_reg[i].alloced_len)
|
||||
my_free(var_reg[i].str_val, MYF(MY_WME));
|
||||
}
|
||||
while (embedded_server_arg_count > 1)
|
||||
my_free(embedded_server_args[--embedded_server_arg_count],MYF(0));
|
||||
delete_dynamic(&q_lines);
|
||||
dynstr_free(&ds_res);
|
||||
my_free(pass,MYF(MY_ALLOW_ZERO_PTR));
|
||||
free_defaults(default_argv);
|
||||
mysql_server_end();
|
||||
my_end(MY_CHECK_ERROR);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
@ -361,6 +402,8 @@ static void die(const char* fmt, ...)
|
|||
exit(1);
|
||||
}
|
||||
|
||||
/* Note that we will get some memory leaks when calling this! */
|
||||
|
||||
static void abort_not_supported_test()
|
||||
{
|
||||
DBUG_ENTER("abort_not_supported_test");
|
||||
|
@ -415,13 +458,22 @@ int dyn_string_cmp(DYNAMIC_STRING* ds, const char* fname)
|
|||
DYNAMIC_STRING res_ds;
|
||||
DBUG_ENTER("dyn_string_cmp");
|
||||
|
||||
if (!my_stat(fname, &stat_info, MYF(MY_WME)))
|
||||
if (!test_if_hard_path(fname))
|
||||
{
|
||||
strxmov(eval_file, opt_basedir, fname, NullS);
|
||||
fn_format(eval_file, eval_file,"","",4);
|
||||
}
|
||||
else
|
||||
fn_format(eval_file, fname,"","",4);
|
||||
|
||||
if (!my_stat(eval_file, &stat_info, MYF(MY_WME)))
|
||||
die(NullS);
|
||||
if (!eval_result && stat_info.st_size != ds->length)
|
||||
DBUG_RETURN(2);
|
||||
if (!(tmp = (char*) my_malloc(stat_info.st_size + 1, MYF(MY_WME))))
|
||||
die(NullS);
|
||||
if ((fd = my_open(fname, O_RDONLY, MYF(MY_WME))) < 0)
|
||||
|
||||
if ((fd = my_open(eval_file, O_RDONLY, MYF(MY_WME))) < 0)
|
||||
die(NullS);
|
||||
if (my_read(fd, (byte*)tmp, stat_info.st_size, MYF(MY_WME|MY_NABP)))
|
||||
die(NullS);
|
||||
|
@ -570,9 +622,17 @@ int var_set(char* var_name, char* var_name_end, char* var_val,
|
|||
|
||||
int open_file(const char* name)
|
||||
{
|
||||
char buff[FN_REFLEN];
|
||||
if (!test_if_hard_path(name))
|
||||
{
|
||||
strxmov(buff, opt_basedir, name, NullS);
|
||||
name=buff;
|
||||
}
|
||||
fn_format(buff,name,"","",4);
|
||||
|
||||
if (*cur_file && cur_file == file_stack_end)
|
||||
die("Source directives are nesting too deep");
|
||||
if (!(*(cur_file+1) = my_fopen(name, O_RDONLY, MYF(MY_WME))))
|
||||
if (!(*(cur_file+1) = my_fopen(buff, O_RDONLY, MYF(MY_WME))))
|
||||
die(NullS);
|
||||
cur_file++;
|
||||
*++lineno=1;
|
||||
|
@ -580,6 +640,46 @@ int open_file(const char* name)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
int do_server_start(struct st_query* q)
|
||||
{
|
||||
return do_server_op(q,"start");
|
||||
}
|
||||
|
||||
int do_server_stop(struct st_query* q)
|
||||
{
|
||||
return do_server_op(q,"stop");
|
||||
}
|
||||
|
||||
int do_server_op(struct st_query* q,const char* op)
|
||||
{
|
||||
char* p=q->first_argument;
|
||||
char com_buf[256],*com_p;
|
||||
com_p=strmov(com_buf,op);
|
||||
com_p=strmov(com_p,"_exec ");
|
||||
if (!*p)
|
||||
die("Missing server name in server_%s\n",op);
|
||||
while (*p && !isspace(*p))
|
||||
{
|
||||
*com_p++=*p++;
|
||||
}
|
||||
*com_p++=' ';
|
||||
com_p=int10_to_str(manager_wait_timeout,com_p,10);
|
||||
*com_p++ = '\n';
|
||||
*com_p=0;
|
||||
if (mysql_manager_command(manager,com_buf,(int)(com_p-com_buf)))
|
||||
die("Error in command: %s(%d)",manager->last_error,manager->last_errno);
|
||||
while (!manager->eof)
|
||||
{
|
||||
if (mysql_manager_fetch_line(manager,com_buf,sizeof(com_buf)))
|
||||
die("Error fetching result line: %s(%d)", manager->last_error,
|
||||
manager->last_errno);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
int do_source(struct st_query* q)
|
||||
{
|
||||
char* p=q->first_argument, *name;
|
||||
|
@ -623,6 +723,18 @@ int var_query_set(VAR* v, const char* p, const char** p_end)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void var_copy(VAR* dest, VAR* src)
|
||||
{
|
||||
dest->int_val=src->int_val;
|
||||
dest->int_dirty=src->int_dirty;
|
||||
if (dest->alloced_len < src->alloced_len &&
|
||||
!(dest->str_val=my_realloc(dest->str_val,src->alloced_len,
|
||||
MYF(MY_WME))))
|
||||
die("Out of memory");
|
||||
dest->str_val_len=src->str_val_len;
|
||||
memcpy(dest->str_val,src->str_val,src->str_val_len);
|
||||
}
|
||||
|
||||
int eval_expr(VAR* v, const char* p, const char** p_end)
|
||||
{
|
||||
VAR* vp;
|
||||
|
@ -630,7 +742,7 @@ int eval_expr(VAR* v, const char* p, const char** p_end)
|
|||
{
|
||||
if ((vp = var_get(p,p_end,0)))
|
||||
{
|
||||
memcpy(v, vp, sizeof(*v));
|
||||
var_copy(v, vp);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -703,6 +815,7 @@ int do_system(struct st_query* q)
|
|||
if (system(expr_buf) && q->abort_on_error)
|
||||
die("system command '%s' failed", expr_buf);
|
||||
}
|
||||
var_free(&v);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -718,6 +831,7 @@ int do_echo(struct st_query* q)
|
|||
write(1, v.str_val, v.str_val_len);
|
||||
}
|
||||
write(1, "\n", 1);
|
||||
var_free(&v);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -743,14 +857,13 @@ int do_sync_with_master(struct st_query* q)
|
|||
die("At line %u: failed in %s: %d: %s", start_lineno, query_buf,
|
||||
mysql_errno(mysql), mysql_error(mysql));
|
||||
|
||||
if(!(res = mysql_store_result(mysql)))
|
||||
if(!(last_result = res = mysql_store_result(mysql)))
|
||||
die("line %u: mysql_store_result() retuned NULL", start_lineno);
|
||||
if(!(row = mysql_fetch_row(res)))
|
||||
die("line %u: empty result in %s", start_lineno, query_buf);
|
||||
if(!row[0])
|
||||
die("Error on slave while syncing with master");
|
||||
mysql_free_result(res);
|
||||
|
||||
mysql_free_result(res); last_result=0;
|
||||
if(rpl_parse)
|
||||
mysql_enable_rpl_parse(mysql);
|
||||
|
||||
|
@ -771,13 +884,13 @@ int do_save_master_pos()
|
|||
die("At line %u: failed in show master status: %d: %s", start_lineno,
|
||||
mysql_errno(mysql), mysql_error(mysql));
|
||||
|
||||
if(!(res = mysql_store_result(mysql)))
|
||||
if(!(last_result =res = mysql_store_result(mysql)))
|
||||
die("line %u: mysql_store_result() retuned NULL", start_lineno);
|
||||
if(!(row = mysql_fetch_row(res)))
|
||||
die("line %u: empty result in show master status", start_lineno);
|
||||
strncpy(master_pos.file, row[0], sizeof(master_pos.file));
|
||||
master_pos.pos = strtoul(row[1], (char**) 0, 10);
|
||||
mysql_free_result(res);
|
||||
mysql_free_result(res); last_result=0;
|
||||
|
||||
if(rpl_parse)
|
||||
mysql_enable_rpl_parse(mysql);
|
||||
|
@ -1067,18 +1180,18 @@ int close_connection(struct st_query* q)
|
|||
p++;
|
||||
*p = 0;
|
||||
|
||||
for(con = cons; con < next_con; con++)
|
||||
for (con = cons; con < next_con; con++)
|
||||
{
|
||||
if (!strcmp(con->name, name))
|
||||
{
|
||||
if(q->type == Q_DIRTY_CLOSE)
|
||||
if (q->type == Q_DIRTY_CLOSE)
|
||||
{
|
||||
if (con->mysql.net.vio)
|
||||
{
|
||||
if(con->mysql.net.vio)
|
||||
{
|
||||
vio_delete(con->mysql.net.vio);
|
||||
con->mysql.net.vio = 0;
|
||||
}
|
||||
vio_delete(con->mysql.net.vio);
|
||||
con->mysql.net.vio = 0;
|
||||
}
|
||||
}
|
||||
|
||||
mysql_close(&con->mysql);
|
||||
DBUG_RETURN(0);
|
||||
|
@ -1111,6 +1224,19 @@ char* safe_get_param(char* str, char** arg, const char* msg)
|
|||
DBUG_RETURN(str);
|
||||
}
|
||||
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
void init_manager()
|
||||
{
|
||||
if (!(manager=mysql_manager_init(0)))
|
||||
die("Failed in mysql_manager_init()");
|
||||
if (!mysql_manager_connect(manager,manager_host,manager_user,
|
||||
manager_pass,manager_port))
|
||||
die("Could not connect to MySQL manager: %s(%d)",manager->last_error,
|
||||
manager->last_errno);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
int safe_connect(MYSQL* con, const char* host, const char* user,
|
||||
const char* pass,
|
||||
const char* db, int port, const char* sock)
|
||||
|
@ -1167,6 +1293,8 @@ int do_connect(struct st_query* q)
|
|||
|
||||
if (!mysql_init(&next_con->mysql))
|
||||
die("Failed on mysql_init()");
|
||||
if (opt_compress)
|
||||
mysql_options(&next_con->mysql,MYSQL_OPT_COMPRESS,NullS);
|
||||
if (con_sock)
|
||||
con_sock=fn_format(buff, con_sock, TMPDIR, "",0);
|
||||
if (!con_db[0])
|
||||
|
@ -1194,10 +1322,10 @@ int do_done(struct st_query* q)
|
|||
parser.current_line = *--cur_block;
|
||||
}
|
||||
else
|
||||
{
|
||||
++parser.current_line;
|
||||
--cur_block;
|
||||
}
|
||||
{
|
||||
++parser.current_line;
|
||||
--cur_block;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1206,7 +1334,6 @@ int do_while(struct st_query* q)
|
|||
char* p=q->first_argument;
|
||||
const char* expr_start, *expr_end;
|
||||
VAR v;
|
||||
var_init(&v,0,0,0,0);
|
||||
if (cur_block == block_stack_end)
|
||||
die("Nesting too deeply");
|
||||
if (!*block_ok)
|
||||
|
@ -1223,6 +1350,7 @@ int do_while(struct st_query* q)
|
|||
expr_end = strrchr(expr_start, ')');
|
||||
if (!expr_end)
|
||||
die("missing ')' in while");
|
||||
var_init(&v,0,0,0,0);
|
||||
eval_expr(&v, ++expr_start, &expr_end);
|
||||
*cur_block++ = parser.current_line++;
|
||||
if (!v.int_val)
|
||||
|
@ -1232,6 +1360,7 @@ int do_while(struct st_query* q)
|
|||
}
|
||||
else
|
||||
*++block_ok = 1;
|
||||
var_free(&v);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1307,15 +1436,11 @@ int read_line(char* buf, int size)
|
|||
{
|
||||
if ((*cur_file) != stdin)
|
||||
my_fclose(*cur_file,MYF(0));
|
||||
|
||||
cur_file--;
|
||||
lineno--;
|
||||
if (cur_file == file_stack)
|
||||
return 1;
|
||||
else
|
||||
{
|
||||
cur_file--;
|
||||
lineno--;
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
switch(state) {
|
||||
|
@ -1504,20 +1629,28 @@ int read_query(struct st_query** q_ptr)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
struct option long_options[] =
|
||||
{
|
||||
{"debug", optional_argument, 0, '#'},
|
||||
{"database", required_argument, 0, 'D'},
|
||||
{"basedir", required_argument, 0, 'b'},
|
||||
{"big-test", no_argument, 0, 'B'},
|
||||
{"compress", no_argument, 0, 'C'},
|
||||
{"help", no_argument, 0, '?'},
|
||||
{"host", required_argument, 0, 'h'},
|
||||
{"manager-user",required_argument, 0, OPT_MANAGER_USER},
|
||||
{"manager-host",required_argument, 0, OPT_MANAGER_HOST},
|
||||
{"manager-password",required_argument,0,OPT_MANAGER_PASSWD},
|
||||
{"manager-port",required_argument,0,OPT_MANAGER_PORT},
|
||||
{"manager-wait-timeout",required_argument,0,OPT_MANAGER_WAIT_TIMEOUT},
|
||||
{"password", optional_argument, 0, 'p'},
|
||||
{"port", required_argument, 0, 'P'},
|
||||
{"quiet", no_argument, 0, 'q'},
|
||||
{"quiet", no_argument, 0, 's'},
|
||||
{"record", no_argument, 0, 'r'},
|
||||
{"result-file", required_argument, 0, 'R'},
|
||||
{"silent", no_argument, 0, 'q'},
|
||||
{"server-arg", required_argument, 0, 'A'},
|
||||
{"server-file", required_argument, 0, 'F'},
|
||||
{"silent", no_argument, 0, 's'},
|
||||
{"sleep", required_argument, 0, 'T'},
|
||||
{"socket", required_argument, 0, 'S'},
|
||||
{"test-file", required_argument, 0, 'x'},
|
||||
|
@ -1553,9 +1686,14 @@ void usage()
|
|||
-u, --user=... User for login.\n\
|
||||
-p[password], --password[=...]\n\
|
||||
Password to use when connecting to server.\n\
|
||||
-b, --basedir=... Basedir for tests\n\
|
||||
-B, --big-test Define BIG_TEST to 1\n\
|
||||
-C, --compress Use the compressed server/client protocol\n\
|
||||
-D, --database=... Database to use.\n\
|
||||
-P, --port=... Port number to use for connection.\n\
|
||||
--server-arg=... Send enbedded server this as a paramenter\n\
|
||||
--server-file=... Read embedded server arguments from file\n\
|
||||
-s, --silent, --quiet Suppress all normal output.\n\
|
||||
-S, --socket=... Socket file to use for connection.\n\
|
||||
-t, --tmpdir=... Temporary directory where sockets are put\n\
|
||||
-T, --sleep=# Sleep always this many seconds on sleep commands\n\
|
||||
|
@ -1563,7 +1701,6 @@ void usage()
|
|||
-R, --result-file=... Read/Store result from/in this file.\n\
|
||||
-x, --test-file=... Read test from/in this file (default stdin).\n\
|
||||
-v, --verbose Write more.\n\
|
||||
-q, --quiet, --silent Suppress all normal output.\n\
|
||||
-V, --version Output version information and exit.\n\
|
||||
--no-defaults Don't read default options from any options file.\n\n");
|
||||
}
|
||||
|
@ -1576,12 +1713,12 @@ int parse_args(int argc, char **argv)
|
|||
load_defaults("my",load_default_groups,&argc,&argv);
|
||||
default_argv= argv;
|
||||
|
||||
while((c = getopt_long(argc, argv, "h:p::u:BP:D:S:R:x:t:T:#:?rvVq",
|
||||
long_options, &option_index)) != EOF)
|
||||
while ((c = getopt_long(argc, argv, "A:h:p::u:b:BCF:P:D:S:R:x:t:T:#:?rvVs",
|
||||
long_options, &option_index)) != EOF)
|
||||
{
|
||||
switch(c) {
|
||||
case '#':
|
||||
DBUG_PUSH(optarg ? optarg : "d:t:O,/tmp/mysqltest.trace");
|
||||
DBUG_PUSH(optarg ? optarg : "d:t:S:i:O,/tmp/mysqltest.trace");
|
||||
break;
|
||||
case 'v':
|
||||
verbose = 1;
|
||||
|
@ -1589,6 +1726,23 @@ int parse_args(int argc, char **argv)
|
|||
case 'r':
|
||||
record = 1;
|
||||
break;
|
||||
case (int)OPT_MANAGER_WAIT_TIMEOUT:
|
||||
manager_wait_timeout=atoi(optarg);
|
||||
break;
|
||||
case (int)OPT_MANAGER_PORT:
|
||||
manager_port=atoi(optarg);
|
||||
break;
|
||||
case (int)OPT_MANAGER_HOST:
|
||||
manager_host=optarg;
|
||||
break;
|
||||
case (int)OPT_MANAGER_USER:
|
||||
manager_user=optarg;
|
||||
break;
|
||||
case (int)OPT_MANAGER_PASSWD:
|
||||
my_free(manager_pass,MYF(MY_ALLOW_ZERO_PTR));
|
||||
manager_pass=my_strdup(optarg,MYF(MY_FAE));
|
||||
while (*optarg) *optarg++= 'x'; /* Destroy argument */
|
||||
break;
|
||||
case 'u':
|
||||
user = optarg;
|
||||
break;
|
||||
|
@ -1596,9 +1750,18 @@ int parse_args(int argc, char **argv)
|
|||
result_file = optarg;
|
||||
break;
|
||||
case 'x':
|
||||
if (!(*cur_file = my_fopen(optarg, O_RDONLY, MYF(MY_WME))))
|
||||
{
|
||||
char buff[FN_REFLEN];
|
||||
if (!test_if_hard_path(optarg))
|
||||
{
|
||||
strxmov(buff, opt_basedir, optarg, NullS);
|
||||
optarg=buff;
|
||||
}
|
||||
fn_format(buff,optarg,"","",4);
|
||||
if (!(*++cur_file = my_fopen(buff, O_RDONLY, MYF(MY_WME))))
|
||||
die("Could not open %s: errno = %d", optarg, errno);
|
||||
break;
|
||||
}
|
||||
case 'p':
|
||||
if (optarg)
|
||||
{
|
||||
|
@ -1609,9 +1772,15 @@ int parse_args(int argc, char **argv)
|
|||
else
|
||||
tty_password=1;
|
||||
break;
|
||||
case 'b':
|
||||
opt_basedir= optarg;
|
||||
break;
|
||||
case 'B':
|
||||
opt_big_test=1;
|
||||
break;
|
||||
case 'C':
|
||||
opt_compress=1;
|
||||
break;
|
||||
case 'P':
|
||||
port = atoi(optarg);
|
||||
break;
|
||||
|
@ -1624,7 +1793,7 @@ int parse_args(int argc, char **argv)
|
|||
case 'h':
|
||||
host = optarg;
|
||||
break;
|
||||
case 'q':
|
||||
case 's':
|
||||
silent = 1;
|
||||
break;
|
||||
case 't':
|
||||
|
@ -1633,6 +1802,24 @@ int parse_args(int argc, char **argv)
|
|||
case 'T':
|
||||
opt_sleep=atoi(optarg);
|
||||
break;
|
||||
case 'A':
|
||||
if (!embedded_server_arg_count)
|
||||
{
|
||||
embedded_server_arg_count=1;
|
||||
embedded_server_args[0]= (char*) "";
|
||||
}
|
||||
embedded_server_args[embedded_server_arg_count++]=
|
||||
my_strdup(optarg,MYF(MY_FAE));
|
||||
if (embedded_server_arg_count == MAX_SERVER_ARGS ||
|
||||
!embedded_server_args[embedded_server_arg_count-1])
|
||||
{
|
||||
die("Can't use server argument");
|
||||
}
|
||||
break;
|
||||
case 'F':
|
||||
if (read_server_arguments(optarg))
|
||||
die(NullS);
|
||||
break;
|
||||
case 'V':
|
||||
print_version();
|
||||
exit(0);
|
||||
|
@ -1640,6 +1827,7 @@ int parse_args(int argc, char **argv)
|
|||
usage();
|
||||
exit(1); /* Unknown option */
|
||||
default:
|
||||
fprintf(stderr,"Unknown option '%c'\n",c);
|
||||
usage();
|
||||
exit(1);
|
||||
}
|
||||
|
@ -1672,9 +1860,17 @@ char* safe_str_append(char* buf, const char* str, int size)
|
|||
void str_to_file(const char* fname, char* str, int size)
|
||||
{
|
||||
int fd;
|
||||
if ((fd = my_open(fname, O_WRONLY | O_CREAT | O_TRUNC,
|
||||
char buff[FN_REFLEN];
|
||||
if (!test_if_hard_path(fname))
|
||||
{
|
||||
strxmov(buff, opt_basedir, fname, NullS);
|
||||
fname=buff;
|
||||
}
|
||||
fn_format(buff,fname,"","",4);
|
||||
|
||||
if ((fd = my_open(buff, O_WRONLY | O_CREAT | O_TRUNC,
|
||||
MYF(MY_WME | MY_FFNF))) < 0)
|
||||
die("Could not open %s: errno = %d", fname, errno);
|
||||
die("Could not open %s: errno = %d", buff, errno);
|
||||
if (my_write(fd, (byte*)str, size, MYF(MY_WME|MY_FNABP)))
|
||||
die("write failed");
|
||||
my_close(fd, MYF(0));
|
||||
|
@ -1731,14 +1927,22 @@ int run_query(MYSQL* mysql, struct st_query* q, int flags)
|
|||
|
||||
if ((flags & QUERY_SEND) && mysql_send_query(mysql, query, query_len))
|
||||
die("At line %u: unable to send query '%s'", start_lineno, query);
|
||||
if(!(flags & QUERY_REAP))
|
||||
return 0;
|
||||
if ((flags & QUERY_SEND) && !disable_query_log)
|
||||
{
|
||||
dynstr_append_mem(ds,query,query_len);
|
||||
dynstr_append_mem(ds,";\n",2);
|
||||
}
|
||||
if (!(flags & QUERY_REAP))
|
||||
DBUG_RETURN(0);
|
||||
|
||||
if (mysql_read_query_result(mysql) ||
|
||||
(!(res = mysql_store_result(mysql)) && mysql_field_count(mysql)))
|
||||
(!(last_result = res = mysql_store_result(mysql)) &&
|
||||
mysql_field_count(mysql)))
|
||||
{
|
||||
if (q->require_file)
|
||||
{
|
||||
abort_not_supported_test();
|
||||
}
|
||||
if (q->abort_on_error)
|
||||
die("At line %u: query '%s' failed: %d: %s", start_lineno, query,
|
||||
mysql_errno(mysql), mysql_error(mysql));
|
||||
|
@ -1747,7 +1951,17 @@ int run_query(MYSQL* mysql, struct st_query* q, int flags)
|
|||
for (i=0 ; q->expected_errno[i] ; i++)
|
||||
{
|
||||
if ((q->expected_errno[i] == mysql_errno(mysql)))
|
||||
{
|
||||
if (i == 0 && q->expected_errno[1] == 0)
|
||||
{
|
||||
/* Only log error if there is one possible error */
|
||||
dynstr_append(ds,mysql_error(mysql));
|
||||
dynstr_append_mem(ds,"\n",1);
|
||||
}
|
||||
else
|
||||
dynstr_append(ds,"Got one of the listed errors\n");
|
||||
goto end; /* Ok */
|
||||
}
|
||||
}
|
||||
if (i)
|
||||
{
|
||||
|
@ -1839,6 +2053,7 @@ int run_query(MYSQL* mysql, struct st_query* q, int flags)
|
|||
|
||||
end:
|
||||
if (res) mysql_free_result(res);
|
||||
last_result=0;
|
||||
if (ds == &ds_tmp)
|
||||
dynstr_free(&ds_tmp);
|
||||
if(q->type == Q_EVAL)
|
||||
|
@ -1891,6 +2106,7 @@ static VAR* var_init(VAR* v, const char* name, int name_len, const char* val,
|
|||
die("Out of memory");
|
||||
|
||||
tmp_var->name = (name) ? (char*)tmp_var + sizeof(*tmp_var) : 0;
|
||||
tmp_var->alloced = (v == 0);
|
||||
|
||||
if(!(tmp_var->str_val = my_malloc(val_alloc_len, MYF(MY_WME))))
|
||||
die("Out of memory");
|
||||
|
@ -1909,7 +2125,8 @@ static VAR* var_init(VAR* v, const char* name, int name_len, const char* val,
|
|||
static void var_free(void* v)
|
||||
{
|
||||
my_free(((VAR*) v)->str_val, MYF(MY_WME));
|
||||
my_free((char*) v, MYF(MY_WME));
|
||||
if (((VAR*)v)->alloced)
|
||||
my_free((char*) v, MYF(MY_WME));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1935,17 +2152,6 @@ static void init_var_hash()
|
|||
var_from_env("BIG_TEST", opt_big_test ? "1" : "0");
|
||||
}
|
||||
|
||||
static const char *embedded_server_args[] = {
|
||||
"", /* XXX: argv[0] is program name - we should fix the API */
|
||||
"--datadir=.",
|
||||
"--language=/usr/local/mysql/share/mysql/english",
|
||||
"--skip-innodb",
|
||||
NullS
|
||||
};
|
||||
static const char *embedded_server_groups[] = {
|
||||
"mysql-test-server",
|
||||
NullS
|
||||
};
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
|
@ -1953,9 +2159,10 @@ int main(int argc, char** argv)
|
|||
struct st_query* q;
|
||||
my_bool require_file=0, q_send_flag=0;
|
||||
char save_file[FN_REFLEN];
|
||||
mysql_server_init(sizeof(embedded_server_args) / sizeof(char *) - 1,
|
||||
embedded_server_args, embedded_server_groups);
|
||||
MY_INIT(argv[0]);
|
||||
{
|
||||
DBUG_ENTER("main");
|
||||
DBUG_PROCESS(argv[0]);
|
||||
|
||||
save_file[0]=0;
|
||||
TMPDIR[0]=0;
|
||||
|
@ -1980,17 +2187,25 @@ int main(int argc, char** argv)
|
|||
*block_ok = 1;
|
||||
init_dynamic_string(&ds_res, "", 0, 65536);
|
||||
parse_args(argc, argv);
|
||||
if (mysql_server_init(embedded_server_arg_count,
|
||||
embedded_server_args,
|
||||
(char**) embedded_server_groups))
|
||||
die("Can't initialize MySQL server");
|
||||
init_var_hash();
|
||||
if (!*cur_file)
|
||||
*cur_file = stdin;
|
||||
if (cur_file == file_stack)
|
||||
*++cur_file = stdin;
|
||||
*lineno=1;
|
||||
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
init_manager();
|
||||
#endif
|
||||
if (!( mysql_init(&cur_con->mysql)))
|
||||
die("Failed in mysql_init()");
|
||||
if (opt_compress)
|
||||
mysql_options(&cur_con->mysql,MYSQL_OPT_COMPRESS,NullS);
|
||||
cur_con->name = my_strdup("default", MYF(MY_WME));
|
||||
if (!cur_con->name)
|
||||
die("Out of memory");
|
||||
|
||||
|
||||
if (safe_connect(&cur_con->mysql, host,
|
||||
user, pass, db, port, unix_sock))
|
||||
die("Failed in mysql_real_connect(): %s", mysql_error(&cur_con->mysql));
|
||||
|
@ -2012,8 +2227,14 @@ int main(int argc, char** argv)
|
|||
case Q_RPL_PROBE: do_rpl_probe(q); break;
|
||||
case Q_ENABLE_RPL_PARSE: do_enable_rpl_parse(q); break;
|
||||
case Q_DISABLE_RPL_PARSE: do_disable_rpl_parse(q); break;
|
||||
case Q_ENABLE_QUERY_LOG: disable_query_log=0; break;
|
||||
case Q_DISABLE_QUERY_LOG: disable_query_log=1; break;
|
||||
case Q_SOURCE: do_source(q); break;
|
||||
case Q_SLEEP: do_sleep(q); break;
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
case Q_SERVER_START: do_server_start(q); break;
|
||||
case Q_SERVER_STOP: do_server_stop(q); break;
|
||||
#endif
|
||||
case Q_INC: do_inc(q); break;
|
||||
case Q_DEC: do_dec(q); break;
|
||||
case Q_ECHO: do_echo(q); break;
|
||||
|
@ -2122,8 +2343,54 @@ int main(int argc, char** argv)
|
|||
free_used_memory();
|
||||
exit(error ? 1 : 0);
|
||||
return error ? 1 : 0; /* Keep compiler happy */
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Read arguments for embedded server and put them into
|
||||
embedded_server_args_count and embedded_server_args[]
|
||||
*/
|
||||
|
||||
|
||||
static int read_server_arguments(const char* name)
|
||||
{
|
||||
char argument[1024],buff[FN_REFLEN], *str=0;
|
||||
FILE *file;
|
||||
|
||||
if (!test_if_hard_path(name))
|
||||
{
|
||||
strxmov(buff, opt_basedir, name, NullS);
|
||||
name=buff;
|
||||
}
|
||||
fn_format(buff,name,"","",4);
|
||||
|
||||
if (!embedded_server_arg_count)
|
||||
{
|
||||
embedded_server_arg_count=1;
|
||||
embedded_server_args[0]= (char*) ""; /* Progname */
|
||||
}
|
||||
if (!(file=my_fopen(buff, O_RDONLY | O_BINARY, MYF(MY_WME))))
|
||||
return 1;
|
||||
while (embedded_server_arg_count < MAX_SERVER_ARGS &&
|
||||
(str=fgets(argument,sizeof(argument), file)))
|
||||
{
|
||||
*(strend(str)-1)=0; /* Remove end newline */
|
||||
if (!(embedded_server_args[embedded_server_arg_count]=
|
||||
(char*) my_strdup(str,MYF(MY_WME))))
|
||||
{
|
||||
my_fclose(file,MYF(0));
|
||||
return 1;
|
||||
}
|
||||
embedded_server_arg_count++;
|
||||
}
|
||||
my_fclose(file,MYF(0));
|
||||
if (str)
|
||||
{
|
||||
fprintf(stderr,"Too many arguments in option file: %s\n",name);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Handle replacement of strings
|
||||
|
|
37
configure.in
|
@ -10,7 +10,7 @@ AM_CONFIG_HEADER(config.h)
|
|||
PROTOCOL_VERSION=10
|
||||
DOT_FRM_VERSION=6
|
||||
# See the libtool docs for information on how to do shared lib versions.
|
||||
SHARED_LIB_VERSION=10:0:0
|
||||
SHARED_LIB_VERSION=11:0:0
|
||||
|
||||
# Set all version vars based on $VERSION. How do we do this more elegant ?
|
||||
# Remember that regexps needs to quote [ and ] since this is run through m4
|
||||
|
@ -699,9 +699,9 @@ int main()
|
|||
AC_MSG_RESULT($atom_ops)
|
||||
|
||||
AC_ARG_WITH(pstack,
|
||||
[ --without-pstack Do not use the pstack backtrace library],
|
||||
[USE_PSTACK=$withval],
|
||||
[USE_PSTACK=yes])
|
||||
[ --with-pstack Use the pstack backtrace library],
|
||||
[ USE_PSTACK=$withval ],
|
||||
[ USE_PSTACK=no ])
|
||||
pstack_libs=
|
||||
pstack_dirs=
|
||||
if test "$USE_PSTACK" = yes -a "$IS_LINUX" = "true" -a "$BASE_MACHINE_TYPE" = "i386" -a "$with_mit_threads" = "no"
|
||||
|
@ -717,7 +717,9 @@ dnl I have no idea if this is a good test - can not find docs for libiberty
|
|||
if test x"$have_libiberty" = xyes -a x"$have_libbfd" = xyes
|
||||
then
|
||||
pstack_dirs='$(top_srcdir)'/pstack
|
||||
pstack_libs="$pstack_dirs/libpstack.a -lbfd -liberty"
|
||||
pstack_libs="../pstack/libpstack.a -lbfd -liberty"
|
||||
# We must link staticly when using pstack
|
||||
with_mysqld_ldflags="-all-static"
|
||||
AC_SUBST([pstack_dirs])
|
||||
AC_SUBST([pstack_libs])
|
||||
AC_DEFINE([USE_PSTACK])
|
||||
|
@ -1750,17 +1752,20 @@ AC_ARG_WITH(embedded-server,
|
|||
)
|
||||
|
||||
AC_ARG_WITH(extra-tools,
|
||||
[ --without-extra-tools Skip building utilites in the tools \
|
||||
directory.],
|
||||
[ --without-extra-tools Skip building utilites in the tools directory.],
|
||||
[with_tools=$withval],
|
||||
[with_tools=yes]
|
||||
)
|
||||
|
||||
tools_dirs=""
|
||||
if test "$with_tools" = "yes"
|
||||
then
|
||||
tools_dirs="tools"
|
||||
else
|
||||
tools_dirs=""
|
||||
if test "$THREAD_SAFE_CLIENT" = "no"
|
||||
then
|
||||
echo "Warning: extra-tools disabled because --enable-thread-safe-client wasn't used"
|
||||
else
|
||||
tools_dirs="tools"
|
||||
fi
|
||||
fi
|
||||
AC_SUBST(tools_dirs)
|
||||
|
||||
|
@ -2176,7 +2181,17 @@ EOF
|
|||
then
|
||||
sql_server_dirs="innobase $sql_server_dirs"
|
||||
echo "CONFIGURING FOR INNODB"
|
||||
(cd innobase && sh ./configure) \
|
||||
if test ! -d "innobase"; then
|
||||
# This should only happen when doing a VPATH build
|
||||
echo "NOTICE: I have to make the Innobase directory: `pwd`/innobase"
|
||||
mkdir "innobase" || exit 1
|
||||
fi
|
||||
rel_srcdir=
|
||||
case "$srcdir" in
|
||||
/* ) rel_srcdir="$srcdir" ;;
|
||||
* ) rel_srcdir="../$srcdir" ;;
|
||||
esac
|
||||
(cd innobase && sh $rel_srcdir/innobase/configure) \
|
||||
|| AC_MSG_ERROR([could not configure INNODB])
|
||||
|
||||
echo "END OF INNODB CONFIGURATION"
|
||||
|
|
|
@ -20,16 +20,11 @@
|
|||
#define RESOLVE_VERSION "2.0"
|
||||
|
||||
#include <my_global.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#ifndef HAVE_BROKEN_NETINET_INCLUDES
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <m_ctype.h>
|
||||
#include <my_net.h>
|
||||
#include <my_sys.h>
|
||||
#include <m_string.h>
|
||||
#include <netdb.h>
|
||||
#include <getopt.h>
|
||||
|
||||
#if !defined(_AIX) && !defined(HAVE_UNIXWARE7_THREADS) && !defined(HAVE_UNIXWARE7_POSIX) && !defined(h_errno)
|
||||
|
|
|
@ -62,6 +62,7 @@ int heap_write(HP_INFO *info, const byte *record)
|
|||
info->update|=HA_STATE_AKTIV;
|
||||
DBUG_RETURN(0);
|
||||
err:
|
||||
DBUG_PRINT("info",("Duplicate key: %d",key));
|
||||
info->errkey= key;
|
||||
do
|
||||
{
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
# MA 02111-1307, USA
|
||||
|
||||
BUILT_SOURCES = mysql_version.h m_ctype.h my_config.h
|
||||
pkginclude_HEADERS = dbug.h m_string.h my_sys.h mysql.h mysql_com.h \
|
||||
mysqld_error.h my_list.h \
|
||||
pkginclude_HEADERS = dbug.h m_string.h my_sys.h my_list.h \
|
||||
mysql.h mysql_com.h mysqld_error.h mysql_embed.h \
|
||||
my_pthread.h my_no_pthread.h raid.h errmsg.h \
|
||||
my_global.h my_net.h \
|
||||
sslopt-case.h sslopt-longopts.h sslopt-usage.h \
|
||||
|
@ -28,7 +28,7 @@ noinst_HEADERS = config-win.h \
|
|||
my_dir.h mysys_err.h my_base.h \
|
||||
my_nosys.h my_alarm.h queues.h \
|
||||
my_tree.h hash.h thr_alarm.h thr_lock.h \
|
||||
getopt.h t_ctype.h violite.h \
|
||||
getopt.h t_ctype.h violite.h md5.h \
|
||||
mysql_version.h.in
|
||||
|
||||
# mysql_version.h are generated
|
||||
|
|
|
@ -57,6 +57,8 @@ extern CHARSET_INFO *default_charset_info;
|
|||
extern CHARSET_INFO *find_compiled_charset(uint cs_number);
|
||||
extern CHARSET_INFO *find_compiled_charset_by_name(const char *name);
|
||||
extern CHARSET_INFO compiled_charsets[];
|
||||
extern uint compiled_charset_number(const char *name);
|
||||
extern const char *compiled_charset_name(uint charset_number);
|
||||
|
||||
#define MY_CHARSET_UNDEFINED 0
|
||||
#define MY_CHARSET_CURRENT (default_charset_info->number)
|
||||
|
|
|
@ -453,8 +453,7 @@ typedef SOCKET_SIZE_TYPE size_socket;
|
|||
/* Some things that this system doesn't have */
|
||||
|
||||
#define ONLY_OWN_DATABASES /* We are using only databases by monty */
|
||||
#define NO_PISAM /* Not needed anymore */
|
||||
#define NO_MISAM /* Not needed anymore */
|
||||
#define HAVE_ISAM /* TO BE DELETED */
|
||||
#define NO_HASH /* Not needed anymore */
|
||||
#ifdef __WIN__
|
||||
#define NO_DIR_LIBRARY /* Not standar dir-library */
|
||||
|
@ -654,6 +653,7 @@ typedef off_t os_off_t;
|
|||
#define socket_errno WSAGetLastError()
|
||||
#define SOCKET_EINTR WSAEINTR
|
||||
#define SOCKET_EAGAIN WSAEINPROGRESS
|
||||
#define SOCKET_EWOULDBLOCK WSAEINPROGRESS
|
||||
#define SOCKET_ENFILE ENFILE
|
||||
#define SOCKET_EMFILE EMFILE
|
||||
#elif defined(OS2)
|
||||
|
@ -965,4 +965,13 @@ typedef union {
|
|||
#define statistic_add(V,C,L) (V)+=(C)
|
||||
#endif
|
||||
|
||||
/* Macros to make switching between C and C++ mode easier */
|
||||
#ifdef __cplusplus
|
||||
#define C_MODE_START extern "C" {
|
||||
#define C_MODE_END }
|
||||
#else
|
||||
#define C_MODE_START
|
||||
#define C_MODE_END
|
||||
#endif
|
||||
|
||||
#endif /* _global_h */
|
||||
|
|
|
@ -15,14 +15,20 @@
|
|||
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
||||
MA 02111-1307, USA */
|
||||
|
||||
/* thread safe version of some common functions */
|
||||
/*
|
||||
thread safe version of some common functions:
|
||||
my_inet_ntoa
|
||||
|
||||
/* for thread safe my_inet_ntoa */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
This file is also used to make handling of sockets and ioctl()
|
||||
portable accross systems.
|
||||
|
||||
#if !defined(MSDOS) && !defined(__WIN__) && !defined(__BEOS__)
|
||||
*/
|
||||
|
||||
#ifndef _my_net_h
|
||||
#define _my_net_h
|
||||
C_MODE_START
|
||||
|
||||
#include <errno.h>
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
|
@ -32,10 +38,35 @@ extern "C" {
|
|||
#ifdef HAVE_ARPA_INET_H
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
#endif /* !defined(MSDOS) && !defined(__WIN__) */
|
||||
#ifdef HAVE_POLL
|
||||
#include <sys/poll.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_IOCTL_H
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
|
||||
#if !defined(MSDOS) && !defined(__WIN__) && !defined(HAVE_BROKEN_NETINET_INCLUDES) && !defined(__BEOS__)
|
||||
#include <netinet/in_systm.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/ip.h>
|
||||
#if !defined(alpha_linux_port)
|
||||
#include <netinet/tcp.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__EMX__)
|
||||
#include <sys/ioctl.h>
|
||||
#define ioctlsocket(A,B,C) ioctl((A),(B),(void *)(C),sizeof(*(C)))
|
||||
#undef HAVE_FCNTL
|
||||
#endif /* defined(__EMX__) */
|
||||
|
||||
#if defined(MSDOS) || defined(__WIN__)
|
||||
#define O_NONBLOCK 1 /* For emulation of fcntl() */
|
||||
#endif
|
||||
|
||||
/* Thread safe or portable version of some functions */
|
||||
|
||||
void my_inet_ntoa(struct in_addr in, char *buf);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
C_MODE_END
|
||||
#endif
|
||||
|
|
|
@ -59,6 +59,9 @@ 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_RAID 64 /* Support for RAID (not the "Johnson&Johnson"-s one ;) */
|
||||
#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() */
|
||||
#define MY_LINK_WARNING 32 /* my_redel() gives warning if links */
|
||||
#define MY_COPYTIME 64 /* my_redel() copys time */
|
||||
|
@ -90,6 +93,16 @@ extern int NEAR my_errno; /* Last error in mysys */
|
|||
#define ME_COLOUR2 ((2 << ME_HIGHBYTE))
|
||||
#define ME_COLOUR3 ((3 << ME_HIGHBYTE))
|
||||
|
||||
/* Bits in last argument to fn_format */
|
||||
#define MY_REPLACE_DIR 1 /* replace dir in name with 'dir' */
|
||||
#define MY_REPLACE_EXT 2 /* replace extension with 'ext' */
|
||||
#define MY_UNPACK_FILENAME 4 /* Unpack name (~ -> home) */
|
||||
#define MY_PACK_FILENAME 8 /* Pack name (home -> ~) */
|
||||
#define MY_RESOLVE_SYMLINKS 16 /* Resolve all symbolic links */
|
||||
#define MY_RETURN_REAL_PATH 32 /* return full path for file */
|
||||
#define MY_SAFE_PATH 64 /* Return NULL if too long path */
|
||||
#define MY_RELATIVE_PATH 128 /* name is relative to 'dir' */
|
||||
|
||||
/* My seek flags */
|
||||
#define MY_SEEK_SET 0
|
||||
#define MY_SEEK_CUR 1
|
||||
|
@ -106,7 +119,8 @@ extern int NEAR my_errno; /* Last error in mysys */
|
|||
#define MY_WAIT_FOR_USER_TO_FIX_PANIC 60 /* in seconds */
|
||||
#define MY_WAIT_GIVE_USER_A_MESSAGE 10 /* Every 10 times of prev */
|
||||
#define MIN_COMPRESS_LENGTH 50 /* Don't compress small bl. */
|
||||
#define KEYCACHE_BLOCK_SIZE 1024
|
||||
#define DEFAULT_KEYCACHE_BLOCK_SIZE 1024
|
||||
#define MAX_KEYCACHE_BLOCK_SIZE 16384
|
||||
|
||||
/* root_alloc flags */
|
||||
#define MY_KEEP_PREALLOC 1
|
||||
|
@ -190,9 +204,10 @@ extern char *get_charsets_dir(char *buf);
|
|||
/* statistics */
|
||||
extern ulong _my_cache_w_requests,_my_cache_write,_my_cache_r_requests,
|
||||
_my_cache_read;
|
||||
extern ulong _my_blocks_used,_my_blocks_changed;
|
||||
extern ulong _my_blocks_used,_my_blocks_changed;
|
||||
extern uint key_cache_block_size;
|
||||
extern ulong my_file_opened,my_stream_opened, my_tmp_file_created;
|
||||
extern my_bool key_cache_inited;
|
||||
extern my_bool key_cache_inited, my_init_done;
|
||||
|
||||
/* Point to current my_message() */
|
||||
extern void (*my_sigtstp_cleanup)(void),
|
||||
|
@ -467,12 +482,12 @@ extern uint dirname_part(my_string to,const char *name);
|
|||
extern uint dirname_length(const char *name);
|
||||
#define base_name(A) (A+dirname_length(A))
|
||||
extern int test_if_hard_path(const char *dir_name);
|
||||
extern char *convert_dirname(my_string name);
|
||||
extern char *convert_dirname(char *to, const char *from, const char *from_end);
|
||||
extern void to_unix_path(my_string name);
|
||||
extern my_string fn_ext(const char *name);
|
||||
extern my_string fn_same(my_string toname,const char *name,int flag);
|
||||
extern my_string fn_format(my_string to,const char *name,const char *dsk,
|
||||
const char *form,int flag);
|
||||
extern my_string fn_format(my_string to,const char *name,const char *dir,
|
||||
const char *form, uint flag);
|
||||
extern size_s strlength(const char *str);
|
||||
extern void pack_dirname(my_string to,const char *from);
|
||||
extern uint unpack_dirname(my_string to,const char *from);
|
||||
|
@ -602,6 +617,7 @@ my_bool my_compress(byte *, ulong *, ulong *);
|
|||
my_bool my_uncompress(byte *, ulong *, ulong *);
|
||||
byte *my_compress_alloc(const byte *packet, ulong *len, ulong *complen);
|
||||
ulong checksum(const byte *mem, uint count);
|
||||
uint my_bit_log2(ulong value);
|
||||
|
||||
#if defined(_MSC_VER) && !defined(__WIN__)
|
||||
extern void sleep(int sec);
|
||||
|
|
|
@ -46,6 +46,11 @@ extern "C" {
|
|||
/* Max extra space to use when sorting keys */
|
||||
#define MI_MAX_TEMP_LENGTH 256*1024L*1024L
|
||||
|
||||
/* Possible values for myisam_block_size (must be power of 2) */
|
||||
#define MI_KEY_BLOCK_LENGTH 1024 /* default key block length */
|
||||
#define MI_MIN_KEY_BLOCK_LENGTH 1024 /* Min key block length */
|
||||
#define MI_MAX_KEY_BLOCK_LENGTH 16384
|
||||
|
||||
#define mi_portable_sizeof_char_ptr 8
|
||||
|
||||
typedef uint32 ha_checksum;
|
||||
|
@ -192,7 +197,7 @@ extern uint myisam_block_size;
|
|||
extern my_bool myisam_flush,myisam_delay_key_write,myisam_single_user;
|
||||
extern my_bool myisam_concurrent_insert;
|
||||
extern my_off_t myisam_max_temp_length,myisam_max_extra_temp_length;
|
||||
extern uint myisam_bulk_insert_tree_size;
|
||||
extern ulong myisam_bulk_insert_tree_size;
|
||||
|
||||
/* Prototypes for myisam-functions */
|
||||
|
||||
|
|
|
@ -34,6 +34,13 @@ extern "C" {
|
|||
|
||||
#define MYRG_NAME_EXT ".MRG"
|
||||
|
||||
/* In which table to INSERT rows */
|
||||
#define MERGE_INSERT_DISABLED 0
|
||||
#define MERGE_INSERT_TO_FIRST 1
|
||||
#define MERGE_INSERT_TO_LAST 2
|
||||
|
||||
extern TYPELIB merge_insert_method;
|
||||
|
||||
/* Param to/from myrg_info */
|
||||
|
||||
typedef struct st_mymerge_info /* Struct from h_info */
|
||||
|
@ -44,7 +51,7 @@ typedef struct st_mymerge_info /* Struct from h_info */
|
|||
ulonglong data_file_length;
|
||||
uint reclength; /* Recordlength */
|
||||
int errkey; /* With key was dupplicated on err */
|
||||
uint options; /* HA_OPTIONS_... used */
|
||||
uint options; /* HA_OPTION_... used */
|
||||
} MYMERGE_INFO;
|
||||
|
||||
typedef struct st_myrg_table_info
|
||||
|
@ -56,6 +63,7 @@ typedef struct st_myrg_table_info
|
|||
typedef struct st_myrg_info
|
||||
{
|
||||
MYRG_TABLE *open_tables,*current_table,*end_table,*last_used_table;
|
||||
uint merge_insert_method;
|
||||
ulonglong records; /* records in tables */
|
||||
ulonglong del; /* Removed records */
|
||||
ulonglong data_file_length;
|
||||
|
@ -81,10 +89,11 @@ extern int myrg_rkey(MYRG_INFO *file,byte *buf,int inx,const byte *key,
|
|||
extern int myrg_rrnd(MYRG_INFO *file,byte *buf,ulonglong pos);
|
||||
extern int myrg_rsame(MYRG_INFO *file,byte *record,int inx);
|
||||
extern int myrg_update(MYRG_INFO *file,const byte *old,byte *new_rec);
|
||||
extern int myrg_write(MYRG_INFO *info,byte *rec);
|
||||
extern int myrg_status(MYRG_INFO *file,MYMERGE_INFO *x,int flag);
|
||||
extern int myrg_lock_database(MYRG_INFO *file,int lock_type);
|
||||
extern int myrg_create(const char *name,const char **table_names,
|
||||
my_bool fix_names);
|
||||
extern int myrg_create(const char *name, const char **table_names,
|
||||
uint insert_method, my_bool fix_names);
|
||||
extern int myrg_extra(MYRG_INFO *file,enum ha_extra_function function);
|
||||
extern ha_rows myrg_records_in_range(MYRG_INFO *info,int inx,
|
||||
const byte *start_key,uint start_key_len,
|
||||
|
|
168
include/mysql.h
|
@ -26,11 +26,9 @@
|
|||
#undef __WIN__
|
||||
#endif
|
||||
|
||||
#ifndef MYSQL_SERVER
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef _global_h /* If not standard header */
|
||||
#include <sys/types.h>
|
||||
|
@ -48,32 +46,15 @@ typedef char my_bool;
|
|||
#endif
|
||||
typedef char * gptr;
|
||||
|
||||
#ifndef ST_USED_MEM_DEFINED
|
||||
#define ST_USED_MEM_DEFINED
|
||||
typedef struct st_used_mem { /* struct for once_alloc */
|
||||
struct st_used_mem *next; /* Next block in use */
|
||||
unsigned int left; /* memory left in block */
|
||||
unsigned int size; /* size of block */
|
||||
} USED_MEM;
|
||||
typedef struct st_mem_root {
|
||||
USED_MEM *free;
|
||||
USED_MEM *used;
|
||||
USED_MEM *pre_alloc;
|
||||
unsigned int min_malloc;
|
||||
unsigned int block_size;
|
||||
|
||||
void (*error_handler)(void);
|
||||
} MEM_ROOT;
|
||||
#endif
|
||||
|
||||
#ifndef my_socket_defined
|
||||
#ifdef __WIN__
|
||||
#define my_socket SOCKET
|
||||
#else
|
||||
typedef int my_socket;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif /* __WIN__ */
|
||||
#endif /* my_socket_defined */
|
||||
#endif /* _global_h */
|
||||
|
||||
#include "mysql_com.h"
|
||||
#include "mysql_version.h"
|
||||
|
||||
|
@ -90,12 +71,14 @@ extern char *mysql_unix_port;
|
|||
typedef struct st_mysql_field {
|
||||
char *name; /* Name of column */
|
||||
char *table; /* Table of column if column was a field */
|
||||
char *org_table; /* Org table name if table was an alias */
|
||||
char *db; /* Database for table */
|
||||
char *def; /* Default value (set by mysql_list_fields) */
|
||||
enum enum_field_types type; /* Type of field. Se mysql_com.h for types */
|
||||
unsigned int length; /* Width of column */
|
||||
unsigned int max_length; /* Max width of selected set */
|
||||
unsigned long length; /* Width of column */
|
||||
unsigned long max_length; /* Max width of selected set */
|
||||
unsigned int flags; /* Div flags */
|
||||
unsigned int decimals; /* Number of decimals in field */
|
||||
enum enum_field_types type; /* Type of field. Se mysql_com.h for types */
|
||||
} MYSQL_FIELD;
|
||||
|
||||
typedef char **MYSQL_ROW; /* return data as array of strings */
|
||||
|
@ -118,6 +101,24 @@ typedef struct st_mysql_rows {
|
|||
|
||||
typedef MYSQL_ROWS *MYSQL_ROW_OFFSET; /* offset to current row */
|
||||
|
||||
#ifndef ST_USED_MEM_DEFINED
|
||||
#define ST_USED_MEM_DEFINED
|
||||
typedef struct st_used_mem { /* struct for once_alloc */
|
||||
struct st_used_mem *next; /* Next block in use */
|
||||
unsigned int left; /* memory left in block */
|
||||
unsigned int size; /* size of block */
|
||||
} USED_MEM;
|
||||
typedef struct st_mem_root {
|
||||
USED_MEM *free;
|
||||
USED_MEM *used;
|
||||
USED_MEM *pre_alloc;
|
||||
unsigned int min_malloc;
|
||||
unsigned int block_size;
|
||||
|
||||
void (*error_handler)(void);
|
||||
} MEM_ROOT;
|
||||
#endif
|
||||
|
||||
typedef struct st_mysql_data {
|
||||
my_ulonglong rows;
|
||||
unsigned int fields;
|
||||
|
@ -134,6 +135,7 @@ struct st_mysql_options {
|
|||
char *ssl_cert; /* PEM cert file */
|
||||
char *ssl_ca; /* PEM CA file */
|
||||
char *ssl_capath; /* PEM directory of CA-s? */
|
||||
char *ssl_cipher; /* cipher to use */
|
||||
my_bool use_ssl; /* if to use SSL or not */
|
||||
my_bool compress,named_pipe;
|
||||
/*
|
||||
|
@ -175,25 +177,30 @@ typedef struct st_mysql {
|
|||
gptr connector_fd; /* ConnectorFd for SSL */
|
||||
char *host,*user,*passwd,*unix_socket,*server_version,*host_info,
|
||||
*info,*db;
|
||||
struct charset_info_st *charset;
|
||||
MYSQL_FIELD *fields;
|
||||
MEM_ROOT field_alloc;
|
||||
my_ulonglong affected_rows;
|
||||
my_ulonglong insert_id; /* id if insert on table with NEXTNR */
|
||||
my_ulonglong extra_info; /* Used by mysqlshow */
|
||||
unsigned long thread_id; /* Id for connection in server */
|
||||
unsigned long packet_length;
|
||||
unsigned int port,client_flag,server_capabilities;
|
||||
unsigned int protocol_version;
|
||||
unsigned int field_count;
|
||||
unsigned int server_status;
|
||||
unsigned long thread_id; /* Id for connection in server */
|
||||
my_ulonglong affected_rows;
|
||||
my_ulonglong insert_id; /* id if insert on table with NEXTNR */
|
||||
my_ulonglong extra_info; /* Used by mysqlshow */
|
||||
unsigned long packet_length;
|
||||
unsigned int server_language;
|
||||
struct st_mysql_options options;
|
||||
enum mysql_status status;
|
||||
MYSQL_FIELD *fields;
|
||||
MEM_ROOT field_alloc;
|
||||
my_bool free_me; /* If free in mysql_close */
|
||||
my_bool reconnect; /* set to 1 if automatic reconnect */
|
||||
struct st_mysql_options options;
|
||||
char scramble_buff[9];
|
||||
struct charset_info_st *charset;
|
||||
unsigned int server_language;
|
||||
|
||||
/*
|
||||
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;
|
||||
|
@ -201,41 +208,60 @@ typedef struct st_mysql {
|
|||
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;
|
||||
/*
|
||||
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;
|
||||
} MYSQL;
|
||||
|
||||
|
||||
typedef struct st_mysql_res {
|
||||
my_ulonglong row_count;
|
||||
unsigned int field_count, current_field;
|
||||
MYSQL_FIELD *fields;
|
||||
MYSQL_DATA *data;
|
||||
MYSQL_ROWS *data_cursor;
|
||||
MEM_ROOT field_alloc;
|
||||
MYSQL_ROW row; /* If unbuffered read */
|
||||
MYSQL_ROW current_row; /* buffer to current row */
|
||||
unsigned long *lengths; /* column lengths of current row */
|
||||
MYSQL *handle; /* for unbuffered reads */
|
||||
my_bool eof; /* Used my mysql_fetch_row */
|
||||
MEM_ROOT field_alloc;
|
||||
unsigned int field_count, current_field;
|
||||
MYSQL_ROW row; /* If unbuffered read */
|
||||
MYSQL_ROW current_row; /* buffer to current row */
|
||||
my_bool eof; /* Used by mysql_fetch_row */
|
||||
} 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
|
||||
|
||||
|
||||
|
||||
typedef struct st_mysql_manager
|
||||
{
|
||||
Vio* vio;
|
||||
char *host,*user,*passwd;
|
||||
unsigned int port;
|
||||
my_bool free_me;
|
||||
my_bool eof;
|
||||
int cmd_status;
|
||||
int last_errno;
|
||||
char* net_buf,*net_buf_pos,*net_data_end;
|
||||
int net_buf_size;
|
||||
char last_error[MAX_MYSQL_MANAGER_ERR];
|
||||
} MYSQL_MANAGER;
|
||||
|
||||
/* Set up and bring down the server; to ensure that applications will
|
||||
* work when linked against either the standard client library or the
|
||||
* embedded server library, these functions should be called. */
|
||||
void mysql_server_init(int argc, const char **argv, const char **groups);
|
||||
void mysql_server_end();
|
||||
int mysql_server_init(int argc, char **argv, char **groups);
|
||||
void mysql_server_end(void);
|
||||
|
||||
/* Set up and bring down a thread; these function should be called
|
||||
* for each thread in an application which opens at least one MySQL
|
||||
* connection. All uses of the connection(s) should be between these
|
||||
* function calls. */
|
||||
my_bool mysql_thread_init();
|
||||
void mysql_thread_end();
|
||||
my_bool mysql_thread_init(void);
|
||||
void mysql_thread_end(void);
|
||||
|
||||
/* Functions to get information from the MYSQL and MYSQL_RES structures */
|
||||
/* Should definitely be used if one uses shared libraries */
|
||||
|
@ -261,7 +287,7 @@ const char * STDCALL mysql_character_set_name(MYSQL *mysql);
|
|||
MYSQL * STDCALL mysql_init(MYSQL *mysql);
|
||||
int STDCALL mysql_ssl_set(MYSQL *mysql, const char *key,
|
||||
const char *cert, const char *ca,
|
||||
const char *capath);
|
||||
const char *capath, const char *cipher);
|
||||
int STDCALL mysql_ssl_clear(MYSQL *mysql);
|
||||
my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user,
|
||||
const char *passwd, const char *db);
|
||||
|
@ -276,20 +302,20 @@ void STDCALL mysql_close(MYSQL *sock);
|
|||
int STDCALL mysql_select_db(MYSQL *mysql, const char *db);
|
||||
int STDCALL mysql_query(MYSQL *mysql, const char *q);
|
||||
int STDCALL mysql_send_query(MYSQL *mysql, const char *q,
|
||||
unsigned int length);
|
||||
unsigned long length);
|
||||
int STDCALL mysql_read_query_result(MYSQL *mysql);
|
||||
int STDCALL mysql_real_query(MYSQL *mysql, const char *q,
|
||||
unsigned int length);
|
||||
unsigned long length);
|
||||
/* perform query on master */
|
||||
int STDCALL mysql_master_query(MYSQL *mysql, const char *q,
|
||||
unsigned int length);
|
||||
unsigned long length);
|
||||
int STDCALL mysql_master_send_query(MYSQL *mysql, const char *q,
|
||||
unsigned int length);
|
||||
unsigned long length);
|
||||
/* perform query on slave */
|
||||
int STDCALL mysql_slave_query(MYSQL *mysql, const char *q,
|
||||
unsigned int length);
|
||||
unsigned long length);
|
||||
int STDCALL mysql_slave_send_query(MYSQL *mysql, const char *q,
|
||||
unsigned int length);
|
||||
unsigned long length);
|
||||
|
||||
/*
|
||||
enable/disable parsing of all queries to decide if they go on master or
|
||||
|
@ -368,7 +394,18 @@ char * STDCALL mysql_odbc_escape_string(MYSQL *mysql,
|
|||
unsigned long *length));
|
||||
void STDCALL myodbc_remove_escape(MYSQL *mysql,char *name);
|
||||
unsigned int STDCALL mysql_thread_safe(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);
|
||||
#define mysql_reload(mysql) mysql_refresh((mysql),REFRESH_GRANT)
|
||||
|
||||
#ifdef USE_OLD_FUNCTIONS
|
||||
|
@ -376,14 +413,21 @@ 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)
|
||||
#define HAVE_MYSQL_REAL_CONNECT
|
||||
#endif
|
||||
|
||||
#define HAVE_MYSQL_REAL_CONNECT
|
||||
/*
|
||||
The following functions are mainly exported because of mysqlbinlog;
|
||||
They are not for general usage
|
||||
*/
|
||||
|
||||
int simple_command(MYSQL *mysql,enum enum_server_command command,
|
||||
const char *arg, unsigned long length, my_bool skipp_check);
|
||||
unsigned long net_safe_read(MYSQL* mysql);
|
||||
|
||||
#ifndef MYSQL_SERVER
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif /* _mysql_h */
|
||||
|
|
|
@ -104,26 +104,31 @@ enum enum_server_command {COM_SLEEP,COM_QUIT,COM_INIT_DB,COM_QUERY,
|
|||
struct st_vio; /* Only C */
|
||||
typedef struct st_vio Vio;
|
||||
|
||||
#define MAX_BLOB_WIDTH 8192 // Default width for blob
|
||||
|
||||
typedef struct st_net {
|
||||
Vio* vio;
|
||||
my_socket fd; /* For Perl DBI/dbd */
|
||||
int fcntl;
|
||||
unsigned char *buff,*buff_end,*write_pos,*read_pos;
|
||||
my_socket fd; /* For Perl DBI/dbd */
|
||||
unsigned long max_packet;
|
||||
int fcntl;
|
||||
unsigned int last_errno,timeout,pkt_nr,compress_pkt_nr;
|
||||
char last_error[MYSQL_ERRMSG_SIZE];
|
||||
unsigned int last_errno,max_packet,timeout,pkt_nr;
|
||||
unsigned char error;
|
||||
my_bool return_errno,compress;
|
||||
my_bool no_send_ok; /* needed if we are doing several
|
||||
queries in one command ( as in LOAD TABLE ... FROM MASTER ),
|
||||
and do not want to confuse the client with OK at the wrong time
|
||||
*/
|
||||
/*
|
||||
The following variable is set if we are doing several queries in one
|
||||
command ( as in LOAD TABLE ... FROM MASTER ),
|
||||
and do not want to confuse the client with OK at the wrong time
|
||||
*/
|
||||
unsigned long remain_in_buf,length, buf_length, where_b;
|
||||
unsigned int *return_status;
|
||||
unsigned char reading_or_writing;
|
||||
char save_char;
|
||||
my_bool no_send_ok;
|
||||
} NET;
|
||||
|
||||
#define packet_error ((unsigned int) -1)
|
||||
#define packet_error (~(unsigned long) 0)
|
||||
|
||||
enum enum_field_types { FIELD_TYPE_DECIMAL, FIELD_TYPE_TINY,
|
||||
FIELD_TYPE_SHORT, FIELD_TYPE_LONG,
|
||||
|
@ -165,6 +170,11 @@ int net_write_command(NET *net,unsigned char command,const char *packet,
|
|||
int net_real_write(NET *net,const char *packet,unsigned long len);
|
||||
unsigned long my_net_read(NET *net);
|
||||
|
||||
/* The following function is not meant for normal usage */
|
||||
struct sockaddr;
|
||||
int my_connect(my_socket s, const struct sockaddr *name, unsigned int namelen,
|
||||
unsigned int timeout);
|
||||
|
||||
struct rand_struct {
|
||||
unsigned long seed1,seed2,max_value;
|
||||
double max_value_dbl;
|
||||
|
@ -193,7 +203,7 @@ typedef struct st_udf_init
|
|||
{
|
||||
my_bool maybe_null; /* 1 if function can return NULL */
|
||||
unsigned int decimals; /* for real functions */
|
||||
unsigned int max_length; /* For string functions */
|
||||
unsigned long max_length; /* For string functions */
|
||||
char *ptr; /* free pointer for function data */
|
||||
my_bool const_item; /* 0 if result is independent of arguments */
|
||||
} UDF_INIT;
|
||||
|
|
30
include/mysql_embed.h
Normal file
|
@ -0,0 +1,30 @@
|
|||
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult 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; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
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 */
|
||||
|
||||
/* Defines that are unique to the embedded version of MySQL */
|
||||
|
||||
#ifdef EMBEDDED_LIBRARY
|
||||
|
||||
/* Things we don't need in the embedded version of MySQL */
|
||||
|
||||
#undef HAVE_PSTACK /* No stacktrace */
|
||||
#undef HAVE_DLOPEN /* No udf functions */
|
||||
#undef HAVE_OPENSSL
|
||||
#undef HAVE_VIO
|
||||
#undef HAVE_ISAM
|
||||
|
||||
#define DONT_USE_RAID
|
||||
#endif /* EMBEDDED_LIBRARY */
|
|
@ -221,4 +221,5 @@
|
|||
#define ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT 1218
|
||||
#define ER_CANT_UPDATE_WITH_READLOCK 1219
|
||||
#define ER_MIXING_NOT_ALLOWED 1220
|
||||
#define ER_ERROR_MESSAGES 221
|
||||
#define ER_DUP_ARGUMENT 1221
|
||||
#define ER_ERROR_MESSAGES 222
|
||||
|
|
|
@ -39,4 +39,10 @@
|
|||
my_free(opt_ssl_ca, MYF(MY_ALLOW_ZERO_PTR));
|
||||
opt_ssl_ca = my_strdup(optarg, MYF(0));
|
||||
break;
|
||||
case OPT_SSL_CIPHER:
|
||||
opt_use_ssl = 1; /* true */
|
||||
my_free(opt_ssl_cipher, MYF(MY_ALLOW_ZERO_PTR));
|
||||
opt_ssl_cipher = my_strdup(optarg, MYF(0));
|
||||
break;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -22,10 +22,12 @@
|
|||
#define OPT_SSL_CERT 202
|
||||
#define OPT_SSL_CA 203
|
||||
#define OPT_SSL_CAPATH 204
|
||||
#define OPT_SSL_CIPHER 205
|
||||
{"ssl", no_argument, 0, OPT_SSL_SSL},
|
||||
{"ssl-key", required_argument, 0, OPT_SSL_KEY},
|
||||
{"ssl-cert", required_argument, 0, OPT_SSL_CERT},
|
||||
{"ssl-ca", required_argument, 0, OPT_SSL_CA},
|
||||
{"ssl-capath", required_argument, 0, OPT_SSL_CAPATH},
|
||||
{"ssl-cipher", required_argument, 0, OPT_SSL_CIPHER},
|
||||
|
||||
#endif /* HAVE_OPENSSL */
|
||||
|
|
|
@ -21,5 +21,6 @@
|
|||
--ssl-key X509 key in PEM format (implies --ssl)\n\
|
||||
--ssl-cert X509 cert in PEM format (implies --ssl)\n\
|
||||
--ssl-ca CA file in PEM format (check OpenSSL docs, implies --ssl)\n\
|
||||
--ssl-capath CA directory (check OpenSSL docs, implies --ssl)");
|
||||
--ssl-capath CA directory (check OpenSSL docs, implies --ssl)\n\
|
||||
--ssl-cipher SSL cipher to use (implies --ssl)");
|
||||
#endif
|
||||
|
|
|
@ -21,4 +21,5 @@ static char *opt_ssl_key = 0;
|
|||
static char *opt_ssl_cert = 0;
|
||||
static char *opt_ssl_ca = 0;
|
||||
static char *opt_ssl_capath = 0;
|
||||
static char *opt_ssl_cipher = 0;
|
||||
#endif
|
||||
|
|
|
@ -33,67 +33,59 @@ extern "C" {
|
|||
#endif /* __cplusplus */
|
||||
|
||||
enum enum_vio_type { VIO_CLOSED, VIO_TYPE_TCPIP, VIO_TYPE_SOCKET,
|
||||
VIO_TYPE_NAMEDPIPE, VIO_TYPE_SSL};
|
||||
VIO_TYPE_NAMEDPIPE, VIO_TYPE_SSL};
|
||||
|
||||
#ifndef __WIN__
|
||||
#define HANDLE void *
|
||||
#endif
|
||||
|
||||
Vio* vio_new(my_socket sd,
|
||||
enum enum_vio_type type,
|
||||
my_bool localhost);
|
||||
Vio* vio_new(my_socket sd, enum enum_vio_type type, my_bool localhost);
|
||||
#ifdef __WIN__
|
||||
Vio* vio_new_win32pipe(HANDLE hPipe);
|
||||
Vio* vio_new_win32pipe(HANDLE hPipe);
|
||||
#endif
|
||||
void vio_delete(Vio* vio);
|
||||
void vio_delete(Vio* vio);
|
||||
|
||||
#ifdef EMBEDDED_LIBRARY
|
||||
void vio_reset(Vio *vio);
|
||||
#else
|
||||
void vio_reset(Vio* vio, enum enum_vio_type type,
|
||||
my_socket sd, HANDLE hPipe,
|
||||
my_bool localhost);
|
||||
my_socket sd, HANDLE hPipe, my_bool localhost);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* vio_read and vio_write should have the same semantics
|
||||
* as read(2) and write(2).
|
||||
*/
|
||||
int vio_read( Vio* vio,
|
||||
gptr buf, int size);
|
||||
int vio_write( Vio* vio,
|
||||
const gptr buf,
|
||||
int size);
|
||||
int vio_read(Vio *vio, gptr buf, int size);
|
||||
int vio_write(Vio *vio, const gptr buf, int size);
|
||||
/*
|
||||
* Whenever the socket is set to blocking mode or not.
|
||||
*/
|
||||
int vio_blocking( Vio* vio,
|
||||
my_bool onoff);
|
||||
my_bool vio_is_blocking( Vio* vio);
|
||||
int vio_blocking(Vio *vio, my_bool onoff);
|
||||
my_bool vio_is_blocking(Vio *vio);
|
||||
/*
|
||||
* setsockopt TCP_NODELAY at IPPROTO_TCP level, when possible.
|
||||
*/
|
||||
int vio_fastsend( Vio* vio);
|
||||
int vio_fastsend(Vio *vio);
|
||||
/*
|
||||
* setsockopt SO_KEEPALIVE at SOL_SOCKET level, when possible.
|
||||
*/
|
||||
int vio_keepalive( Vio* vio,
|
||||
my_bool onoff);
|
||||
int vio_keepalive(Vio *vio, my_bool onoff);
|
||||
/*
|
||||
* Whenever we should retry the last read/write operation.
|
||||
*/
|
||||
my_bool vio_should_retry( Vio* vio);
|
||||
my_bool vio_should_retry(Vio *vio);
|
||||
/*
|
||||
* When the workday is over...
|
||||
*/
|
||||
int vio_close(Vio* vio);
|
||||
int vio_close(Vio* vio);
|
||||
/*
|
||||
* Short text description of the socket for those, who are curious..
|
||||
*/
|
||||
const char* vio_description( Vio* vio);
|
||||
const char* vio_description(Vio *vio);
|
||||
|
||||
/* Return the type of the connection */
|
||||
enum enum_vio_type vio_type(Vio* vio);
|
||||
enum enum_vio_type vio_type(Vio* vio);
|
||||
|
||||
/* Return last error number */
|
||||
int vio_errno(Vio*vio);
|
||||
|
@ -116,9 +108,8 @@ my_bool vio_poll_read(Vio *vio,uint timeout);
|
|||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* vio_violite_h_ */
|
||||
#ifdef HAVE_VIO
|
||||
#ifndef DONT_MAP_VIO
|
||||
|
||||
#if defined(HAVE_VIO) && !defined(DONT_MAP_VIO)
|
||||
#define vio_delete(vio) (vio)->viodelete(vio)
|
||||
#define vio_errno(vio) (vio)->vioerrno(vio)
|
||||
#define vio_read(vio, buf, size) (vio)->read(vio,buf,size)
|
||||
|
@ -132,9 +123,7 @@ my_bool vio_poll_read(Vio *vio,uint timeout);
|
|||
#define vio_peer_addr(vio, buf) (vio)->peer_addr(vio, buf)
|
||||
#define vio_in_addr(vio, in) (vio)->in_addr(vio, in)
|
||||
#define vio_poll_read(vio,timeout) (vio)->poll_read(vio,timeout)
|
||||
#endif /* !DONT_MAP_VIO */
|
||||
#endif /* HAVE_VIO */
|
||||
|
||||
#endif /* defined(HAVE_VIO) && !defined(DONT_MAP_VIO) */
|
||||
|
||||
#ifdef HAVE_OPENSSL
|
||||
#define HEADER_DES_LOCL_H dummy_something
|
||||
|
@ -142,17 +131,16 @@ my_bool vio_poll_read(Vio *vio,uint timeout);
|
|||
#include <openssl/err.h>
|
||||
#include "my_net.h" /* needed because of struct in_addr */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
void vio_ssl_delete(Vio* vio);
|
||||
void vio_ssl_delete(Vio* vio);
|
||||
|
||||
int vio_ssl_read(Vio* vio,gptr buf, int size);
|
||||
int vio_ssl_write(Vio* vio,const gptr buf,int size);
|
||||
int vio_ssl_blocking(Vio* vio,my_bool onoff);
|
||||
my_bool vio_ssl_is_blocking(Vio* vio);
|
||||
int vio_ssl_read(Vio* vio,gptr buf, int size);
|
||||
int vio_ssl_write(Vio* vio,const gptr buf,int size);
|
||||
int vio_ssl_blocking(Vio* vio,my_bool onoff);
|
||||
my_bool vio_ssl_is_blocking(Vio* vio);
|
||||
|
||||
/* setsockopt TCP_NODELAY at IPPROTO_TCP level, when possible. */
|
||||
int vio_ssl_fastsend(Vio* vio);
|
||||
|
@ -170,8 +158,6 @@ void vio_ssl_in_addr(Vio *vio, struct in_addr *in);
|
|||
/* Return 1 if there is data to be read */
|
||||
my_bool vio_ssl_poll_read(Vio *vio,uint timeout);
|
||||
|
||||
#ifdef HAVE_OPENSSL
|
||||
|
||||
/* Single copy for server */
|
||||
struct st_VioSSLAcceptorFd
|
||||
{
|
||||
|
@ -182,9 +168,6 @@ struct st_VioSSLAcceptorFd
|
|||
state_connect = 1,
|
||||
state_accept = 2
|
||||
};
|
||||
// BIO* bio_;
|
||||
// char desc_[100];
|
||||
// Vio* sd_;
|
||||
|
||||
/* function pointers which are only once for SSL server
|
||||
Vio*(*sslaccept)(struct st_VioSSLAcceptorFd*,Vio*); */
|
||||
|
@ -197,24 +180,27 @@ struct st_VioSSLConnectorFd
|
|||
SSL_METHOD* ssl_method_;
|
||||
/* function pointers which are only once for SSL client */
|
||||
};
|
||||
void sslaccept(struct st_VioSSLAcceptorFd*, Vio*);
|
||||
void sslconnect(struct st_VioSSLConnectorFd*, Vio*);
|
||||
void sslaccept(struct st_VioSSLAcceptorFd*, Vio*, long timeout);
|
||||
void sslconnect(struct st_VioSSLConnectorFd*, Vio*, long timeout);
|
||||
|
||||
#else /* HAVE_OPENSSL */
|
||||
/* This dummy is required to maintain proper size of st_mysql in mysql.h */
|
||||
struct st_VioSSLConnectorFd {};
|
||||
#endif /* HAVE_OPENSSL */
|
||||
struct st_VioSSLConnectorFd *new_VioSSLConnectorFd(
|
||||
const char* key_file,const char* cert_file,const char* ca_file,const char* ca_path);
|
||||
struct st_VioSSLAcceptorFd *new_VioSSLAcceptorFd(
|
||||
const char* key_file,const char* cert_file,const char* ca_file,const char* ca_path);
|
||||
struct st_VioSSLConnectorFd
|
||||
*new_VioSSLConnectorFd(const char* key_file, const char* cert_file,
|
||||
const char* ca_file, const char* ca_path,
|
||||
const char* cipher);
|
||||
struct st_VioSSLAcceptorFd
|
||||
*new_VioSSLAcceptorFd(const char* key_file, const char* cert_file,
|
||||
const char* ca_file,const char* ca_path,
|
||||
const char* cipher);
|
||||
Vio* new_VioSSL(struct st_VioSSLAcceptorFd* fd, Vio* sd,int state);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* HAVE_OPENSSL */
|
||||
|
||||
/* This enumerator is used in parser - should be always visible */
|
||||
enum SSL_type {SSL_TYPE_NONE, SSL_TYPE_ANY, SSL_TYPE_X509, SSL_TYPE_SPECIFIED};
|
||||
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
/* This structure is for every connection on both sides */
|
||||
struct st_vio
|
||||
|
@ -229,27 +215,25 @@ struct st_vio
|
|||
char desc[30]; /* String description */
|
||||
#ifdef HAVE_VIO
|
||||
/* function pointers. They are similar for socket/SSL/whatever */
|
||||
void (*viodelete)(Vio*);
|
||||
int(*vioerrno)(Vio*);
|
||||
int(*read)(Vio*, gptr, int);
|
||||
int(*write)(Vio*, gptr, int);
|
||||
int(*vioblocking)(Vio*, my_bool);
|
||||
my_bool(*is_blocking)(Vio*);
|
||||
int(*viokeepalive)(Vio*, my_bool);
|
||||
int(*fastsend)(Vio*);
|
||||
my_bool(*peer_addr)(Vio*, gptr);
|
||||
void(*in_addr)(Vio*, struct in_addr*);
|
||||
my_bool(*should_retry)(Vio*);
|
||||
int(*vioclose)(Vio*);
|
||||
my_bool(*poll_read)(Vio*,uint);
|
||||
void (*viodelete)(Vio*);
|
||||
int (*vioerrno)(Vio*);
|
||||
int (*read)(Vio*, gptr, int);
|
||||
int (*write)(Vio*, gptr, int);
|
||||
int (*vioblocking)(Vio*, my_bool);
|
||||
my_bool (*is_blocking)(Vio*);
|
||||
int (*viokeepalive)(Vio*, my_bool);
|
||||
int (*fastsend)(Vio*);
|
||||
my_bool (*peer_addr)(Vio*, gptr);
|
||||
void (*in_addr)(Vio*, struct in_addr*);
|
||||
my_bool (*should_retry)(Vio*);
|
||||
int (*vioclose)(Vio*);
|
||||
my_bool (*poll_read)(Vio*,uint);
|
||||
|
||||
#ifdef HAVE_OPENSSL
|
||||
BIO* bio_;
|
||||
SSL* ssl_;
|
||||
my_bool open_;
|
||||
char *ssl_cip_;
|
||||
#endif /* HAVE_OPENSSL */
|
||||
#endif /* HAVE_VIO */
|
||||
};
|
||||
#endif /* EMBEDDED_LIBRARY */
|
||||
|
||||
#endif /* vio_violite_h_ */
|
||||
|
|
|
@ -55,5 +55,7 @@ noinst_HEADERS = btr0btr.h btr0btr.ic btr0cur.h btr0cur.ic \
|
|||
ut0dbg.h ut0lst.h ut0mem.h ut0mem.ic ut0rnd.h ut0rnd.ic \
|
||||
ut0sort.h ut0ut.h ut0ut.ic
|
||||
|
||||
EXTRA_DIST = Makefile.i
|
||||
|
||||
# Don't update the files from bitkeeper
|
||||
%::SCCS/s.%
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
libsdir = ../libs
|
||||
|
||||
INCLUDES = -I../../include -I../include
|
||||
INCLUDES = -I$(srcdir)/../include -I$(srcdir)/../../include -I../../include
|
||||
|
||||
# Don't update the files from bitkeeper
|
||||
%::SCCS/s.%
|
||||
|
|
|
@ -170,7 +170,9 @@ mem_heap_alloc(
|
|||
buf = (byte*)buf + MEM_FIELD_HEADER_SIZE;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef UNIV_SET_MEM_TO_ZERO
|
||||
memset(buf, '\0', n);
|
||||
#endif
|
||||
return(buf);
|
||||
}
|
||||
|
||||
|
@ -494,8 +496,14 @@ mem_alloc_func(
|
|||
)
|
||||
{
|
||||
#ifndef UNIV_MEM_DEBUG
|
||||
void* buf;
|
||||
|
||||
return(mem_area_alloc(n, mem_comm_pool));
|
||||
buf = mem_area_alloc(n, mem_comm_pool);
|
||||
|
||||
#ifdef UNIV_SET_MEM_TO_ZERO
|
||||
memset(buf, '\0', n);
|
||||
#endif
|
||||
return(buf);
|
||||
|
||||
#else
|
||||
|
||||
|
|
|
@ -160,6 +160,7 @@ os_fast_mutex_trylock(
|
|||
was reserved by another
|
||||
thread */
|
||||
os_fast_mutex_t* fast_mutex); /* in: mutex to acquire */
|
||||
#endif
|
||||
/**************************************************************
|
||||
Releases ownership of a fast mutex. */
|
||||
UNIV_INLINE
|
||||
|
@ -188,7 +189,6 @@ void
|
|||
os_fast_mutex_free(
|
||||
/*===============*/
|
||||
os_fast_mutex_t* fast_mutex); /* in: mutex to free */
|
||||
#endif
|
||||
|
||||
#ifndef UNIV_NONINL
|
||||
#include "os0sync.ic"
|
||||
|
|
|
@ -38,6 +38,7 @@ os_fast_mutex_trylock(
|
|||
return((ulint) pthread_mutex_trylock(fast_mutex));
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/**************************************************************
|
||||
Releases ownership of a fast mutex. */
|
||||
|
@ -53,4 +54,3 @@ os_fast_mutex_unlock(
|
|||
pthread_mutex_unlock(fast_mutex);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -70,6 +70,7 @@ extern ulint srv_n_rows_read;
|
|||
extern ibool srv_print_innodb_monitor;
|
||||
extern ibool srv_print_innodb_lock_monitor;
|
||||
extern ibool srv_print_innodb_tablespace_monitor;
|
||||
extern ibool srv_print_verbose_log;
|
||||
|
||||
extern ulint srv_n_spin_wait_rounds;
|
||||
extern ulint srv_spin_wait_delay;
|
||||
|
|
|
@ -61,8 +61,12 @@ subdirectory of 'mysql'. */
|
|||
/* DEBUG VERSION CONTROL
|
||||
===================== */
|
||||
|
||||
/* The following flag will make InnoDB to initialize
|
||||
all memory it allocates to zero. It hides Purify
|
||||
warnings about reading unallocated memory unless
|
||||
memory is read outside the allocated blocks. */
|
||||
/*
|
||||
#define UNIV_SYNC_DEBUG
|
||||
#define UNIV_INIT_MEM_TO_ZERO
|
||||
*/
|
||||
|
||||
/* Make a non-inline debug version */
|
||||
|
@ -72,7 +76,7 @@ subdirectory of 'mysql'. */
|
|||
#define UNIV_SEARCH_DEBUG
|
||||
|
||||
#define UNIV_IBUF_DEBUG
|
||||
|
||||
#define UNIV_SYNC_DEBUG
|
||||
#define UNIV_SYNC_PERF_STAT
|
||||
#define UNIV_SEARCH_PERF_STAT
|
||||
*/
|
||||
|
|
|
@ -26,12 +26,39 @@ int
|
|||
ut_memcmp(void* str1, void* str2, ulint n);
|
||||
|
||||
|
||||
void*
|
||||
ut_malloc(ulint n);
|
||||
/**************************************************************************
|
||||
Allocates memory. Sets it also to zero if UNIV_SET_MEM_TO_ZERO is
|
||||
defined and set_to_zero is TRUE. */
|
||||
|
||||
void*
|
||||
ut_malloc_low(
|
||||
/*==========*/
|
||||
/* out, own: allocated memory */
|
||||
ulint n, /* in: number of bytes to allocate */
|
||||
ibool set_to_zero); /* in: TRUE if allocated memory should be set
|
||||
to zero if UNIV_SET_MEM_TO_ZERO is defined */
|
||||
/**************************************************************************
|
||||
Allocates memory. Sets it also to zero if UNIV_SET_MEM_TO_ZERO is
|
||||
defined. */
|
||||
|
||||
void*
|
||||
ut_malloc(
|
||||
/*======*/
|
||||
/* out, own: allocated memory */
|
||||
ulint n); /* in: number of bytes to allocate */
|
||||
/**************************************************************************
|
||||
Frees a memory bloock allocated with ut_malloc. */
|
||||
|
||||
UNIV_INLINE
|
||||
void
|
||||
ut_free(void* ptr);
|
||||
ut_free(
|
||||
/*====*/
|
||||
void* ptr); /* in, own: memory block */
|
||||
/**************************************************************************
|
||||
Frees all allocated memory not freed yet. */
|
||||
|
||||
void
|
||||
ut_free_all_mem(void);
|
||||
/*=================*/
|
||||
|
||||
UNIV_INLINE
|
||||
char*
|
||||
|
|
|
@ -27,13 +27,6 @@ ut_memcmp(void* str1, void* str2, ulint n)
|
|||
return(memcmp(str1, str2, n));
|
||||
}
|
||||
|
||||
UNIV_INLINE
|
||||
void
|
||||
ut_free(void* ptr)
|
||||
{
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
UNIV_INLINE
|
||||
char*
|
||||
ut_strcpy(char* dest, char* sour)
|
||||
|
|
|
@ -2641,9 +2641,11 @@ logs_empty_and_mark_files_at_shutdown(void)
|
|||
dulint lsn;
|
||||
ulint arch_log_no;
|
||||
|
||||
ut_print_timestamp(stderr);
|
||||
fprintf(stderr, " InnoDB: Starting shutdown...\n");
|
||||
|
||||
if (srv_print_verbose_log)
|
||||
{
|
||||
ut_print_timestamp(stderr);
|
||||
fprintf(stderr, " InnoDB: Starting shutdown...\n");
|
||||
}
|
||||
/* Wait until the master thread and all other operations are idle: our
|
||||
algorithm only works if the server is idle at shutdown */
|
||||
loop:
|
||||
|
@ -2732,8 +2734,11 @@ loop:
|
|||
|
||||
fil_flush_file_spaces(FIL_TABLESPACE);
|
||||
|
||||
ut_print_timestamp(stderr);
|
||||
fprintf(stderr, " InnoDB: Shutdown completed\n");
|
||||
if (srv_print_verbose_log)
|
||||
{
|
||||
ut_print_timestamp(stderr);
|
||||
fprintf(stderr, " InnoDB: Shutdown completed\n");
|
||||
}
|
||||
}
|
||||
|
||||
/**********************************************************
|
||||
|
|
|
@ -170,7 +170,11 @@ mem_pool_create(
|
|||
|
||||
pool = ut_malloc(sizeof(mem_pool_t));
|
||||
|
||||
pool->buf = ut_malloc(size);
|
||||
/* We do not set the memory to zero (FALSE) in the pool,
|
||||
but only when allocated at a higher level in mem0mem.c.
|
||||
This is to avoid masking useful Purify warnings. */
|
||||
|
||||
pool->buf = ut_malloc_low(size, FALSE);
|
||||
pool->size = size;
|
||||
|
||||
mutex_create(&(pool->mutex));
|
||||
|
|
|
@ -422,7 +422,6 @@ os_mutex_free(
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
/*************************************************************
|
||||
Initializes an operating system fast mutex semaphore. */
|
||||
|
||||
|
@ -472,4 +471,3 @@ os_fast_mutex_free(
|
|||
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -120,6 +120,12 @@ ibool srv_print_innodb_monitor = FALSE;
|
|||
ibool srv_print_innodb_lock_monitor = FALSE;
|
||||
ibool srv_print_innodb_tablespace_monitor = FALSE;
|
||||
|
||||
/*
|
||||
Set the following to 0 if you want InnoDB to write messages on
|
||||
stderr on startup/shutdown
|
||||
*/
|
||||
ibool srv_print_verbose_log = TRUE;
|
||||
|
||||
/* The parameters below are obsolete: */
|
||||
|
||||
ibool srv_print_parsed_sql = FALSE;
|
||||
|
|
|
@ -888,9 +888,11 @@ innobase_start_or_create_for_mysql(void)
|
|||
|
||||
/* buf_debug_prints = TRUE; */
|
||||
|
||||
ut_print_timestamp(stderr);
|
||||
fprintf(stderr, " InnoDB: Started\n");
|
||||
|
||||
if (srv_print_verbose_log)
|
||||
{
|
||||
ut_print_timestamp(stderr);
|
||||
fprintf(stderr, " InnoDB: Started\n");
|
||||
}
|
||||
return((int) DB_SUCCESS);
|
||||
}
|
||||
|
||||
|
@ -916,5 +918,7 @@ innobase_shutdown_for_mysql(void)
|
|||
|
||||
logs_empty_and_mark_files_at_shutdown();
|
||||
|
||||
ut_free_all_mem();
|
||||
|
||||
return((int) DB_SUCCESS);
|
||||
}
|
||||
|
|
|
@ -14,30 +14,136 @@ Created 5/11/1994 Heikki Tuuri
|
|||
|
||||
#include "mem0mem.h"
|
||||
|
||||
|
||||
/* This struct is placed first in every allocated memory block */
|
||||
typedef struct ut_mem_block_struct ut_mem_block_t;
|
||||
|
||||
struct ut_mem_block_struct{
|
||||
UT_LIST_NODE_T(ut_mem_block_t) mem_block_list;/* mem block list node */
|
||||
};
|
||||
|
||||
|
||||
/* List of all memory blocks allocated from the operating system
|
||||
with malloc */
|
||||
UT_LIST_BASE_NODE_T(ut_mem_block_t) ut_mem_block_list;
|
||||
|
||||
os_fast_mutex_t ut_list_mutex; /* this protects the list */
|
||||
|
||||
ibool ut_mem_block_list_inited = FALSE;
|
||||
|
||||
/**************************************************************************
|
||||
Initializes the mem block list at database startup. */
|
||||
static
|
||||
void
|
||||
ut_mem_block_list_init(void)
|
||||
/*========================*/
|
||||
{
|
||||
os_fast_mutex_init(&ut_list_mutex);
|
||||
UT_LIST_INIT(ut_mem_block_list);
|
||||
ut_mem_block_list_inited = TRUE;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
Allocates memory. Sets it also to zero if UNIV_SET_MEM_TO_ZERO is
|
||||
defined and set_to_zero is TRUE. */
|
||||
|
||||
void*
|
||||
ut_malloc(ulint n)
|
||||
ut_malloc_low(
|
||||
/*==========*/
|
||||
/* out, own: allocated memory */
|
||||
ulint n, /* in: number of bytes to allocate */
|
||||
ibool set_to_zero) /* in: TRUE if allocated memory should be set
|
||||
to zero if UNIV_SET_MEM_TO_ZERO is defined */
|
||||
{
|
||||
void* ret;
|
||||
/*
|
||||
ret = VirtualAlloc(NULL, n, MEM_COMMIT, PAGE_READWRITE);
|
||||
*/
|
||||
|
||||
ret = malloc(n);
|
||||
ut_ad((sizeof(ut_mem_block_t) % 8) == 0); /* check alignment ok */
|
||||
|
||||
if (!ut_mem_block_list_inited) {
|
||||
ut_mem_block_list_init();
|
||||
}
|
||||
|
||||
os_fast_mutex_lock(&ut_list_mutex);
|
||||
|
||||
ret = malloc(n + sizeof(ut_mem_block_t));
|
||||
|
||||
if (ret == NULL) {
|
||||
fprintf(stderr,
|
||||
"Innobase: Fatal error: cannot allocate memory!\n");
|
||||
fprintf(stderr,
|
||||
"Innobase: Cannot continue operation!\n");
|
||||
fprintf(stderr,
|
||||
"Innobase: Check if you can increase the swap file of your\n");
|
||||
fprintf(stderr,
|
||||
"Innobase: operating system.\n");
|
||||
"InnoDB: Fatal error: cannot allocate %lu bytes of\n"
|
||||
"InnoDB: memory with malloc!\n"
|
||||
"InnoDB: Operating system errno: %lu\n"
|
||||
"InnoDB: Cannot continue operation!\n"
|
||||
"InnoDB: Check if you should increase the swap file or\n"
|
||||
"InnoDB: ulimits of your operating system.\n", n, errno);
|
||||
|
||||
os_fast_mutex_unlock(&ut_list_mutex);
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return(ret);
|
||||
if (set_to_zero) {
|
||||
#ifdef UNIV_SET_MEM_TO_ZERO
|
||||
memset(ret, '\0', n + sizeof(ut_mem_block_t));
|
||||
#endif
|
||||
}
|
||||
|
||||
UT_LIST_ADD_FIRST(mem_block_list, ut_mem_block_list,
|
||||
((ut_mem_block_t*)ret));
|
||||
os_fast_mutex_unlock(&ut_list_mutex);
|
||||
|
||||
return((void*)((byte*)ret + sizeof(ut_mem_block_t)));
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
Allocates memory. Sets it also to zero if UNIV_SET_MEM_TO_ZERO is
|
||||
defined. */
|
||||
|
||||
void*
|
||||
ut_malloc(
|
||||
/*======*/
|
||||
/* out, own: allocated memory */
|
||||
ulint n) /* in: number of bytes to allocate */
|
||||
{
|
||||
return(ut_malloc_low(n, TRUE));
|
||||
}
|
||||
/**************************************************************************
|
||||
Frees a memory bloock allocated with ut_malloc. */
|
||||
|
||||
void
|
||||
ut_free(
|
||||
/*====*/
|
||||
void* ptr) /* in, own: memory block */
|
||||
{
|
||||
ut_mem_block_t* block;
|
||||
|
||||
block = (ut_mem_block_t*)((byte*)ptr - sizeof(ut_mem_block_t));
|
||||
|
||||
os_fast_mutex_lock(&ut_list_mutex);
|
||||
|
||||
UT_LIST_REMOVE(mem_block_list, ut_mem_block_list, block);
|
||||
free(block);
|
||||
|
||||
os_fast_mutex_unlock(&ut_list_mutex);
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
Frees all allocated memory not freed yet. */
|
||||
|
||||
void
|
||||
ut_free_all_mem(void)
|
||||
/*=================*/
|
||||
{
|
||||
ut_mem_block_t* block;
|
||||
|
||||
os_fast_mutex_lock(&ut_list_mutex);
|
||||
|
||||
while (block = UT_LIST_GET_FIRST(ut_mem_block_list)) {
|
||||
|
||||
UT_LIST_REMOVE(mem_block_list, ut_mem_block_list, block);
|
||||
free(block);
|
||||
}
|
||||
|
||||
os_fast_mutex_unlock(&ut_list_mutex);
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
|
|
|
@ -400,11 +400,7 @@ static int examine_log(my_string file_name, char **table_names)
|
|||
}
|
||||
to=isam_file_name;
|
||||
if (filepath)
|
||||
{
|
||||
strmov(isam_file_name,filepath);
|
||||
convert_dirname(isam_file_name);
|
||||
to=strend(isam_file_name);
|
||||
}
|
||||
to=convert_dirname(isam_file_name, filepath, NullS);
|
||||
strmov(to,pos);
|
||||
fn_ext(isam_file_name)[0]=0; /* Remove extension */
|
||||
}
|
||||
|
|
|
@ -71,11 +71,11 @@ link_sources:
|
|||
# keep only the stubs for safemalloc.c and debug.c
|
||||
#
|
||||
# A list of needed headers collected from the deps information 000213
|
||||
nh = global.h config-win32.h dbug.h errmsg.h global.h \
|
||||
nh = my_global.h config-win32.h dbug.h errmsg.h \
|
||||
m_ctype.h m_string.h \
|
||||
my_alarm.h my_config.h my_dir.h my_list.h my_net.h my_sys.h \
|
||||
mysql.h mysql_com.h mysql_version.h mysqld_error.h mysys_err.h \
|
||||
my_pthread.h thr_alarm.h violite.h hash.h
|
||||
mysql.h mysql_com.h mysql_version.h mysqld_error.h \
|
||||
mysys_err.h my_pthread.h thr_alarm.h violite.h hash.h
|
||||
# Get a list of the needed objects
|
||||
lobjs = $(mysysobjects1) $(dbugobjects) $(mystringsobjects)
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ noinst_PROGRAMS = conf_to_src
|
|||
CHARSET_OBJS=@CHARSET_OBJS@
|
||||
LTCHARSET_OBJS= ${CHARSET_OBJS:.o=.lo}
|
||||
|
||||
target_sources = libmysql.c net.c password.c \
|
||||
target_sources = libmysql.c net.c password.c manager.c \
|
||||
get_password.c errmsg.c
|
||||
|
||||
mystringsobjects = strmov.lo strxmov.lo strnmov.lo strmake.lo strend.lo \
|
||||
|
@ -56,7 +56,7 @@ mysysobjects1 = my_init.lo my_static.lo my_malloc.lo my_realloc.lo \
|
|||
thr_mutex.lo mulalloc.lo string.lo default.lo \
|
||||
my_compress.lo array.lo my_once.lo list.lo my_net.lo \
|
||||
charset.lo hash.lo mf_iocache.lo my_seek.lo \
|
||||
my_pread.lo mf_cache.lo my_vsnprintf.lo
|
||||
my_pread.lo mf_cache.lo my_vsnprintf.lo md5.lo
|
||||
|
||||
# Not needed in the minimum library
|
||||
mysysobjects2 = getopt.lo getopt1.lo getvar.lo my_lib.lo
|
||||
|
|
|
@ -91,10 +91,12 @@ static sig_handler pipe_sig_handler(int sig);
|
|||
static ulong mysql_sub_escape_string(CHARSET_INFO *charset_info, char *to,
|
||||
const char *from, ulong length);
|
||||
|
||||
void mysql_server_init(int argc __attribute__((unused)),
|
||||
const char **argv __attribute__((unused)),
|
||||
const char **groups __attribute__((unused)))
|
||||
{}
|
||||
int mysql_server_init(int argc __attribute__((unused)),
|
||||
char **argv __attribute__((unused)),
|
||||
char **groups __attribute__((unused)))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void mysql_server_end()
|
||||
{}
|
||||
|
@ -140,12 +142,12 @@ static MYSQL* spawn_init(MYSQL* parent, const char* host,
|
|||
* A modified version of connect(). connect2() allows you to specify
|
||||
* a timeout value, in seconds, that we should wait until we
|
||||
* derermine we can't connect to a particular host. If timeout is 0,
|
||||
* connect2() will behave exactly like connect().
|
||||
* my_connect() will behave exactly like connect().
|
||||
*
|
||||
* Base version coded by Steve Bernacki, Jr. <steve@navinet.net>
|
||||
*****************************************************************************/
|
||||
|
||||
static int connect2(my_socket s, const struct sockaddr *name, uint namelen,
|
||||
int my_connect(my_socket s, const struct sockaddr *name, uint namelen,
|
||||
uint timeout)
|
||||
{
|
||||
#if defined(__WIN__) || defined(OS2)
|
||||
|
@ -314,11 +316,11 @@ HANDLE create_named_pipe(NET *net, uint connect_timeout, char **arg_host,
|
|||
** or packet is an error message
|
||||
*****************************************************************************/
|
||||
|
||||
uint
|
||||
ulong
|
||||
net_safe_read(MYSQL *mysql)
|
||||
{
|
||||
NET *net= &mysql->net;
|
||||
uint len=0;
|
||||
ulong len=0;
|
||||
init_sigpipe_variables
|
||||
|
||||
/* Don't give sigpipe errors if the client doesn't want them */
|
||||
|
@ -336,7 +338,7 @@ net_safe_read(MYSQL *mysql)
|
|||
CR_NET_PACKET_TOO_LARGE:
|
||||
CR_SERVER_LOST);
|
||||
strmov(net->last_error,ER(net->last_errno));
|
||||
return(packet_error);
|
||||
return (packet_error);
|
||||
}
|
||||
if (net->read_pos[0] == 255)
|
||||
{
|
||||
|
@ -347,7 +349,7 @@ net_safe_read(MYSQL *mysql)
|
|||
pos+=2;
|
||||
len-=2;
|
||||
(void) strmake(net->last_error,(char*) pos,
|
||||
min(len,sizeof(net->last_error)-1));
|
||||
min((uint) len,(uint) sizeof(net->last_error)-1));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -438,7 +440,7 @@ static void free_rows(MYSQL_DATA *cur)
|
|||
|
||||
int
|
||||
simple_command(MYSQL *mysql,enum enum_server_command command, const char *arg,
|
||||
uint length, my_bool skipp_check)
|
||||
ulong length, my_bool skipp_check)
|
||||
{
|
||||
NET *net= &mysql->net;
|
||||
int result= -1;
|
||||
|
@ -669,8 +671,8 @@ mysql_free_result(MYSQL_RES *result)
|
|||
DBUG_PRINT("warning",("Not all rows in set were read; Ignoring rows"));
|
||||
for (;;)
|
||||
{
|
||||
uint pkt_len;
|
||||
if ((pkt_len=(uint) net_safe_read(result->handle)) == packet_error)
|
||||
ulong pkt_len;
|
||||
if ((pkt_len=net_safe_read(result->handle)) == packet_error)
|
||||
break;
|
||||
if (pkt_len == 1 && result->handle->net.read_pos[0] == 254)
|
||||
break; /* End of data */
|
||||
|
@ -695,7 +697,7 @@ mysql_free_result(MYSQL_RES *result)
|
|||
static const char *default_options[]=
|
||||
{"port","socket","compress","password","pipe", "timeout", "user",
|
||||
"init-command", "host", "database", "debug", "return-found-rows",
|
||||
"ssl-key" ,"ssl-cert" ,"ssl-ca" ,"ssl-capath",
|
||||
"ssl-key" ,"ssl-cert" ,"ssl-ca" ,"ssl-capath", "ssl-cipher"
|
||||
"character-set-dir", "default-character-set", "interactive-timeout",
|
||||
"connect_timeout", "replication-probe", "enable-reads-from-master",
|
||||
"repl-parse-query",
|
||||
|
@ -864,13 +866,14 @@ unpack_fields(MYSQL_DATA *data,MEM_ROOT *alloc,uint fields,
|
|||
MYSQL_FIELD *field,*result;
|
||||
DBUG_ENTER("unpack_fields");
|
||||
|
||||
field=result=(MYSQL_FIELD*) alloc_root(alloc,sizeof(MYSQL_FIELD)*fields);
|
||||
field=result=(MYSQL_FIELD*) alloc_root(alloc,
|
||||
(uint) sizeof(MYSQL_FIELD)*fields);
|
||||
if (!result)
|
||||
DBUG_RETURN(0);
|
||||
|
||||
for (row=data->data; row ; row = row->next,field++)
|
||||
{
|
||||
field->table= strdup_root(alloc,(char*) row->data[0]);
|
||||
field->org_table= field->table= strdup_root(alloc,(char*) row->data[0]);
|
||||
field->name= strdup_root(alloc,(char*) row->data[1]);
|
||||
field->length= (uint) uint3korr(row->data[2]);
|
||||
field->type= (enum enum_field_types) (uchar) row->data[3][0];
|
||||
|
@ -911,7 +914,7 @@ static MYSQL_DATA *read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
|
|||
NET *net = &mysql->net;
|
||||
DBUG_ENTER("read_rows");
|
||||
|
||||
if ((pkt_len=(uint) net_safe_read(mysql)) == packet_error)
|
||||
if ((pkt_len= net_safe_read(mysql)) == packet_error)
|
||||
DBUG_RETURN(0);
|
||||
if (!(result=(MYSQL_DATA*) my_malloc(sizeof(MYSQL_DATA),
|
||||
MYF(MY_WME | MY_ZEROFILL))))
|
||||
|
@ -1018,7 +1021,7 @@ read_one_row(MYSQL *mysql,uint fields,MYSQL_ROW row, ulong *lengths)
|
|||
|
||||
/* perform query on master */
|
||||
int STDCALL mysql_master_query(MYSQL *mysql, const char *q,
|
||||
unsigned int length)
|
||||
unsigned long length)
|
||||
{
|
||||
if (mysql_master_send_query(mysql, q, length))
|
||||
return 1;
|
||||
|
@ -1026,7 +1029,7 @@ int STDCALL mysql_master_query(MYSQL *mysql, const char *q,
|
|||
}
|
||||
|
||||
int STDCALL mysql_master_send_query(MYSQL *mysql, const char *q,
|
||||
unsigned int length)
|
||||
unsigned long length)
|
||||
{
|
||||
MYSQL*master = mysql->master;
|
||||
if (!length)
|
||||
|
@ -1040,7 +1043,7 @@ int STDCALL mysql_master_send_query(MYSQL *mysql, const char *q,
|
|||
|
||||
/* perform query on slave */
|
||||
int STDCALL mysql_slave_query(MYSQL *mysql, const char *q,
|
||||
unsigned int length)
|
||||
unsigned long length)
|
||||
{
|
||||
if (mysql_slave_send_query(mysql, q, length))
|
||||
return 1;
|
||||
|
@ -1048,7 +1051,7 @@ int STDCALL mysql_slave_query(MYSQL *mysql, const char *q,
|
|||
}
|
||||
|
||||
int STDCALL mysql_slave_send_query(MYSQL *mysql, const char *q,
|
||||
unsigned int length)
|
||||
unsigned long length)
|
||||
{
|
||||
MYSQL* last_used_slave, *slave_to_use = 0;
|
||||
|
||||
|
@ -1269,7 +1272,7 @@ STDCALL mysql_rpl_query_type(const char* q, int len)
|
|||
case 'c': /* create or check */
|
||||
return tolower(q[1]) == 'h' ? MYSQL_RPL_ADMIN : MYSQL_RPL_MASTER ;
|
||||
case 's': /* select or show */
|
||||
return tolower(q[1] == 'h') ? MYSQL_RPL_ADMIN : MYSQL_RPL_SLAVE;
|
||||
return tolower(q[1]) == 'h' ? MYSQL_RPL_ADMIN : MYSQL_RPL_SLAVE;
|
||||
case 'f': /* flush */
|
||||
case 'r': /* repair */
|
||||
case 'g': /* grant */
|
||||
|
@ -1278,8 +1281,7 @@ STDCALL mysql_rpl_query_type(const char* q, int len)
|
|||
return MYSQL_RPL_SLAVE;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return MYSQL_RPL_MASTER; /* By default, send to master */
|
||||
}
|
||||
|
||||
|
||||
|
@ -1368,15 +1370,17 @@ mysql_ssl_set(MYSQL *mysql __attribute__((unused)) ,
|
|||
const char *key __attribute__((unused)),
|
||||
const char *cert __attribute__((unused)),
|
||||
const char *ca __attribute__((unused)),
|
||||
const char *capath __attribute__((unused)))
|
||||
const char *capath __attribute__((unused)),
|
||||
const char *cipher __attribute__((unused)))
|
||||
{
|
||||
#ifdef HAVE_OPENSSL
|
||||
mysql->options.ssl_key = key==0 ? 0 : my_strdup(key,MYF(0));
|
||||
mysql->options.ssl_cert = cert==0 ? 0 : my_strdup(cert,MYF(0));
|
||||
mysql->options.ssl_ca = ca==0 ? 0 : my_strdup(ca,MYF(0));
|
||||
mysql->options.ssl_capath = capath==0 ? 0 : my_strdup(capath,MYF(0));
|
||||
mysql->options.ssl_cipher = cipher==0 ? 0 : my_strdup(cipher,MYF(0));
|
||||
mysql->options.use_ssl = TRUE;
|
||||
mysql->connector_fd = (gptr)new_VioSSLConnectorFd(key, cert, ca, capath);
|
||||
mysql->connector_fd = (gptr)new_VioSSLConnectorFd(key, cert, ca, capath, cipher);
|
||||
DBUG_PRINT("info",("mysql_ssl_set, context: %p",((struct st_VioSSLConnectorFd *)(mysql->connector_fd))->ssl_context_));
|
||||
#endif
|
||||
return 0;
|
||||
|
@ -1396,10 +1400,12 @@ mysql_ssl_clear(MYSQL *mysql __attribute__((unused)))
|
|||
my_free(mysql->options.ssl_cert, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(mysql->options.ssl_ca, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(mysql->options.ssl_capath, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(mysql->options.ssl_cipher, MYF(MY_ALLOW_ZERO_PTR));
|
||||
mysql->options.ssl_key = 0;
|
||||
mysql->options.ssl_cert = 0;
|
||||
mysql->options.ssl_ca = 0;
|
||||
mysql->options.ssl_capath = 0;
|
||||
mysql->options.ssl_cipher= 0;
|
||||
mysql->options.use_ssl = FALSE;
|
||||
my_free(mysql->connector_fd,MYF(MY_ALLOW_ZERO_PTR));
|
||||
mysql->connector_fd = 0;
|
||||
|
@ -1523,7 +1529,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
|
|||
bzero((char*) &UNIXaddr,sizeof(UNIXaddr));
|
||||
UNIXaddr.sun_family = AF_UNIX;
|
||||
strmov(UNIXaddr.sun_path, unix_socket);
|
||||
if (connect2(sock,(struct sockaddr *) &UNIXaddr, sizeof(UNIXaddr),
|
||||
if (my_connect(sock,(struct sockaddr *) &UNIXaddr, sizeof(UNIXaddr),
|
||||
mysql->options.connect_timeout) <0)
|
||||
{
|
||||
DBUG_PRINT("error",("Got error %d on connect to local server",socket_errno));
|
||||
|
@ -1623,7 +1629,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
|
|||
}
|
||||
#endif
|
||||
sock_addr.sin_port = (ushort) htons((ushort) port);
|
||||
if (connect2(sock,(struct sockaddr *) &sock_addr, sizeof(sock_addr),
|
||||
if (my_connect(sock,(struct sockaddr *) &sock_addr, sizeof(sock_addr),
|
||||
mysql->options.connect_timeout) <0)
|
||||
{
|
||||
DBUG_PRINT("error",("Got error %d on connect to '%s'",socket_errno,host));
|
||||
|
@ -1797,7 +1803,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
|
|||
/* Do the SSL layering. */
|
||||
DBUG_PRINT("info", ("IO layer change in progress..."));
|
||||
DBUG_PRINT("info", ("IO context %p",((struct st_VioSSLConnectorFd*)mysql->connector_fd)->ssl_context_));
|
||||
sslconnect((struct st_VioSSLConnectorFd*)(mysql->connector_fd),mysql->net.vio);
|
||||
sslconnect((struct st_VioSSLConnectorFd*)(mysql->connector_fd),mysql->net.vio, (long)(mysql->options.connect_timeout));
|
||||
DBUG_PRINT("info", ("IO layer change done!"));
|
||||
}
|
||||
#endif /* HAVE_OPENSSL */
|
||||
|
@ -1823,7 +1829,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
|
|||
mysql->db=my_strdup(db,MYF(MY_WME));
|
||||
db=0;
|
||||
}
|
||||
if (my_net_write(net,buff,(uint) (end-buff)) || net_flush(net) ||
|
||||
if (my_net_write(net,buff,(ulong) (end-buff)) || net_flush(net) ||
|
||||
net_safe_read(mysql) == packet_error)
|
||||
goto error;
|
||||
if (client_flag & CLIENT_COMPRESS) /* We will use compression */
|
||||
|
@ -1887,7 +1893,7 @@ static my_bool mysql_reconnect(MYSQL *mysql)
|
|||
if (!mysql->reconnect ||
|
||||
(mysql->server_status & SERVER_STATUS_IN_TRANS) || !mysql->host_info)
|
||||
{
|
||||
/* Allov reconnect next time */
|
||||
/* Allow reconnect next time */
|
||||
mysql->server_status&= ~SERVER_STATUS_IN_TRANS;
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
|
@ -1929,7 +1935,7 @@ my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user,
|
|||
pos=scramble(pos, mysql->scramble_buff, passwd,
|
||||
(my_bool) (mysql->protocol_version == 9));
|
||||
pos=strmov(pos+1,db ? db : "");
|
||||
if (simple_command(mysql,COM_CHANGE_USER, buff,(uint) (pos-buff),0))
|
||||
if (simple_command(mysql,COM_CHANGE_USER, buff,(ulong) (pos-buff),0))
|
||||
DBUG_RETURN(1);
|
||||
|
||||
my_free(mysql->user,MYF(MY_ALLOW_ZERO_PTR));
|
||||
|
@ -1954,7 +1960,7 @@ mysql_select_db(MYSQL *mysql, const char *db)
|
|||
DBUG_ENTER("mysql_select_db");
|
||||
DBUG_PRINT("enter",("db: '%s'",db));
|
||||
|
||||
if ((error=simple_command(mysql,COM_INIT_DB,db,(uint) strlen(db),0)))
|
||||
if ((error=simple_command(mysql,COM_INIT_DB,db,(ulong) strlen(db),0)))
|
||||
DBUG_RETURN(error);
|
||||
my_free(mysql->db,MYF(MY_ALLOW_ZERO_PTR));
|
||||
mysql->db=my_strdup(db,MYF(MY_WME));
|
||||
|
@ -1995,13 +2001,13 @@ mysql_close(MYSQL *mysql)
|
|||
my_free(mysql->options.my_cnf_group,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(mysql->options.charset_dir,MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(mysql->options.charset_name,MYF(MY_ALLOW_ZERO_PTR));
|
||||
#ifdef HAVE_OPENSSL
|
||||
mysql_ssl_clear(mysql);
|
||||
#endif /* HAVE_OPENSSL */
|
||||
/* Clear pointers for better safety */
|
||||
mysql->host_info=mysql->user=mysql->passwd=mysql->db=0;
|
||||
bzero((char*) &mysql->options,sizeof(mysql->options));
|
||||
mysql->net.vio = 0;
|
||||
#ifdef HAVE_OPENSSL
|
||||
mysql_ssl_clear(mysql);
|
||||
#endif /* HAVE_OPENSSL */
|
||||
|
||||
/* free/close slave list */
|
||||
if (mysql->rpl_pivot)
|
||||
|
@ -2014,6 +2020,7 @@ mysql_close(MYSQL *mysql)
|
|||
mysql_close(tmp);
|
||||
tmp = tmp1;
|
||||
}
|
||||
mysql->rpl_pivot=0;
|
||||
}
|
||||
if (mysql != mysql->master)
|
||||
mysql_close(mysql->master);
|
||||
|
@ -2104,7 +2111,7 @@ STDCALL mysql_add_slave(MYSQL* mysql, const char* host,
|
|||
*/
|
||||
|
||||
int STDCALL
|
||||
mysql_send_query(MYSQL* mysql, const char* query, uint length)
|
||||
mysql_send_query(MYSQL* mysql, const char* query, ulong length)
|
||||
{
|
||||
if (mysql->options.rpl_parse && mysql->rpl_pivot)
|
||||
{
|
||||
|
@ -2172,13 +2179,13 @@ get_info:
|
|||
CLIENT_LONG_FLAG))))
|
||||
DBUG_RETURN(-1);
|
||||
mysql->status=MYSQL_STATUS_GET_RESULT;
|
||||
mysql->field_count=field_count;
|
||||
mysql->field_count= (uint) field_count;
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
|
||||
int STDCALL
|
||||
mysql_real_query(MYSQL *mysql, const char *query, uint length)
|
||||
mysql_real_query(MYSQL *mysql, const char *query, ulong length)
|
||||
{
|
||||
DBUG_ENTER("mysql_real_query");
|
||||
DBUG_PRINT("enter",("handle: %lx",mysql));
|
||||
|
@ -2269,8 +2276,9 @@ mysql_store_result(MYSQL *mysql)
|
|||
DBUG_RETURN(0);
|
||||
}
|
||||
mysql->status=MYSQL_STATUS_READY; /* server is ready */
|
||||
if (!(result=(MYSQL_RES*) my_malloc(sizeof(MYSQL_RES)+
|
||||
sizeof(ulong)*mysql->field_count,
|
||||
if (!(result=(MYSQL_RES*) my_malloc((uint) (sizeof(MYSQL_RES)+
|
||||
sizeof(ulong) *
|
||||
mysql->field_count),
|
||||
MYF(MY_WME | MY_ZEROFILL))))
|
||||
{
|
||||
mysql->net.last_errno=CR_OUT_OF_MEMORY;
|
||||
|
@ -2426,7 +2434,7 @@ mysql_fetch_lengths(MYSQL_RES *res)
|
|||
continue;
|
||||
}
|
||||
if (start) /* Found end of prev string */
|
||||
*prev_length= (uint) (*column-start-1);
|
||||
*prev_length= (ulong) (*column-start-1);
|
||||
start= *column;
|
||||
prev_length=lengths;
|
||||
}
|
||||
|
@ -2527,7 +2535,7 @@ mysql_list_fields(MYSQL *mysql, const char *table, const char *wild)
|
|||
LINT_INIT(query);
|
||||
|
||||
end=strmake(strmake(buff, table,128)+1,wild ? wild : "",128);
|
||||
if (simple_command(mysql,COM_FIELD_LIST,buff,(uint) (end-buff),1) ||
|
||||
if (simple_command(mysql,COM_FIELD_LIST,buff,(ulong) (end-buff),1) ||
|
||||
!(query = read_rows(mysql,(MYSQL_FIELD*) 0,6)))
|
||||
DBUG_RETURN(NULL);
|
||||
|
||||
|
@ -2583,7 +2591,7 @@ mysql_create_db(MYSQL *mysql, const char *db)
|
|||
{
|
||||
DBUG_ENTER("mysql_createdb");
|
||||
DBUG_PRINT("enter",("db: %s",db));
|
||||
DBUG_RETURN(simple_command(mysql,COM_CREATE_DB,db, (uint) strlen(db),0));
|
||||
DBUG_RETURN(simple_command(mysql,COM_CREATE_DB,db, (ulong) strlen(db),0));
|
||||
}
|
||||
|
||||
|
||||
|
@ -2592,7 +2600,7 @@ mysql_drop_db(MYSQL *mysql, const char *db)
|
|||
{
|
||||
DBUG_ENTER("mysql_drop_db");
|
||||
DBUG_PRINT("enter",("db: %s",db));
|
||||
DBUG_RETURN(simple_command(mysql,COM_DROP_DB,db,(uint) strlen(db),0));
|
||||
DBUG_RETURN(simple_command(mysql,COM_DROP_DB,db,(ulong) strlen(db),0));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
308
libmysql/manager.c
Normal file
|
@ -0,0 +1,308 @@
|
|||
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
||||
MA 02111-1307, USA */
|
||||
|
||||
#include <my_global.h>
|
||||
#if defined(__WIN__) || defined(_WIN32) || defined(_WIN64)
|
||||
#include <winsock.h>
|
||||
#include <odbcinst.h>
|
||||
#endif
|
||||
#include <my_sys.h>
|
||||
#include <mysys_err.h>
|
||||
#include <m_string.h>
|
||||
#include <m_ctype.h>
|
||||
#include "mysql.h"
|
||||
#include "mysql_version.h"
|
||||
#include "mysqld_error.h"
|
||||
#include "errmsg.h"
|
||||
#include <violite.h>
|
||||
#include <sys/stat.h>
|
||||
#include <signal.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef HAVE_PWD_H
|
||||
#include <pwd.h>
|
||||
#endif
|
||||
#if !defined(MSDOS) && !defined(__WIN__)
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#ifdef HAVE_SELECT_H
|
||||
# include <select.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SELECT_H
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
#endif
|
||||
#ifdef HAVE_SYS_UN_H
|
||||
# include <sys/un.h>
|
||||
#endif
|
||||
#if defined(THREAD) && !defined(__WIN__)
|
||||
#include <my_pthread.h> /* because of signal() */
|
||||
#endif
|
||||
#ifndef INADDR_NONE
|
||||
#define INADDR_NONE -1
|
||||
#endif
|
||||
|
||||
|
||||
#define RES_BUF_SHIFT 5
|
||||
#define SOCKET_ERROR -1
|
||||
#define NET_BUF_SIZE 2048
|
||||
|
||||
MYSQL_MANAGER* STDCALL mysql_manager_init(MYSQL_MANAGER* con)
|
||||
{
|
||||
int net_buf_size=NET_BUF_SIZE;
|
||||
if (!con)
|
||||
{
|
||||
if (!(con=(MYSQL_MANAGER*)my_malloc(sizeof(*con)+net_buf_size,
|
||||
MYF(MY_WME|MY_ZEROFILL))))
|
||||
return 0;
|
||||
con->free_me=1;
|
||||
con->net_buf=(char*)con+sizeof(*con);
|
||||
}
|
||||
else
|
||||
{
|
||||
bzero((char*)con,sizeof(*con));
|
||||
if (!(con->net_buf=my_malloc(net_buf_size,MYF(0))))
|
||||
return 0;
|
||||
}
|
||||
con->net_buf_pos=con->net_data_end=con->net_buf;
|
||||
con->net_buf_size=net_buf_size;
|
||||
return con;
|
||||
}
|
||||
|
||||
MYSQL_MANAGER* STDCALL mysql_manager_connect(MYSQL_MANAGER* con,
|
||||
const char* host,
|
||||
const char* user,
|
||||
const char* passwd,
|
||||
unsigned int port)
|
||||
{
|
||||
my_socket sock;
|
||||
struct sockaddr_in sock_addr;
|
||||
uint32 ip_addr;
|
||||
char msg_buf[MAX_MYSQL_MANAGER_MSG];
|
||||
int msg_len;
|
||||
|
||||
if (!host)
|
||||
host="localhost";
|
||||
if (!user)
|
||||
user="root";
|
||||
if (!passwd)
|
||||
passwd="";
|
||||
|
||||
if ((sock=(my_socket)socket(AF_INET,SOCK_STREAM,0)) == SOCKET_ERROR)
|
||||
{
|
||||
con->last_errno=errno;
|
||||
strmov(con->last_error,"Cannot create socket");
|
||||
goto err;
|
||||
}
|
||||
if (!(con->vio=vio_new(sock,VIO_TYPE_TCPIP,FALSE)))
|
||||
{
|
||||
con->last_errno=ENOMEM;
|
||||
strmov(con->last_error,"Cannot create network I/O object");
|
||||
goto err;
|
||||
}
|
||||
vio_blocking(con->vio,TRUE);
|
||||
bzero((char*) &sock_addr,sizeof(sock_addr));
|
||||
sock_addr.sin_family = AF_INET;
|
||||
if ((int) (ip_addr = inet_addr(host)) != (int) INADDR_NONE)
|
||||
{
|
||||
memcpy_fixed(&sock_addr.sin_addr,&ip_addr,sizeof(ip_addr));
|
||||
}
|
||||
else
|
||||
#if defined(HAVE_GETHOSTBYNAME_R) && defined(_REENTRANT) && defined(THREAD)
|
||||
{
|
||||
int tmp_errno;
|
||||
struct hostent tmp_hostent,*hp;
|
||||
char buff2[GETHOSTBYNAME_BUFF_SIZE];
|
||||
hp = my_gethostbyname_r(host,&tmp_hostent,buff2,sizeof(buff2),
|
||||
&tmp_errno);
|
||||
if (!hp)
|
||||
{
|
||||
con->last_errno=tmp_errno;
|
||||
sprintf(con->last_error,"Could not resolve host '%s'",host);
|
||||
goto err;
|
||||
}
|
||||
memcpy(&sock_addr.sin_addr,hp->h_addr, (size_t) hp->h_length);
|
||||
}
|
||||
#else
|
||||
{
|
||||
struct hostent *hp;
|
||||
if (!(hp=gethostbyname(host)))
|
||||
{
|
||||
con->last_errno=socket_errno;
|
||||
sprintf(con->last_error, "Could not resolve host '%s'", host);
|
||||
goto err;
|
||||
}
|
||||
memcpy(&sock_addr.sin_addr,hp->h_addr, (size_t) hp->h_length);
|
||||
}
|
||||
#endif
|
||||
sock_addr.sin_port = (ushort) htons((ushort) port);
|
||||
if (my_connect(sock,(struct sockaddr *) &sock_addr, sizeof(sock_addr),
|
||||
0) <0)
|
||||
{
|
||||
con->last_errno=errno;
|
||||
sprintf(con->last_error ,"Could not connect to %-.64s", host);
|
||||
goto err;
|
||||
}
|
||||
/* read the greating */
|
||||
if (vio_read(con->vio,msg_buf,MAX_MYSQL_MANAGER_MSG)<=0)
|
||||
{
|
||||
con->last_errno=errno;
|
||||
strmov(con->last_error,"Read error on socket");
|
||||
goto err;
|
||||
}
|
||||
sprintf(msg_buf,"%-.16s %-.16s\n",user,passwd);
|
||||
msg_len=strlen(msg_buf);
|
||||
if (vio_write(con->vio,msg_buf,msg_len)!=msg_len)
|
||||
{
|
||||
con->last_errno=errno;
|
||||
strmov(con->last_error,"Write error on socket");
|
||||
goto err;
|
||||
}
|
||||
if (vio_read(con->vio,msg_buf,MAX_MYSQL_MANAGER_MSG)<=0)
|
||||
{
|
||||
con->last_errno=errno;
|
||||
strmov(con->last_error,"Read error on socket");
|
||||
goto err;
|
||||
}
|
||||
if ((con->cmd_status=atoi(msg_buf)) != MANAGER_OK)
|
||||
{
|
||||
strmov(con->last_error,"Access denied");
|
||||
goto err;
|
||||
}
|
||||
if (!my_multi_malloc(MYF(0), &con->host, (uint)strlen(host)+1,
|
||||
&con->user, (uint)strlen(user)+1,
|
||||
&con->passwd, (uint)strlen(passwd)+1,
|
||||
NullS))
|
||||
{
|
||||
con->last_errno=ENOMEM;
|
||||
strmov(con->last_error,"Out of memory");
|
||||
goto err;
|
||||
}
|
||||
strmov(con->host,host);
|
||||
strmov(con->user,user);
|
||||
strmov(con->passwd,passwd);
|
||||
return con;
|
||||
err:
|
||||
{
|
||||
my_bool free_me=con->free_me;
|
||||
con->free_me=0;
|
||||
mysql_manager_close(con);
|
||||
con->free_me=free_me;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void STDCALL mysql_manager_close(MYSQL_MANAGER* con)
|
||||
{
|
||||
my_free((gptr)con->host,MYF(MY_ALLOW_ZERO_PTR));
|
||||
/* no need to free con->user and con->passwd, because they were
|
||||
allocated in my_multimalloc() along with con->host, freeing
|
||||
con->hosts frees the whole block
|
||||
*/
|
||||
if (con->vio)
|
||||
{
|
||||
vio_delete(con->vio);
|
||||
con->vio=0;
|
||||
}
|
||||
if (con->free_me)
|
||||
my_free((gptr)con,MYF(0));
|
||||
}
|
||||
|
||||
int STDCALL mysql_manager_command(MYSQL_MANAGER* con,const char* cmd,
|
||||
int cmd_len)
|
||||
{
|
||||
if (!cmd_len)
|
||||
cmd_len=strlen(cmd);
|
||||
if (vio_write(con->vio,(char*)cmd,cmd_len) != cmd_len)
|
||||
{
|
||||
con->last_errno=errno;
|
||||
strmov(con->last_error,"Write error on socket");
|
||||
return 1;
|
||||
}
|
||||
con->eof=0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int STDCALL mysql_manager_fetch_line(MYSQL_MANAGER* con, char* res_buf,
|
||||
int res_buf_size)
|
||||
{
|
||||
char* res_buf_end=res_buf+res_buf_size;
|
||||
char* net_buf_pos=con->net_buf_pos, *net_buf_end=con->net_data_end;
|
||||
int res_buf_shift=RES_BUF_SHIFT;
|
||||
int done=0;
|
||||
|
||||
if (res_buf_size<RES_BUF_SHIFT)
|
||||
{
|
||||
con->last_errno=ENOMEM;
|
||||
strmov(con->last_error,"Result buffer too small");
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (;;)
|
||||
{
|
||||
for (;net_buf_pos<net_buf_end && res_buf<res_buf_end;
|
||||
net_buf_pos++,res_buf++)
|
||||
{
|
||||
char c=*net_buf_pos;
|
||||
if (c == '\r')
|
||||
c=*++net_buf_pos;
|
||||
if (c == '\n')
|
||||
{
|
||||
*res_buf=0;
|
||||
net_buf_pos++;
|
||||
done=1;
|
||||
break;
|
||||
}
|
||||
else
|
||||
*res_buf=*net_buf_pos;
|
||||
}
|
||||
if (done || res_buf==res_buf_end)
|
||||
break;
|
||||
|
||||
if (net_buf_pos == net_buf_end && res_buf<res_buf_end)
|
||||
{
|
||||
int num_bytes;
|
||||
if ((num_bytes=vio_read(con->vio,con->net_buf,con->net_buf_size))<=0)
|
||||
{
|
||||
con->last_errno=errno;
|
||||
strmov(con->last_error,"socket read failed");
|
||||
return 1;
|
||||
}
|
||||
net_buf_pos=con->net_buf;
|
||||
net_buf_end=net_buf_pos+num_bytes;
|
||||
}
|
||||
}
|
||||
con->net_buf_pos=net_buf_pos;
|
||||
con->net_data_end=net_buf_end;
|
||||
res_buf=res_buf_end-res_buf_size;
|
||||
if ((con->eof=(res_buf[3]==' ')))
|
||||
res_buf_shift--;
|
||||
res_buf_end-=res_buf_shift;
|
||||
for (;res_buf<res_buf_end;res_buf++)
|
||||
{
|
||||
if(!(*res_buf=res_buf[res_buf_shift]))
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -31,15 +31,16 @@
|
|||
#include <winsock.h>
|
||||
#endif
|
||||
#include <my_global.h>
|
||||
#include <mysql.h>
|
||||
#include <mysql_embed.h>
|
||||
#include <mysql_com.h>
|
||||
#include <violite.h>
|
||||
#include <mysqld_error.h>
|
||||
#include <my_sys.h>
|
||||
#include <m_string.h>
|
||||
#include "mysql.h"
|
||||
#include "mysqld_error.h"
|
||||
#include <my_net.h>
|
||||
#include <violite.h>
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef MYSQL_SERVER
|
||||
ulong max_allowed_packet=65536;
|
||||
|
@ -59,20 +60,9 @@ ulong net_write_timeout= NET_WRITE_TIMEOUT;
|
|||
#endif
|
||||
ulong net_buffer_length=8192; /* Default length. Enlarged if necessary */
|
||||
|
||||
#if !defined(__WIN__) && !defined(MSDOS)
|
||||
#include <sys/socket.h>
|
||||
#else
|
||||
#if defined(__WIN__) || defined(MSDOS)
|
||||
#undef MYSQL_SERVER /* Win32 can't handle interrupts */
|
||||
#endif
|
||||
#if !defined(MSDOS) && !defined(__WIN__) && !defined(HAVE_BROKEN_NETINET_INCLUDES) && !defined(__BEOS__)
|
||||
#include <netinet/in_systm.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/ip.h>
|
||||
#if !defined(alpha_linux_port)
|
||||
#include <netinet/tcp.h>
|
||||
#endif
|
||||
#endif
|
||||
#include "mysqld_error.h"
|
||||
#ifdef MYSQL_SERVER
|
||||
#include "my_pthread.h"
|
||||
#include "thr_alarm.h"
|
||||
|
@ -89,7 +79,7 @@ extern ulong mysqld_net_retry_count;
|
|||
typedef my_bool thr_alarm_t;
|
||||
typedef my_bool ALARM;
|
||||
#define thr_alarm_init(A) (*(A))=0
|
||||
#define thr_alarm_in_use(A) (*(A)!= 0)
|
||||
#define thr_alarm_in_use(A) (*(A) != 0)
|
||||
#define thr_end_alarm(A)
|
||||
#define thr_alarm(A,B,C) local_thr_alarm((A),(B),(C))
|
||||
inline int local_thr_alarm(my_bool *A,int B __attribute__((unused)),ALARM *C __attribute__((unused)))
|
||||
|
@ -129,7 +119,7 @@ int my_net_init(NET *net, Vio* vio)
|
|||
net->no_send_ok = 0;
|
||||
net->error=0; net->return_errno=0; net->return_status=0;
|
||||
net->timeout=(uint) net_read_timeout; /* Timeout for read */
|
||||
net->pkt_nr=0;
|
||||
net->pkt_nr=net->compress_pkt_nr=0;
|
||||
net->write_pos=net->read_pos = net->buff;
|
||||
net->last_error[0]=0;
|
||||
net->compress=0; net->reading_or_writing=0;
|
||||
|
@ -190,7 +180,7 @@ static my_bool net_realloc(NET *net, ulong length)
|
|||
void net_clear(NET *net)
|
||||
{
|
||||
#ifndef EXTRA_DEBUG
|
||||
int count;
|
||||
int count; /* One may get 'unused' warn */
|
||||
bool is_blocking=vio_is_blocking(net->vio);
|
||||
if (is_blocking)
|
||||
vio_blocking(net->vio, FALSE);
|
||||
|
@ -204,7 +194,7 @@ void net_clear(NET *net)
|
|||
vio_blocking(net->vio, TRUE);
|
||||
}
|
||||
#endif /* EXTRA_DEBUG */
|
||||
net->pkt_nr=0; /* Ready for new command */
|
||||
net->pkt_nr=net->compress_pkt_nr=0; /* Ready for new command */
|
||||
net->write_pos=net->buff;
|
||||
}
|
||||
|
||||
|
@ -217,9 +207,12 @@ int net_flush(NET *net)
|
|||
if (net->buff != net->write_pos)
|
||||
{
|
||||
error=net_real_write(net,(char*) net->buff,
|
||||
(uint) (net->write_pos - net->buff));
|
||||
(ulong) (net->write_pos - net->buff));
|
||||
net->write_pos=net->buff;
|
||||
}
|
||||
/* Sync packet number if using compression */
|
||||
if (net->compress)
|
||||
net->pkt_nr=net->compress_pkt_nr;
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
|
@ -248,7 +241,7 @@ my_net_write(NET *net,const char *packet,ulong len)
|
|||
{
|
||||
const ulong z_size = MAX_THREE_BYTES;
|
||||
int3store(buff, z_size);
|
||||
buff[3]= (net->compress) ? 0 : (uchar) (net->pkt_nr++);
|
||||
buff[3]= net->pkt_nr++;
|
||||
if (net_write_buff(net, (char*) buff, NET_HEADER_SIZE) ||
|
||||
net_write_buff(net, packet, z_size))
|
||||
return 1;
|
||||
|
@ -257,7 +250,7 @@ my_net_write(NET *net,const char *packet,ulong len)
|
|||
}
|
||||
/* Write last packet */
|
||||
int3store(buff,len);
|
||||
buff[3]= (net->compress) ? 0 : (uchar) (net->pkt_nr++);
|
||||
buff[3]= net->pkt_nr++;
|
||||
if (net_write_buff(net,(char*) buff,NET_HEADER_SIZE))
|
||||
return 1;
|
||||
return net_write_buff(net,packet,len);
|
||||
|
@ -275,7 +268,7 @@ my_net_write(NET *net,const char *packet,ulong len)
|
|||
int
|
||||
net_write_command(NET *net,uchar command,const char *packet,ulong len)
|
||||
{
|
||||
uint length=len+1; /* 1 extra byte for command */
|
||||
ulong length=len+1; /* 1 extra byte for command */
|
||||
uchar buff[NET_HEADER_SIZE+1];
|
||||
uint header_size=NET_HEADER_SIZE+1;
|
||||
buff[4]=command; /* For first packet */
|
||||
|
@ -287,7 +280,7 @@ net_write_command(NET *net,uchar command,const char *packet,ulong len)
|
|||
do
|
||||
{
|
||||
int3store(buff, MAX_THREE_BYTES);
|
||||
buff[3]= (net->compress) ? 0 : (uchar) (net->pkt_nr++);
|
||||
buff[3]= net->pkt_nr++;
|
||||
if (net_write_buff(net,(char*) buff, header_size) ||
|
||||
net_write_buff(net,packet,len))
|
||||
return 1;
|
||||
|
@ -299,7 +292,7 @@ net_write_command(NET *net,uchar command,const char *packet,ulong len)
|
|||
len=length; /* Data left to be written */
|
||||
}
|
||||
int3store(buff,length);
|
||||
buff[3]= (net->compress) ? 0 : (uchar) (net->pkt_nr++);
|
||||
buff[3]= net->pkt_nr++;
|
||||
return test(net_write_buff(net,(char*) buff,header_size) ||
|
||||
net_write_buff(net,packet,len) || net_flush(net));
|
||||
}
|
||||
|
@ -312,7 +305,7 @@ net_write_command(NET *net,uchar command,const char *packet,ulong len)
|
|||
static int
|
||||
net_write_buff(NET *net,const char *packet,ulong len)
|
||||
{
|
||||
uint left_length=(uint) (net->buff_end - net->write_pos);
|
||||
ulong left_length=(ulong) (net->buff_end - net->write_pos);
|
||||
|
||||
while (len > left_length)
|
||||
{
|
||||
|
@ -338,7 +331,7 @@ net_write_buff(NET *net,const char *packet,ulong len)
|
|||
int
|
||||
net_real_write(NET *net,const char *packet,ulong len)
|
||||
{
|
||||
int length;
|
||||
long int length;
|
||||
char *pos,*end;
|
||||
thr_alarm_t alarmed;
|
||||
#if !defined(__WIN__) && !defined(__EMX__) && !defined(OS2)
|
||||
|
@ -378,7 +371,7 @@ net_real_write(NET *net,const char *packet,ulong len)
|
|||
}
|
||||
int3store(&b[NET_HEADER_SIZE],complen);
|
||||
int3store(b,len);
|
||||
b[3]=(uchar) (net->pkt_nr++);
|
||||
b[3]=(uchar) (net->compress_pkt_nr++);
|
||||
len+= header_length;
|
||||
packet= (char*) b;
|
||||
}
|
||||
|
@ -396,7 +389,7 @@ net_real_write(NET *net,const char *packet,ulong len)
|
|||
pos=(char*) packet; end=pos+len;
|
||||
while (pos != end)
|
||||
{
|
||||
if ((int) (length=vio_write(net->vio,pos,(int) (end-pos))) <= 0)
|
||||
if ((long) (length=vio_write(net->vio,pos,(ulong) (end-pos))) <= 0)
|
||||
{
|
||||
my_bool interrupted = vio_should_retry(net->vio);
|
||||
#if (!defined(__WIN__) && !defined(__EMX__) && !defined(OS2))
|
||||
|
@ -496,7 +489,7 @@ static void my_net_skip_rest(NET *net, ulong remain, thr_alarm_t *alarmed)
|
|||
if ((int) (length=vio_read(net->vio,(char*) net->buff,remain)) <= 0L)
|
||||
{
|
||||
my_bool interrupted = vio_should_retry(net->vio);
|
||||
if (!thr_got_alarm(alarmed) && interrupted)
|
||||
if (!thr_got_alarm(&alarmed) && interrupted)
|
||||
{ /* Probably in MIT threads */
|
||||
if (retry_count++ < RETRY_COUNT)
|
||||
continue;
|
||||
|
@ -516,7 +509,7 @@ static void my_net_skip_rest(NET *net, ulong remain, thr_alarm_t *alarmed)
|
|||
This function reallocates the net->buff buffer if necessary.
|
||||
*/
|
||||
|
||||
static uint
|
||||
static ulong
|
||||
my_real_read(NET *net, ulong *complen)
|
||||
{
|
||||
uchar *pos;
|
||||
|
@ -627,9 +620,9 @@ my_real_read(NET *net, ulong *complen)
|
|||
if (net->buff[net->where_b] != (uchar) 255)
|
||||
{
|
||||
DBUG_PRINT("error",
|
||||
("Packets out of order (Found: %d, expected %d)",
|
||||
("Packets out of order (Found: %d, expected %u)",
|
||||
(int) net->buff[net->where_b + 3],
|
||||
(uint) (uchar) net->pkt_nr));
|
||||
net->pkt_nr));
|
||||
#ifdef EXTRA_DEBUG
|
||||
fprintf(stderr,"Packets out of order (Found: %d, expected %d)\n",
|
||||
(int) net->buff[net->where_b + 3],
|
||||
|
@ -642,7 +635,7 @@ my_real_read(NET *net, ulong *complen)
|
|||
#endif
|
||||
goto end;
|
||||
}
|
||||
net->pkt_nr++;
|
||||
net->compress_pkt_nr= ++net->pkt_nr;
|
||||
#ifdef HAVE_COMPRESS
|
||||
if (net->compress)
|
||||
{
|
||||
|
@ -710,7 +703,7 @@ my_net_read(NET *net)
|
|||
if (len == MAX_THREE_BYTES)
|
||||
{
|
||||
/* First packet of a multi-packet. Concatenate the packets */
|
||||
int save_pos = net->where_b;
|
||||
ulong save_pos = net->where_b;
|
||||
ulong total_length=0;
|
||||
do
|
||||
{
|
||||
|
@ -820,8 +813,8 @@ my_net_read(NET *net)
|
|||
|
||||
net->read_pos= net->buff+ first_packet_offset + NET_HEADER_SIZE;
|
||||
net->buf_length= buf_length;
|
||||
net->remain_in_buf= buf_length - start_of_packet;
|
||||
len = ((uint) (start_of_packet - first_packet_offset) - NET_HEADER_SIZE -
|
||||
net->remain_in_buf= (ulong) (buf_length - start_of_packet);
|
||||
len = ((ulong) (start_of_packet - first_packet_offset) - NET_HEADER_SIZE -
|
||||
multi_byte_packet);
|
||||
net->save_char= net->read_pos[len]; /* Must be saved */
|
||||
net->read_pos[len]=0; /* Safeguard for mysql_use_result */
|
||||
|
|
|
@ -17,27 +17,25 @@
|
|||
#
|
||||
# This file is public domain and comes with NO WARRANTY of any kind
|
||||
|
||||
MYSQLDATAdir = $(localstatedir)
|
||||
MYSQLSHAREdir = $(pkgdatadir)
|
||||
MYSQLBASEdir= $(prefix)
|
||||
MYSQLDATAdir = $(localstatedir)
|
||||
MYSQLSHAREdir = $(pkgdatadir)
|
||||
MYSQLBASEdir= $(prefix)
|
||||
|
||||
DEFS = -DEMBEDDED_LIBRARY -DMYSQL_SERVER \
|
||||
-DDEFAULT_MYSQL_HOME="\"$(MYSQLBASEdir)\"" \
|
||||
-DDATADIR="\"$(MYSQLDATAdir)\"" \
|
||||
-DSHAREDIR="\"$(MYSQLSHAREdir)\""
|
||||
INCLUDES = @MT_INCLUDES@ @bdb_includes@ -I$(srcdir)/../include -I../include \
|
||||
-I$(srcdir)/.. -I$(top_srcdir) -I.. -I../sql -I../regex
|
||||
INCLUDES= @MT_INCLUDES@ @bdb_includes@ -I$(srcdir)/../include \
|
||||
-I../include -I$(srcdir)/.. -I$(top_srcdir) -I.. \
|
||||
-I../sql -I../regex
|
||||
|
||||
|
||||
## XXX: should we use client or server LDFLAGS for libmysqld?
|
||||
LDADD = @CLIENT_EXTRA_LDFLAGS@ libmysqld.la
|
||||
pkglib_LTLIBRARIES = libmysqld.la
|
||||
noinst_LIBRARIES = libmysqld_int.a
|
||||
pkglib_LIBRARIES = libmysqld.a
|
||||
SUBDIRS = . examples
|
||||
libmysqld_la_SOURCES= libmysqld.c lib_sql.cc lib_load.cc
|
||||
|
||||
libmysqld_sources= libmysqld.c lib_sql.cc lib_load.cc
|
||||
libmysqlsources = errmsg.c get_password.c password.c
|
||||
## XXX: we should not have to duplicate info from the sources list
|
||||
libmysqlobjects = errmsg.lo get_password.lo password.lo
|
||||
|
||||
noinst_HEADERS = embedded_priv.h
|
||||
|
||||
sqlsources = convert.cc derror.cc field.cc field_conv.cc filesort.cc \
|
||||
ha_innobase.cc ha_berkeley.cc ha_heap.cc ha_isam.cc ha_isammrg.cc \
|
||||
|
@ -45,7 +43,7 @@ sqlsources = convert.cc derror.cc field.cc field_conv.cc filesort.cc \
|
|||
hostname.cc init.cc \
|
||||
item.cc item_buff.cc item_cmpfunc.cc item_create.cc \
|
||||
item_func.cc item_strfunc.cc item_sum.cc item_timefunc.cc \
|
||||
item_uniq.cc key.cc lock.cc log.cc log_event.cc md5.c \
|
||||
item_uniq.cc key.cc lock.cc log.cc log_event.cc \
|
||||
mini_client.cc net_pkg.cc net_serv.cc opt_ft.cc opt_range.cc \
|
||||
opt_sum.cc procedure.cc records.cc slave.cc sql_acl.cc \
|
||||
sql_analyse.cc sql_base.cc sql_cache.cc sql_class.cc \
|
||||
|
@ -56,37 +54,53 @@ sqlsources = convert.cc derror.cc field.cc field_conv.cc filesort.cc \
|
|||
sql_update.cc sql_yacc.cc table.cc thr_malloc.cc time.cc \
|
||||
unireg.cc uniques.cc stacktrace.c sql_union.cc hash_filo.cc
|
||||
|
||||
## XXX: we should not have to duplicate info from the sources list
|
||||
sqlobjects = convert.lo derror.lo field.lo field_conv.lo filesort.lo \
|
||||
ha_innobase.lo ha_berkeley.lo ha_heap.lo ha_isam.lo ha_isammrg.lo \
|
||||
ha_myisam.lo ha_myisammrg.lo handler.lo sql_handler.lo \
|
||||
hostname.lo init.lo \
|
||||
item.lo item_buff.lo item_cmpfunc.lo item_create.lo \
|
||||
item_func.lo item_strfunc.lo item_sum.lo item_timefunc.lo \
|
||||
item_uniq.lo key.lo lock.lo log.lo log_event.lo md5.lo \
|
||||
mini_client.lo net_pkg.lo net_serv.lo opt_ft.lo opt_range.lo \
|
||||
opt_sum.lo procedure.lo records.lo slave.lo sql_acl.lo \
|
||||
sql_analyse.lo sql_base.lo sql_cache.lo sql_class.lo \
|
||||
sql_crypt.lo sql_db.lo sql_delete.lo sql_insert.lo sql_lex.lo \
|
||||
sql_list.lo sql_manager.lo sql_map.lo sql_parse.lo \
|
||||
sql_rename.lo sql_repl.lo sql_select.lo sql_show.lo \
|
||||
sql_string.lo sql_table.lo sql_test.lo sql_udf.lo \
|
||||
sql_update.lo sql_yacc.lo table.lo thr_malloc.lo time.lo \
|
||||
unireg.lo uniques.lo stacktrace.lo sql_union.lo hash_filo.lo
|
||||
|
||||
EXTRA_DIST = lib_vio.c
|
||||
|
||||
libmysqld_int_a_SOURCES= $(libmysqld_sources) $(libmysqlsources) $(sqlsources)
|
||||
libmysqld_a_SOURCES=
|
||||
|
||||
# automake misses these
|
||||
sql_yacc.cc sql_yacc.h: $(top_srcdir)/sql/sql_yacc.yy
|
||||
|
||||
libmysqld_la_LIBADD = $(sqlobjects) $(libmysqlobjects)
|
||||
# The following libraries should be included in libmysqld.a
|
||||
INC_LIB= $(top_builddir)/regex/libregex.a \
|
||||
$(top_builddir)/myisam/libmyisam.a \
|
||||
$(top_builddir)/myisammrg/libmyisammrg.a \
|
||||
$(top_builddir)/heap/libheap.a \
|
||||
@innodb_libs@ @bdb_libs_with_path@ \
|
||||
$(top_builddir)/mysys/libmysys.a \
|
||||
$(top_builddir)/strings/libmystrings.a \
|
||||
$(top_builddir)/dbug/libdbug.a \
|
||||
$(top_builddir)/regex/libregex.a
|
||||
|
||||
#
|
||||
# To make it easy for the end user to use the embedded library we
|
||||
# generate a total libmysqld.a from all library files,
|
||||
|
||||
libmysqld.a: libmysqld_int.a $(INC_LIB)
|
||||
if test ! -d tmp ; then mkdir tmp ; fi
|
||||
rm -f $@ libmysqld_int2.a tmp/*.o tmp/*.a
|
||||
cp $(INC_LIB) tmp
|
||||
cp libmysqld_int.a libmysqld_int2.a ; \
|
||||
cd tmp ; \
|
||||
for file in *.a ; do \
|
||||
bfile=`basename $$file .a` ; \
|
||||
ar x $$file; \
|
||||
for obj in *.o ; do mv $$obj $${bfile}_$$obj ; done ; \
|
||||
ar q ../libmysqld_int2.a *.o ; \
|
||||
rm *.o ; \
|
||||
done
|
||||
mv libmysqld_int2.a libmysqld.a
|
||||
rm tmp/*
|
||||
$(RANLIB) libmysqld.a
|
||||
|
||||
## XXX: any time the client interface changes, we'll need to bump
|
||||
## the version info for libmysqld; however, it's possible for the
|
||||
## libmysqld interface to change without affecting the standard
|
||||
## libmysqlclient interface. Should we make a separate version
|
||||
## string for the two?
|
||||
libmysqld_la_LDFLAGS = -version-info @SHARED_LIB_VERSION@
|
||||
CLEANFILES = $(libmysqld_la_LIBADD) libmysqld.la
|
||||
#libmysqld_la_LDFLAGS = -version-info @SHARED_LIB_VERSION@
|
||||
#CLEANFILES = $(libmysqld_la_LIBADD) libmysqld.la
|
||||
|
||||
# This is called from the toplevel makefile
|
||||
link_sources:
|
||||
|
|
32
libmysqld/embedded_priv.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult 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; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
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 */
|
||||
|
||||
/* Prototypes for the embedded version of MySQL */
|
||||
|
||||
#include <my_global.h>
|
||||
#include <mysql_embed.h>
|
||||
#include <mysql.h>
|
||||
#include <mysql_version.h>
|
||||
#include <mysqld_error.h>
|
||||
#include <my_pthread.h>
|
||||
|
||||
C_MODE_START
|
||||
extern void start_embedded_connection(NET * net);
|
||||
extern void end_embedded_connection(NET * net);
|
||||
extern void lib_connection_phase(NET *net, int phase);
|
||||
extern bool lib_dispatch_command(enum enum_server_command command, NET *net,
|
||||
const char *arg, ulong length);
|
||||
C_MODE_END
|
|
@ -7,26 +7,15 @@ link_sources:
|
|||
@LN_CP_F@ $(srcdir)/../../client/$$f $(srcdir)/$$f; \
|
||||
done;
|
||||
|
||||
DEFS = -DEMBEDDED_SERVER
|
||||
DEFS = -DEMBEDDED_LIBRARY
|
||||
INCLUDES = -I$(top_srcdir)/include $(openssl_includes) \
|
||||
-I$(srcdir) -I$(top_srcdir) -I$(top_srcdir)/client
|
||||
LIBS = @LIBS@
|
||||
LDADD = $(top_builddir)/libmysqld/libmysqld.la \
|
||||
$(top_builddir)/isam/libnisam.a \
|
||||
$(top_builddir)/myisam/libmyisam.a \
|
||||
$(top_builddir)/heap/libheap.a \
|
||||
$(top_builddir)/merge/libmerge.a \
|
||||
$(top_builddir)/myisammrg/libmyisammrg.a \
|
||||
@innodb_libs@ @bdb_libs@ @pstack_libs@ \
|
||||
$(top_builddir)/mysys/libmysys.a \
|
||||
$(top_builddir)/strings/libmystrings.a \
|
||||
$(top_builddir)/dbug/libdbug.a \
|
||||
$(top_builddir)/regex/libregex.a @LIBDL@
|
||||
LIBS = @LIBS@
|
||||
LDADD = ../libmysqld.a @innodb_system_libs@ @LIBDL@
|
||||
|
||||
mysqltest_DEPENDENCIES = ../libmysqld.la
|
||||
mysqltest_SOURCES = mysqltest.c
|
||||
|
||||
mysql_SOURCES = mysql.cc readline.cc sql_string.cc completion_hash.cc \
|
||||
mysql_SOURCES = mysql.cc readline.cc completion_hash.cc \
|
||||
my_readline.h sql_string.h completion_hash.h
|
||||
mysql_LDADD = @readline_link@ @TERMCAP_LIB@ $(LDADD)
|
||||
|
||||
|
|
|
@ -6,26 +6,19 @@
|
|||
# that will run on all platforms (or incorporate it into the
|
||||
# standard mysql-test-run).
|
||||
|
||||
#test_data_dir=/tmp/mysql-data
|
||||
test_data_dir=../../mysql-test/var/master-data
|
||||
cd "$test_data_dir" || {
|
||||
echo "can't cd to $test_data_dir" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
# All paths below must be relative to $test_data_dir
|
||||
#top_builddir=/home/tim/my/4
|
||||
top_builddir=../../..
|
||||
top_builddir=../..
|
||||
mysql_test_dir=$top_builddir/mysql-test
|
||||
examples=$top_builddir/libmysqld/examples
|
||||
mysqltest=$examples/mysqltest
|
||||
testdir=./test
|
||||
|
||||
datadir=$mysql_test_dir/var/master-data
|
||||
test_data_dir=test
|
||||
gdb=0
|
||||
list=0
|
||||
run=
|
||||
tests=
|
||||
start=
|
||||
clean=1
|
||||
|
||||
cr="
|
||||
"
|
||||
|
@ -35,6 +28,7 @@ usage () {
|
|||
cat <<EOF
|
||||
usage: $0 [-g|-h|-r] [test-name ...]
|
||||
|
||||
-C | --noclean Do not remove old innodb and bdb files at start.
|
||||
-g | --gdb run $mysqltest in gdb
|
||||
-h | --help show this help
|
||||
-l | --list ) list all available tests
|
||||
|
@ -43,6 +37,7 @@ usage: $0 [-g|-h|-r] [test-name ...]
|
|||
EOF
|
||||
}
|
||||
|
||||
init_args=""
|
||||
while test $# -gt 0
|
||||
do
|
||||
arg=
|
||||
|
@ -56,6 +51,8 @@ do
|
|||
-h | --help | -\? ) usage; exit 0;;
|
||||
-l | --list ) list=1 ; shift ;;
|
||||
-r | --run ) run="${cr}run"; shift;;
|
||||
--debug) init_args="$init_args --debug" ; shift ;;
|
||||
-C | --noclean) clean=0 ; shift ;;
|
||||
-s | --start=* )
|
||||
test $argset -eq 0 && { shift; arg="$1"; }
|
||||
start="$arg"
|
||||
|
@ -66,25 +63,30 @@ do
|
|||
esac
|
||||
done
|
||||
|
||||
test -d "$mysql_test_dir/t" -a -d "$mysql_test_dir/r" -a \
|
||||
-f $mysqltest -a -d $testdir || {
|
||||
echo "bad setup (is '$testdir', from '$test_data_dir', missing?)" >&2
|
||||
if test ! -d "$datadir/$test_data_dir"
|
||||
then
|
||||
echo "bad setup (is '$datadir/$test_data_dir'', missing ?)" >&2
|
||||
exit 1
|
||||
}
|
||||
fi
|
||||
|
||||
test -n "$tests" ||
|
||||
tests=`/bin/ls -1 "$mysql_test_dir"/t/*.test | grep -v '^.*/rpl[^/]*$' | \
|
||||
sed -e 's,^.*/,,' -e 's,.test$,,'`
|
||||
|
||||
echo "cleaning data directory '$test_data_dir'"
|
||||
rm -f $test_data_dir/ib_* $test_data_dir/ibdata* log.*
|
||||
echo "cleaning test directory '$testdir'"
|
||||
rm -f $testdir/*
|
||||
|
||||
echo "cleaning data directory '$datadir/$test_data_dir'"
|
||||
if test $clean = 1
|
||||
then
|
||||
rm -f $datadir/ib_* $datadir/ibdata*
|
||||
rm -f $datadir/log.00*
|
||||
fi
|
||||
rm -f $datadir/../tmp/*
|
||||
rm -f test-gdbinit
|
||||
|
||||
TZ=GMT-3; export TZ
|
||||
|
||||
# At least one of the tests needs the following environment variable
|
||||
MYSQL_TEST_DIR=`( cd $mysql_test_dir ; pwd )` ; export MYSQL_TEST_DIR
|
||||
|
||||
skip=1
|
||||
test -z "$start" && skip=0
|
||||
|
||||
|
@ -94,16 +96,20 @@ do
|
|||
test $skip -eq 1 && test -n "$start" && test "$start" = "$b" && skip=0
|
||||
test $skip -eq 1 && { echo "skipping '$b'"; continue; }
|
||||
|
||||
t="$mysql_test_dir/t/$b.test"
|
||||
r="$mysql_test_dir/r/$b.result"
|
||||
c="$mysql_test_dir/r/$b.reject"
|
||||
t="t/$b.test"
|
||||
r="r/$b.result"
|
||||
|
||||
# Only test if $t exists; there is no $r for some tests
|
||||
test -f $t || {
|
||||
echo "test '$b' doesn't exist" >&2
|
||||
test -f $mysql_test_dir/$t || {
|
||||
echo "test '$mysql_test_dir/$t' doesn't exist" >&2
|
||||
continue
|
||||
}
|
||||
args="-v -S /tmp/mysql.sock -R $r -x $t test"
|
||||
args="$init_args -v --basedir=$mysql_test_dir/ -R $r -x $t --server-arg=--datadir=$datadir"
|
||||
if test -f "$mysql_test_dir/t/$b-master.opt" ; then
|
||||
args="$args --server-file=t/$b-master.opt"
|
||||
fi
|
||||
|
||||
args="$args $test_data_dir" # Add database last
|
||||
echo "set args $args$run" > test-gdbinit
|
||||
#if false && test -n "$run"
|
||||
if test -n "$run" -o $gdb -eq 1
|
||||
|
@ -127,5 +133,5 @@ do
|
|||
res=$?
|
||||
fi
|
||||
|
||||
test $res -eq 0 || echo "!!! error: $res"
|
||||
test $res -eq 0 -o $res -eq 2 || echo "!!! error: $res"
|
||||
done
|
||||
|
|
|
@ -12,19 +12,21 @@
|
|||
* modified is included with the above copyright notice.
|
||||
*
|
||||
*/
|
||||
#include "my_global.h"
|
||||
#include "my_pthread.h"
|
||||
#include "embedded_priv.h"
|
||||
#include "sys/types.h"
|
||||
#include "../regex/regex.h"
|
||||
#include "my_sys.h"
|
||||
|
||||
/*
|
||||
The following is needed to not cause conflicts when we include mysqld.cc
|
||||
*/
|
||||
|
||||
#define main main1
|
||||
#define mysql_unix_port mysql_inix_port1
|
||||
#define mysql_port mysql_port1
|
||||
#define net_read_timeout net_read_timeout1
|
||||
#define net_write_timeout net_write_timeout1
|
||||
#define changeable_vars changeable_vars1
|
||||
//#define mysql_tmpdir mysql_tmpdir1
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
@ -35,38 +37,21 @@ extern "C"
|
|||
|
||||
class THD;
|
||||
|
||||
static int
|
||||
check_connections1(THD * thd);
|
||||
|
||||
static bool
|
||||
check_user(THD *thd, enum_server_command command,const char *user, const char *passwd, const char *db, bool check_count);
|
||||
|
||||
static int
|
||||
check_connections2(THD * thd);
|
||||
|
||||
extern void free_defaults(char ** argv);
|
||||
void free_defaults_internal(char ** argv){if (argv) free_defaults(argv);}
|
||||
static int check_connections1(THD * thd);
|
||||
static int check_connections2(THD * thd);
|
||||
static bool check_user(THD *thd, enum_server_command command,
|
||||
const char *user, const char *passwd, const char *db,
|
||||
bool check_count);
|
||||
void free_defaults_internal(char ** argv) {if (argv) free_defaults(argv);}
|
||||
#define free_defaults free_defaults_internal
|
||||
|
||||
char mysql_data_home[FN_REFLEN];
|
||||
char * get_mysql_data_home(){return mysql_data_home;};
|
||||
#define mysql_data_home mysql_data_home_internal
|
||||
#include "../sql/mysqld.cc"
|
||||
|
||||
#define SCRAMBLE_LENGTH 8
|
||||
extern "C" {
|
||||
C_MODE_START
|
||||
|
||||
/*
|
||||
void
|
||||
free_defaults(char ** argv) {};
|
||||
void
|
||||
load_defaults(const char *, const char **, int *, char ***) {};
|
||||
*/
|
||||
|
||||
char *
|
||||
get_mysql_home(){ return mysql_home;};
|
||||
char *
|
||||
get_mysql_real_data_home(){ return mysql_real_data_home;};
|
||||
char * get_mysql_home(){ return mysql_home;};
|
||||
char * get_mysql_real_data_home(){ return mysql_real_data_home;};
|
||||
|
||||
|
||||
bool lib_dispatch_command(enum enum_server_command command, NET *net,
|
||||
|
@ -82,9 +67,7 @@ bool lib_dispatch_command(enum enum_server_command command, NET *net,
|
|||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
lib_connection_phase(NET * net, int phase)
|
||||
void lib_connection_phase(NET * net, int phase)
|
||||
{
|
||||
THD * thd;
|
||||
thd = (THD *)(net->vio->dest_thd);
|
||||
|
@ -98,7 +81,9 @@ lib_connection_phase(NET * net, int phase)
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
C_MODE_END
|
||||
|
||||
|
||||
void start_embedded_conn1(NET * net)
|
||||
{
|
||||
THD * thd = new THD;
|
||||
|
@ -116,7 +101,6 @@ void start_embedded_conn1(NET * net)
|
|||
if (v)
|
||||
{
|
||||
v -> dest_thd = thd;
|
||||
/* v -> dest_net = &thd->net; XXX: Probably not needed? */
|
||||
}
|
||||
thd->net.vio = v;
|
||||
if (thd->store_globals())
|
||||
|
@ -256,7 +240,7 @@ static bool check_user(THD *thd,enum_server_command command, const char *user,
|
|||
send_error(net,ER_OUT_OF_RESOURCES);
|
||||
return 1;
|
||||
}
|
||||
thd->master_access=acl_getroot(thd->host, thd->ip, thd->user,
|
||||
thd->master_access=acl_getroot(thd, thd->host, thd->ip, thd->user,
|
||||
passwd, thd->scramble, &thd->priv_user,
|
||||
protocol_version == 9 ||
|
||||
!(thd->client_capabilities &
|
||||
|
@ -307,10 +291,14 @@ static bool check_user(THD *thd,enum_server_command command, const char *user,
|
|||
}
|
||||
|
||||
|
||||
extern "C"{
|
||||
void mysql_server_init(int argc, const char **argv, const char **groups)
|
||||
extern "C"
|
||||
{
|
||||
char hostname[FN_REFLEN];
|
||||
|
||||
static my_bool inited, org_my_init_done;
|
||||
|
||||
int mysql_server_init(int argc, char **argv, char **groups)
|
||||
{
|
||||
char glob_hostname[FN_REFLEN];
|
||||
|
||||
/* This mess is to allow people to call the init function without
|
||||
* having to mess with a fake argv */
|
||||
|
@ -318,7 +306,7 @@ void mysql_server_init(int argc, const char **argv, const char **groups)
|
|||
char ***argvp;
|
||||
int fake_argc = 1;
|
||||
char *fake_argv[] = { (char *)"", 0 };
|
||||
const char *fake_groups[] = { "server", 0 };
|
||||
const char *fake_groups[] = { "server", "embedded", 0 };
|
||||
if (argc)
|
||||
{
|
||||
argcp = &argc;
|
||||
|
@ -330,11 +318,22 @@ void mysql_server_init(int argc, const char **argv, const char **groups)
|
|||
argvp = (char ***) &fake_argv;
|
||||
}
|
||||
if (!groups)
|
||||
groups = fake_groups;
|
||||
groups = (char**) fake_groups;
|
||||
|
||||
my_umask=0660; // Default umask for new files
|
||||
my_umask_dir=0700; // Default umask for new directories
|
||||
MY_INIT((char *)"mysqld_server"); // init my_sys library & pthreads
|
||||
|
||||
/* Only call MY_INIT() if it hasn't been called before */
|
||||
if (!inited)
|
||||
{
|
||||
inited=1;
|
||||
org_my_init_done=my_init_done;
|
||||
}
|
||||
if (!org_my_init_done)
|
||||
{
|
||||
MY_INIT((char *)"mysql_embedded"); // init my_sys library & pthreads
|
||||
}
|
||||
|
||||
tzset(); // Set tzname
|
||||
|
||||
start_time=time((time_t*) 0);
|
||||
|
@ -343,49 +342,34 @@ void mysql_server_init(int argc, const char **argv, const char **groups)
|
|||
{
|
||||
struct tm tm_tmp;
|
||||
localtime_r(&start_time,&tm_tmp);
|
||||
strmov(time_zone,tzname[tm_tmp.tm_isdst == 1 ? 1 : 0]);
|
||||
strmov(time_zone,tzname[tm_tmp.tm_isdst != 0 ? 1 : 0]);
|
||||
}
|
||||
#else
|
||||
{
|
||||
struct tm *start_tm;
|
||||
start_tm=localtime(&start_time);
|
||||
strmov(time_zone=tzname[start_tm->tm_isdst == 1 ? 1 : 0]);
|
||||
strmov(time_zone,tzname[start_tm->tm_isdst != 0 ? 1 : 0]);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (gethostname(hostname,sizeof(hostname)-4) < 0)
|
||||
strmov(hostname,"mysql");
|
||||
strmov(pidfile_name,hostname);
|
||||
strmov(strcend(pidfile_name,'.'),".pid"); // Add extension
|
||||
#ifdef DEMO_VERSION
|
||||
strcat(server_version,"-demo");
|
||||
#endif
|
||||
#ifdef SHAREWARE_VERSION
|
||||
strcat(server_version,"-shareware");
|
||||
#endif
|
||||
if (gethostname(glob_hostname,sizeof(glob_hostname)-4) < 0)
|
||||
strmov(glob_hostname,"mysql");
|
||||
#ifndef DBUG_OFF
|
||||
strcat(server_version,"-debug");
|
||||
#endif
|
||||
strcat(server_version,"-library-ver");
|
||||
#ifdef _CUSTOMSTARTUPCONFIG_
|
||||
if (_cust_check_startup())
|
||||
{
|
||||
/* _cust_check_startup will report startup failure error */
|
||||
exit( 1 );
|
||||
}
|
||||
#endif
|
||||
load_defaults("my", groups, argcp, argvp);
|
||||
strcat(server_version,"-embedded");
|
||||
load_defaults("my", (const char **) groups, argcp, argvp);
|
||||
defaults_argv=*argvp;
|
||||
mysql_tmpdir=getenv("TMPDIR"); /* Use this if possible */
|
||||
#ifdef __WIN__
|
||||
#if defined( __WIN__) || defined(OS2)
|
||||
if (!mysql_tmpdir)
|
||||
mysql_tmpdir=getenv("TEMP");
|
||||
if (!mysql_tmpdir)
|
||||
mysql_tmpdir=getenv("TMP");
|
||||
#endif
|
||||
if (!mysql_tmpdir || !mysql_tmpdir[0])
|
||||
mysql_tmpdir=strdup((char*) P_tmpdir);
|
||||
mysql_tmpdir=(char*) P_tmpdir; /* purecov: inspected */
|
||||
set_options();
|
||||
get_options(*argcp, *argvp);
|
||||
|
||||
|
@ -426,23 +410,20 @@ void mysql_server_init(int argc, const char **argv, const char **groups)
|
|||
(void) pthread_cond_init(&COND_slave_start, NULL);
|
||||
|
||||
if (set_default_charset_by_name(default_charset, MYF(MY_WME)))
|
||||
unireg_abort(1);
|
||||
{
|
||||
mysql_server_end();
|
||||
return 1;
|
||||
}
|
||||
charsets_list = list_charsets(MYF(MY_COMPILED_SETS|MY_CONFIG_SETS));
|
||||
|
||||
|
||||
if (!(opt_specialflag & SPECIAL_NO_PRIOR))
|
||||
my_pthread_setprio(pthread_self(),CONNECT_PRIOR);
|
||||
/* Parameter for threads created for connections */
|
||||
(void) pthread_attr_init(&connection_attrib);
|
||||
(void) pthread_attr_setdetachstate(&connection_attrib,
|
||||
PTHREAD_CREATE_DETACHED);
|
||||
pthread_attr_setstacksize(&connection_attrib,thread_stack);
|
||||
|
||||
if (!(opt_specialflag & SPECIAL_NO_PRIOR))
|
||||
my_pthread_attr_setprio(&connection_attrib,WAIT_PRIOR);
|
||||
pthread_attr_setscope(&connection_attrib, PTHREAD_SCOPE_SYSTEM);
|
||||
|
||||
#ifdef SET_RLIMIT_NOFILE
|
||||
#if defined( SET_RLIMIT_NOFILE) || defined( OS2)
|
||||
/* connections and databases neads lots of files */
|
||||
{
|
||||
uint wanted_files=10+(uint) max(max_connections*5,
|
||||
|
@ -467,64 +448,57 @@ void mysql_server_init(int argc, const char **argv, const char **groups)
|
|||
#ifdef USE_REGEX
|
||||
regex_init();
|
||||
#endif
|
||||
select_thread=pthread_self();
|
||||
select_thread_in_use=1;
|
||||
if (use_temp_pool && bitmap_init(&temp_pool,1024))
|
||||
{
|
||||
mysql_server_end();
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
** We have enough space for fiddling with the argv, continue
|
||||
*/
|
||||
umask(((~my_umask) & 0666));
|
||||
// strcpy(mysql_real_data_home, "/usr/local");
|
||||
//if (my_setwd(mysql_real_data_home,MYF(MY_WME)))
|
||||
//{
|
||||
// unireg_abort(1); /* purecov: inspected */
|
||||
//}
|
||||
//mysql_data_home[0]=FN_CURLIB; // all paths are relative from here
|
||||
//mysql_data_home[1]=0;
|
||||
|
||||
strcpy(get_mysql_data_home(), mysql_real_data_home);
|
||||
|
||||
//server_init();
|
||||
table_cache_init();
|
||||
hostname_cache_init();
|
||||
sql_cache_init();
|
||||
randominit(&sql_rand,(ulong) start_time,(ulong) start_time/2);
|
||||
reset_floating_point_exceptions();
|
||||
init_thr_lock();
|
||||
init_slave_list();
|
||||
|
||||
/* Setup log files */
|
||||
if (opt_log)
|
||||
open_log(&mysql_log, hostname, opt_logname, ".log", LOG_NORMAL);
|
||||
open_log(&mysql_log, glob_hostname, opt_logname, ".log", LOG_NORMAL);
|
||||
if (opt_update_log)
|
||||
open_log(&mysql_update_log, hostname, opt_update_logname, "",
|
||||
{
|
||||
open_log(&mysql_update_log, glob_hostname, opt_update_logname, "",
|
||||
LOG_NEW);
|
||||
using_update_log=1;
|
||||
}
|
||||
if (opt_bin_log)
|
||||
{
|
||||
if(server_id)
|
||||
{
|
||||
if (!opt_bin_logname)
|
||||
{
|
||||
char tmp[FN_REFLEN];
|
||||
strnmov(tmp,hostname,FN_REFLEN-5);
|
||||
strmov(strcend(tmp,'.'),"-bin");
|
||||
opt_bin_logname=my_strdup(tmp,MYF(MY_WME));
|
||||
}
|
||||
mysql_bin_log.set_index_file_name(opt_binlog_index_name);
|
||||
open_log(&mysql_bin_log, hostname, opt_bin_logname, "-bin",
|
||||
LOG_BIN);
|
||||
}
|
||||
else
|
||||
sql_print_error("Server id is not set - binary logging disabled");
|
||||
if (!opt_bin_logname)
|
||||
{
|
||||
char tmp[FN_REFLEN];
|
||||
strmake(tmp,glob_hostname,FN_REFLEN-5);
|
||||
strmov(strcend(tmp,'.'),"-bin");
|
||||
opt_bin_logname=my_strdup(tmp,MYF(MY_WME));
|
||||
}
|
||||
mysql_bin_log.set_index_file_name(opt_binlog_index_name);
|
||||
open_log(&mysql_bin_log, glob_hostname, opt_bin_logname, "-bin",
|
||||
LOG_BIN);
|
||||
using_update_log=1;
|
||||
}
|
||||
|
||||
if (opt_slow_log)
|
||||
open_log(&mysql_slow_log, hostname, opt_slow_logname, "-slow.log",
|
||||
open_log(&mysql_slow_log, glob_hostname, opt_slow_logname, "-slow.log",
|
||||
LOG_NORMAL);
|
||||
if (ha_init())
|
||||
{
|
||||
sql_print_error("Can't init databases");
|
||||
exit(1);
|
||||
}
|
||||
ha_key_cache();
|
||||
#ifdef HAVE_MLOCKALL
|
||||
if (locked_in_memory && !geteuid())
|
||||
{
|
||||
|
@ -555,120 +529,73 @@ void mysql_server_init(int argc, const char **argv, const char **groups)
|
|||
sql_print_error("Can't create thread-keys");
|
||||
exit(1);
|
||||
}
|
||||
//init_signals();
|
||||
opt_noacl = 1;
|
||||
opt_noacl = 1; // No permissions
|
||||
if (acl_init(opt_noacl))
|
||||
{
|
||||
select_thread_in_use=0;
|
||||
(void) pthread_kill(signal_thread,MYSQL_KILL_SIGNAL);
|
||||
exit(1);
|
||||
mysql_server_end();
|
||||
return 1;
|
||||
}
|
||||
if (!opt_noacl)
|
||||
(void) grant_init();
|
||||
|
||||
#ifdef HAVE_DLOPEN
|
||||
if (!opt_noacl)
|
||||
udf_init();
|
||||
#endif
|
||||
|
||||
if (opt_bootstrap)
|
||||
{
|
||||
int error=bootstrap(stdin);
|
||||
end_thr_alarm(); // Don't allow alarms
|
||||
unireg_abort(error ? 1 : 0);
|
||||
}
|
||||
if (opt_init_file)
|
||||
{
|
||||
if (read_init_file(opt_init_file))
|
||||
{
|
||||
end_thr_alarm(); // Don't allow alarms
|
||||
unireg_abort(1);
|
||||
}
|
||||
}
|
||||
(void) thr_setconcurrency(concurrency); // 10 by default
|
||||
|
||||
if (flush_time && flush_time != ~(ulong) 0L)
|
||||
if (
|
||||
#ifdef HAVE_BERKELEY_DB
|
||||
!berkeley_skip ||
|
||||
#endif
|
||||
(flush_time && flush_time != ~(ulong) 0L))
|
||||
{
|
||||
pthread_t hThread;
|
||||
if (pthread_create(&hThread,&connection_attrib,handle_manager,0))
|
||||
{
|
||||
sql_print_error("Warning: Can't create thread to manage maintenance");
|
||||
mysql_server_end();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
// slave thread
|
||||
if(master_host)
|
||||
{
|
||||
if(server_id)
|
||||
{
|
||||
pthread_t hThread;
|
||||
if(!opt_skip_slave_start &&
|
||||
pthread_create(&hThread, &connection_attrib, handle_slave, 0))
|
||||
sql_print_error("Warning: Can't create thread to handle slave");
|
||||
}
|
||||
else
|
||||
sql_print_error("Server id is not set, slave thread will not be started");
|
||||
}
|
||||
|
||||
//printf(ER(ER_READY),my_progname,server_version,"");
|
||||
//printf("%s initialized.\n", server_version);
|
||||
fflush(stdout);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void mysql_server_end()
|
||||
{
|
||||
/* (void) pthread_attr_destroy(&connection_attrib); */
|
||||
|
||||
DBUG_PRINT("quit",("Exiting main thread"));
|
||||
|
||||
#ifdef EXTRA_DEBUG
|
||||
sql_print_error("Before Lock_thread_count");
|
||||
clean_up(0);
|
||||
#ifdef THREAD
|
||||
/* Don't call my_thread_end() if the application is using MY_INIT() */
|
||||
if (!org_my_init_done)
|
||||
my_thread_end();
|
||||
#endif
|
||||
(void) pthread_mutex_lock(&LOCK_thread_count);
|
||||
select_thread_in_use=0; // For close_connections
|
||||
(void) pthread_cond_broadcast(&COND_thread_count);
|
||||
(void) pthread_mutex_unlock(&LOCK_thread_count);
|
||||
#ifdef EXTRA_DEBUG
|
||||
sql_print_error("After lock_thread_count");
|
||||
#endif
|
||||
|
||||
// /* Wait until cleanup is done */
|
||||
// (void) pthread_mutex_lock(&LOCK_thread_count);
|
||||
// while (!ready_to_exit)
|
||||
// {
|
||||
// pthread_cond_wait(&COND_thread_count,&LOCK_thread_count);
|
||||
// }
|
||||
// (void) pthread_mutex_unlock(&LOCK_thread_count);
|
||||
unireg_end(0);
|
||||
my_thread_end();
|
||||
}
|
||||
|
||||
my_bool mysql_thread_init()
|
||||
{
|
||||
#ifdef THREAD
|
||||
return my_thread_init();
|
||||
return my_thread_init();
|
||||
#else
|
||||
return 0;
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void mysql_thread_end()
|
||||
{
|
||||
#ifdef THREAD
|
||||
my_thread_end();
|
||||
my_thread_end();
|
||||
#endif
|
||||
}
|
||||
|
||||
void start_embedded_connection(NET * net)
|
||||
{
|
||||
start_embedded_conn1(net);
|
||||
start_embedded_conn1(net);
|
||||
}
|
||||
//====================================================================
|
||||
}
|
||||
int embedded_do_command(NET * net)
|
||||
|
||||
void end_embedded_connection(NET * net)
|
||||
{
|
||||
THD * thd = (THD *) net ->vio;
|
||||
do_command(thd);
|
||||
return 0;
|
||||
THD *thd = (THD *) net->vio->dest_thd;
|
||||
delete thd;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} /* extern "C" */
|
||||
|
|
|
@ -23,12 +23,13 @@
|
|||
*/
|
||||
|
||||
#include <my_global.h>
|
||||
#include "mysql_embed.h"
|
||||
#include "mysql.h"
|
||||
|
||||
#ifndef HAVE_VIO /* is Vio suppored by the Vio lib ? */
|
||||
#ifndef HAVE_VIO /* is Vio enabled */
|
||||
|
||||
#include <errno.h>
|
||||
#include <my_sys.h>
|
||||
#include "mysql.h"
|
||||
#include <violite.h>
|
||||
#include <my_sys.h>
|
||||
#include <my_net.h>
|
||||
|
@ -36,27 +37,6 @@
|
|||
#include <dbug.h>
|
||||
#include <assert.h>
|
||||
|
||||
#if defined(__EMX__)
|
||||
#include <sys/ioctl.h>
|
||||
#define ioctlsocket(A,B,C) ioctl((A),(B),(void *)(C),sizeof(*(C)))
|
||||
#undef HAVE_FCNTL
|
||||
#endif /* defined(__EMX__) */
|
||||
|
||||
#if defined(MSDOS) || defined(__WIN__)
|
||||
#ifdef __WIN__
|
||||
#undef errno
|
||||
#undef EINTR
|
||||
#undef EAGAIN
|
||||
#define errno WSAGetLastError()
|
||||
#define EINTR WSAEINTR
|
||||
#define EAGAIN WSAEINPROGRESS
|
||||
#endif /* __WIN__ */
|
||||
#define O_NONBLOCK 1 /* For emulation of fcntl() */
|
||||
#endif
|
||||
#ifndef EWOULDBLOCK
|
||||
#define EWOULDBLOCK EAGAIN
|
||||
#endif
|
||||
|
||||
#ifndef __WIN__
|
||||
#define HANDLE void *
|
||||
#endif
|
||||
|
@ -71,14 +51,11 @@ struct st_vio
|
|||
struct sockaddr_in remote; /* Remote internet address */
|
||||
enum enum_vio_type type; /* Type of connection */
|
||||
char desc[30]; /* String description */
|
||||
/* #ifdef EMBEDDED_LIBRARY */
|
||||
/* void *dest_net; */
|
||||
void *dest_thd;
|
||||
char *packets, **last_packet;
|
||||
char *where_in_packet, *end_of_packet;
|
||||
my_bool reading;
|
||||
MEM_ROOT root;
|
||||
/* #endif */
|
||||
};
|
||||
|
||||
/* Initialize the communication buffer */
|
||||
|
@ -89,7 +66,7 @@ Vio *vio_new(my_socket sd, enum enum_vio_type type, my_bool localhost)
|
|||
vio = (Vio *) my_malloc (sizeof(*vio),MYF(MY_WME|MY_ZEROFILL));
|
||||
if (vio)
|
||||
{
|
||||
init_alloc_root(&vio->root, 8192, 1024);
|
||||
init_alloc_root(&vio->root, 8192, 8192);
|
||||
vio->root.min_malloc = sizeof(char *) + 4;
|
||||
vio->last_packet = &vio->packets;
|
||||
}
|
||||
|
@ -125,7 +102,7 @@ void vio_reset(Vio *vio)
|
|||
|
||||
int vio_errno(Vio *vio __attribute__((unused)))
|
||||
{
|
||||
return errno; /* On Win32 this mapped to WSAGetLastError() */
|
||||
return socket_errno; /* On Win32 this mapped to WSAGetLastError() */
|
||||
}
|
||||
|
||||
int vio_read(Vio * vio, gptr buf, int size)
|
||||
|
@ -197,8 +174,9 @@ int vio_keepalive(Vio* vio, my_bool set_keep_alive)
|
|||
my_bool
|
||||
vio_should_retry(Vio * vio __attribute__((unused)))
|
||||
{
|
||||
int en = errno;
|
||||
return en == EAGAIN || en == EINTR || en == EWOULDBLOCK;
|
||||
int en = socket_errno;
|
||||
return (en == SOCKET_EAGAIN || en == SOCKET_EINTR ||
|
||||
en == SOCKET_EWOULDBLOCK);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -15,19 +15,11 @@
|
|||
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
||||
MA 02111-1307, USA */
|
||||
|
||||
#define DONT_USE_RAID
|
||||
#include <my_global.h>
|
||||
#if defined(__WIN__) || defined(_WIN32) || defined(_WIN64)
|
||||
#include <winsock.h>
|
||||
#include <odbcinst.h>
|
||||
#endif
|
||||
#include "embedded_priv.h"
|
||||
#include <my_sys.h>
|
||||
#include <mysys_err.h>
|
||||
#include <m_string.h>
|
||||
#include <m_ctype.h>
|
||||
#include "mysql.h"
|
||||
#include "mysql_version.h"
|
||||
#include "mysqld_error.h"
|
||||
#include "errmsg.h"
|
||||
#include <violite.h>
|
||||
#include <sys/stat.h>
|
||||
|
@ -51,9 +43,6 @@
|
|||
#ifdef HAVE_SYS_UN_H
|
||||
# include <sys/un.h>
|
||||
#endif
|
||||
#if defined(THREAD) && !defined(__WIN__)
|
||||
#include <my_pthread.h> /* because of signal() */
|
||||
#endif
|
||||
#ifndef INADDR_NONE
|
||||
#define INADDR_NONE -1
|
||||
#endif
|
||||
|
@ -74,12 +63,6 @@ my_string mysql_unix_port=0;
|
|||
#define closesocket(A) close(A)
|
||||
#endif
|
||||
|
||||
/* XXX: this is real ugly... */
|
||||
extern void start_embedded_connection(NET * net);
|
||||
extern void lib_connection_phase(NET *net, int phase);
|
||||
extern bool lib_dispatch_command(enum enum_server_command command, NET *net,
|
||||
const char *arg, ulong length);
|
||||
|
||||
static void mysql_once_init(void);
|
||||
static MYSQL_DATA *read_rows (MYSQL *mysql,MYSQL_FIELD *fields,
|
||||
uint field_count);
|
||||
|
@ -88,9 +71,7 @@ static int read_one_row(MYSQL *mysql,uint fields,MYSQL_ROW row,
|
|||
static void end_server(MYSQL *mysql);
|
||||
static void read_user_name(char *name);
|
||||
static void append_wild(char *to,char *end,const char *wild);
|
||||
static my_bool mysql_reconnect(MYSQL *mysql);
|
||||
static int send_file_to_server(MYSQL *mysql,const char *filename);
|
||||
static sig_handler pipe_sig_handler(int sig);
|
||||
static ulong mysql_sub_escape_string(CHARSET_INFO *charset_info, char *to,
|
||||
const char *from, ulong length);
|
||||
|
||||
|
@ -98,17 +79,12 @@ static ulong mysql_sub_escape_string(CHARSET_INFO *charset_info, char *to,
|
|||
#define set_sigpipe(mysql)
|
||||
#define reset_sigpipe(mysql)
|
||||
|
||||
static MYSQL* spawn_init(MYSQL* parent, const char* host,
|
||||
unsigned int port,
|
||||
const char* user,
|
||||
const char* passwd);
|
||||
|
||||
/*****************************************************************************
|
||||
** read a packet from server. Give error message if socket was down
|
||||
** or packet is an error message
|
||||
*****************************************************************************/
|
||||
|
||||
static uint
|
||||
ulong
|
||||
net_safe_read(MYSQL *mysql)
|
||||
{
|
||||
NET *net= &mysql->net;
|
||||
|
@ -237,9 +213,9 @@ static void free_rows(MYSQL_DATA *cur)
|
|||
}
|
||||
|
||||
|
||||
static int
|
||||
int
|
||||
simple_command(MYSQL *mysql,enum enum_server_command command, const char *arg,
|
||||
uint length, my_bool skipp_check)
|
||||
ulong length, my_bool skipp_check)
|
||||
{
|
||||
NET *net= &mysql->net;
|
||||
int result= -1;
|
||||
|
@ -403,22 +379,6 @@ mysql_debug(const char *debug)
|
|||
#endif
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
** Close the server connection if we get a SIGPIPE
|
||||
ARGSUSED
|
||||
**************************************************************************/
|
||||
|
||||
static sig_handler
|
||||
pipe_sig_handler(int sig __attribute__((unused)))
|
||||
{
|
||||
DBUG_PRINT("info",("Hit by signal %d",sig));
|
||||
#ifdef DONT_REMEMBER_SIGNAL
|
||||
(void) signal(SIGPIPE,pipe_sig_handler);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
** Shut down connection
|
||||
**************************************************************************/
|
||||
|
@ -429,11 +389,7 @@ end_server(MYSQL *mysql)
|
|||
DBUG_ENTER("end_server");
|
||||
if (mysql->net.vio != 0)
|
||||
{
|
||||
init_sigpipe_variables
|
||||
DBUG_PRINT("info",("Net: %s", vio_description(mysql->net.vio)));
|
||||
set_sigpipe(mysql);
|
||||
vio_delete(mysql->net.vio);
|
||||
reset_sigpipe(mysql);
|
||||
end_embedded_connection(&mysql->net);
|
||||
mysql->net.vio= 0; /* Marker */
|
||||
}
|
||||
net_end(&mysql->net);
|
||||
|
@ -739,7 +695,7 @@ read_one_row(MYSQL *mysql,uint fields,MYSQL_ROW row, ulong *lengths)
|
|||
ulong pkt_len,len;
|
||||
uchar *pos,*prev_pos;
|
||||
|
||||
if ((pkt_len=(uint) net_safe_read(mysql)) == packet_error)
|
||||
if ((pkt_len=net_safe_read(mysql)) == packet_error)
|
||||
return -1;
|
||||
if (pkt_len == 1 && mysql->net.read_pos[0] == 254)
|
||||
return 1; /* End of data */
|
||||
|
@ -767,301 +723,6 @@ read_one_row(MYSQL *mysql,uint fields,MYSQL_ROW row, ulong *lengths)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* perform query on master */
|
||||
int STDCALL mysql_master_query(MYSQL *mysql, const char *q,
|
||||
unsigned int length)
|
||||
{
|
||||
if(mysql_master_send_query(mysql, q, length))
|
||||
return 1;
|
||||
return mysql_read_query_result(mysql);
|
||||
}
|
||||
|
||||
int STDCALL mysql_master_send_query(MYSQL *mysql, const char *q,
|
||||
unsigned int length)
|
||||
{
|
||||
MYSQL*master = mysql->master;
|
||||
if (!length)
|
||||
length = strlen(q);
|
||||
if (!master->net.vio && !mysql_real_connect(master,0,0,0,0,0,0,0))
|
||||
return 1;
|
||||
mysql->last_used_con = master;
|
||||
return simple_command(master, COM_QUERY, q, length, 1);
|
||||
}
|
||||
|
||||
|
||||
/* perform query on slave */
|
||||
int STDCALL mysql_slave_query(MYSQL *mysql, const char *q,
|
||||
unsigned int length)
|
||||
{
|
||||
if(mysql_slave_send_query(mysql, q, length))
|
||||
return 1;
|
||||
return mysql_read_query_result(mysql);
|
||||
}
|
||||
|
||||
int STDCALL mysql_slave_send_query(MYSQL *mysql, const char *q,
|
||||
unsigned int length)
|
||||
{
|
||||
MYSQL* last_used_slave, *slave_to_use = 0;
|
||||
|
||||
if((last_used_slave = mysql->last_used_slave))
|
||||
slave_to_use = last_used_slave->next_slave;
|
||||
else
|
||||
slave_to_use = mysql->next_slave;
|
||||
/* next_slave is always safe to use - we have a circular list of slaves
|
||||
if there are no slaves, mysql->next_slave == mysql
|
||||
*/
|
||||
mysql->last_used_con = mysql->last_used_slave = slave_to_use;
|
||||
if(!length)
|
||||
length = strlen(q);
|
||||
if(!slave_to_use->net.vio && !mysql_real_connect(slave_to_use, 0,0,0,
|
||||
0,0,0,0))
|
||||
return 1;
|
||||
return simple_command(slave_to_use, COM_QUERY, q, length, 1);
|
||||
}
|
||||
|
||||
|
||||
/* enable/disable parsing of all queries to decide
|
||||
if they go on master or slave */
|
||||
void STDCALL mysql_enable_rpl_parse(MYSQL* mysql)
|
||||
{
|
||||
mysql->options.rpl_parse = 1;
|
||||
}
|
||||
|
||||
void STDCALL mysql_disable_rpl_parse(MYSQL* mysql)
|
||||
{
|
||||
mysql->options.rpl_parse = 0;
|
||||
}
|
||||
|
||||
/* get the value of the parse flag */
|
||||
int STDCALL mysql_rpl_parse_enabled(MYSQL* mysql)
|
||||
{
|
||||
return mysql->options.rpl_parse;
|
||||
}
|
||||
|
||||
/* enable/disable reads from master */
|
||||
void STDCALL mysql_enable_reads_from_master(MYSQL* mysql)
|
||||
{
|
||||
mysql->options.no_master_reads = 0;
|
||||
}
|
||||
|
||||
void STDCALL mysql_disable_reads_from_master(MYSQL* mysql)
|
||||
{
|
||||
mysql->options.no_master_reads = 1;
|
||||
}
|
||||
|
||||
/* get the value of the master read flag */
|
||||
int STDCALL mysql_reads_from_master_enabled(MYSQL* mysql)
|
||||
{
|
||||
return !(mysql->options.no_master_reads);
|
||||
}
|
||||
|
||||
/* We may get an error while doing replication internals.
|
||||
In this case, we add a special explanation to the original
|
||||
error
|
||||
*/
|
||||
static inline void expand_error(MYSQL* mysql, int error)
|
||||
{
|
||||
char tmp[MYSQL_ERRMSG_SIZE];
|
||||
char* p, *tmp_end;
|
||||
tmp_end = strnmov(tmp, mysql->net.last_error, MYSQL_ERRMSG_SIZE);
|
||||
p = strnmov(mysql->net.last_error, ER(error), MYSQL_ERRMSG_SIZE);
|
||||
memcpy(p, tmp, tmp_end - tmp);
|
||||
mysql->net.last_errno = error;
|
||||
}
|
||||
|
||||
/* This function assumes we have just called SHOW SLAVE STATUS and have
|
||||
read the given result and row
|
||||
*/
|
||||
static inline int get_master(MYSQL* mysql, MYSQL_RES* res, MYSQL_ROW row)
|
||||
{
|
||||
MYSQL* master;
|
||||
if(mysql_num_fields(res) < 3)
|
||||
return 1; /* safety */
|
||||
|
||||
/* use the same username and password as the original connection */
|
||||
if(!(master = spawn_init(mysql, row[0], atoi(row[2]), 0, 0)))
|
||||
return 1;
|
||||
mysql->master = master;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* assuming we already know that mysql points to a master connection,
|
||||
retrieve all the slaves
|
||||
*/
|
||||
static inline int get_slaves_from_master(MYSQL* mysql)
|
||||
{
|
||||
MYSQL_RES* res = 0;
|
||||
MYSQL_ROW row;
|
||||
int error = 1;
|
||||
int has_auth_info;
|
||||
if (!mysql->net.vio && !mysql_real_connect(mysql,0,0,0,0,0,0,0))
|
||||
{
|
||||
expand_error(mysql, CR_PROBE_MASTER_CONNECT);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (mysql_query(mysql, "SHOW SLAVE HOSTS") ||
|
||||
!(res = mysql_store_result(mysql)))
|
||||
{
|
||||
expand_error(mysql, CR_PROBE_SLAVE_HOSTS);
|
||||
return 1;
|
||||
}
|
||||
|
||||
switch (mysql_num_fields(res))
|
||||
{
|
||||
case 3: has_auth_info = 0; break;
|
||||
case 5: has_auth_info = 1; break;
|
||||
default:
|
||||
goto err;
|
||||
}
|
||||
|
||||
while ((row = mysql_fetch_row(res)))
|
||||
{
|
||||
MYSQL* slave;
|
||||
const char* tmp_user, *tmp_pass;
|
||||
|
||||
if (has_auth_info)
|
||||
{
|
||||
tmp_user = row[3];
|
||||
tmp_pass = row[4];
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp_user = mysql->user;
|
||||
tmp_pass = mysql->passwd;
|
||||
}
|
||||
|
||||
if(!(slave = spawn_init(mysql, row[1], atoi(row[2]),
|
||||
tmp_user, tmp_pass)))
|
||||
goto err;
|
||||
|
||||
/* Now add slave into the circular linked list */
|
||||
slave->next_slave = mysql->next_slave;
|
||||
mysql->next_slave = slave;
|
||||
}
|
||||
error = 0;
|
||||
err:
|
||||
if(res)
|
||||
mysql_free_result(res);
|
||||
return error;
|
||||
}
|
||||
|
||||
int STDCALL mysql_rpl_probe(MYSQL* mysql)
|
||||
{
|
||||
MYSQL_RES* res = 0;
|
||||
MYSQL_ROW row;
|
||||
int error = 1;
|
||||
/* first determine the replication role of the server we connected to
|
||||
the most reliable way to do this is to run SHOW SLAVE STATUS and see
|
||||
if we have a non-empty master host. This is still not fool-proof -
|
||||
it is not a sin to have a master that has a dormant slave thread with
|
||||
a non-empty master host. However, it is more reliable to check
|
||||
for empty master than whether the slave thread is actually running
|
||||
*/
|
||||
if (mysql_query(mysql, "SHOW SLAVE STATUS") ||
|
||||
!(res = mysql_store_result(mysql)))
|
||||
{
|
||||
expand_error(mysql, CR_PROBE_SLAVE_STATUS);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!(row = mysql_fetch_row(res)))
|
||||
goto err;
|
||||
|
||||
/* check master host for emptiness/NULL */
|
||||
if (row[0] && *(row[0]))
|
||||
{
|
||||
/* this is a slave, ask it for the master */
|
||||
if (get_master(mysql, res, row) || get_slaves_from_master(mysql))
|
||||
goto err;
|
||||
}
|
||||
else
|
||||
{
|
||||
mysql->master = mysql;
|
||||
if (get_slaves_from_master(mysql))
|
||||
goto err;
|
||||
}
|
||||
|
||||
error = 0;
|
||||
err:
|
||||
if(res)
|
||||
mysql_free_result(res);
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/* make a not so fool-proof decision on where the query should go, to
|
||||
the master or the slave. Ideally the user should always make this
|
||||
decision himself with mysql_master_query() or mysql_slave_query().
|
||||
However, to be able to more easily port the old code, we support the
|
||||
option of an educated guess - this should work for most applications,
|
||||
however, it may make the wrong decision in some particular cases. If
|
||||
that happens, the user would have to change the code to call
|
||||
mysql_master_query() or mysql_slave_query() explicitly in the place
|
||||
where we have made the wrong decision
|
||||
*/
|
||||
enum mysql_rpl_type
|
||||
STDCALL mysql_rpl_query_type(const char* q, int len)
|
||||
{
|
||||
const char* q_end;
|
||||
q_end = (len) ? q + len : strend(q);
|
||||
for(; q < q_end; ++q)
|
||||
{
|
||||
char c;
|
||||
if(isalpha(c=*q))
|
||||
switch(tolower(c))
|
||||
{
|
||||
case 'i': /* insert */
|
||||
case 'u': /* update or unlock tables */
|
||||
case 'l': /* lock tables or load data infile */
|
||||
case 'd': /* drop or delete */
|
||||
case 'a': /* alter */
|
||||
return MYSQL_RPL_MASTER;
|
||||
case 'c': /* create or check */
|
||||
return tolower(q[1]) == 'h' ? MYSQL_RPL_ADMIN : MYSQL_RPL_MASTER ;
|
||||
case 's': /* select or show */
|
||||
return tolower(q[1] == 'h') ? MYSQL_RPL_ADMIN : MYSQL_RPL_SLAVE;
|
||||
case 'f': /* flush */
|
||||
case 'r': /* repair */
|
||||
case 'g': /* grant */
|
||||
return MYSQL_RPL_ADMIN;
|
||||
default:
|
||||
return MYSQL_RPL_SLAVE;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static MYSQL* spawn_init(MYSQL* parent, const char* host,
|
||||
unsigned int port,
|
||||
const char* user,
|
||||
const char* passwd)
|
||||
{
|
||||
MYSQL* child;
|
||||
if (!(child = mysql_init(0)))
|
||||
return 0;
|
||||
|
||||
child->options.user = my_strdup((user) ? user :
|
||||
(parent->user ? parent->user :
|
||||
parent->options.user), MYF(0));
|
||||
child->options.password = my_strdup((passwd) ? passwd : (parent->passwd ?
|
||||
parent->passwd :
|
||||
parent->options.password), MYF(0));
|
||||
child->options.port = port;
|
||||
child->options.host = my_strdup((host) ? host : (parent->host ?
|
||||
parent->host :
|
||||
parent->options.host), MYF(0));
|
||||
if(parent->db)
|
||||
child->options.db = my_strdup(parent->db, MYF(0));
|
||||
else if(parent->options.db)
|
||||
child->options.db = my_strdup(parent->options.db, MYF(0));
|
||||
|
||||
child->options.rpl_parse = child->options.rpl_probe = child->rpl_pivot = 0;
|
||||
|
||||
return child;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
** Init MySQL structure or allocate one
|
||||
****************************************************************************/
|
||||
|
@ -1308,7 +969,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
|
|||
mysql->db=my_strdup(db,MYF(MY_WME));
|
||||
db=0;
|
||||
}
|
||||
if (my_net_write(net,buff,(uint) (end-buff)) || net_flush(net))
|
||||
if (my_net_write(net,buff,(ulong) (end-buff)) || net_flush(net))
|
||||
goto error;
|
||||
|
||||
lib_connection_phase(net,2);
|
||||
|
@ -1346,35 +1007,6 @@ error:
|
|||
}
|
||||
|
||||
|
||||
static my_bool mysql_reconnect(MYSQL *mysql)
|
||||
{
|
||||
MYSQL tmp_mysql;
|
||||
DBUG_ENTER("mysql_reconnect");
|
||||
|
||||
if (!mysql->reconnect ||
|
||||
(mysql->server_status & SERVER_STATUS_IN_TRANS) || !mysql->host_info)
|
||||
{
|
||||
/* Allov reconnect next time */
|
||||
mysql->server_status&= ~SERVER_STATUS_IN_TRANS;
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
mysql_init(&tmp_mysql);
|
||||
tmp_mysql.options=mysql->options;
|
||||
if (!mysql_real_connect(&tmp_mysql,mysql->host,mysql->user,mysql->passwd,
|
||||
mysql->db, mysql->port, mysql->unix_socket,
|
||||
mysql->client_flag))
|
||||
DBUG_RETURN(1);
|
||||
tmp_mysql.free_me=mysql->free_me;
|
||||
mysql->free_me=0;
|
||||
bzero((char*) &mysql->options,sizeof(mysql->options));
|
||||
mysql_close(mysql);
|
||||
*mysql=tmp_mysql;
|
||||
net_clear(&mysql->net);
|
||||
mysql->affected_rows= ~(my_ulonglong) 0;
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
** Change user and database
|
||||
**************************************************************************/
|
||||
|
@ -1394,7 +1026,7 @@ my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user,
|
|||
pos=scramble(pos, mysql->scramble_buff, passwd,
|
||||
(my_bool) (mysql->protocol_version == 9));
|
||||
pos=strmov(pos+1,db ? db : "");
|
||||
if (simple_command(mysql,COM_CHANGE_USER, buff,(uint) (pos-buff),0))
|
||||
if (simple_command(mysql,COM_CHANGE_USER, buff,(ulong) (pos-buff),0))
|
||||
DBUG_RETURN(1);
|
||||
|
||||
my_free(mysql->user,MYF(MY_ALLOW_ZERO_PTR));
|
||||
|
@ -1419,7 +1051,7 @@ mysql_select_db(MYSQL *mysql, const char *db)
|
|||
DBUG_ENTER("mysql_select_db");
|
||||
DBUG_PRINT("enter",("db: '%s'",db));
|
||||
|
||||
if ((error=simple_command(mysql,COM_INIT_DB,db,(uint) strlen(db),0)))
|
||||
if ((error=simple_command(mysql,COM_INIT_DB,db,(ulong) strlen(db),0)))
|
||||
DBUG_RETURN(error);
|
||||
my_free(mysql->db,MYF(MY_ALLOW_ZERO_PTR));
|
||||
mysql->db=my_strdup(db,MYF(MY_WME));
|
||||
|
@ -1482,11 +1114,11 @@ mysql_close(MYSQL *mysql)
|
|||
int STDCALL
|
||||
mysql_query(MYSQL *mysql, const char *query)
|
||||
{
|
||||
return mysql_real_query(mysql,query, (uint) strlen(query));
|
||||
return mysql_real_query(mysql,query, (ulong) strlen(query));
|
||||
}
|
||||
|
||||
int STDCALL
|
||||
mysql_send_query(MYSQL* mysql, const char* query, uint length)
|
||||
mysql_send_query(MYSQL* mysql, const char* query, ulong length)
|
||||
{
|
||||
return simple_command(mysql, COM_QUERY, query, length, 1);
|
||||
}
|
||||
|
@ -1541,8 +1173,109 @@ get_info:
|
|||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* A modified version of connect(). connect2() allows you to specify
|
||||
* a timeout value, in seconds, that we should wait until we
|
||||
* derermine we can't connect to a particular host. If timeout is 0,
|
||||
* my_connect() will behave exactly like connect().
|
||||
*
|
||||
* Base version coded by Steve Bernacki, Jr. <steve@navinet.net>
|
||||
*****************************************************************************/
|
||||
|
||||
int my_connect(my_socket s, const struct sockaddr *name, uint namelen,
|
||||
uint timeout)
|
||||
{
|
||||
#if defined(__WIN__) || defined(OS2)
|
||||
return connect(s, (struct sockaddr*) name, namelen);
|
||||
#else
|
||||
int flags, res, s_err;
|
||||
SOCKOPT_OPTLEN_TYPE s_err_size = sizeof(uint);
|
||||
fd_set sfds;
|
||||
struct timeval tv;
|
||||
time_t start_time, now_time;
|
||||
|
||||
/* If they passed us a timeout of zero, we should behave
|
||||
* exactly like the normal connect() call does.
|
||||
*/
|
||||
|
||||
if (timeout == 0)
|
||||
return connect(s, (struct sockaddr*) name, namelen);
|
||||
|
||||
flags = fcntl(s, F_GETFL, 0); /* Set socket to not block */
|
||||
#ifdef O_NONBLOCK
|
||||
fcntl(s, F_SETFL, flags | O_NONBLOCK); /* and save the flags.. */
|
||||
#endif
|
||||
|
||||
res = connect(s, (struct sockaddr*) name, namelen);
|
||||
s_err = errno; /* Save the error... */
|
||||
fcntl(s, F_SETFL, flags);
|
||||
if ((res != 0) && (s_err != EINPROGRESS))
|
||||
{
|
||||
errno = s_err; /* Restore it */
|
||||
return(-1);
|
||||
}
|
||||
if (res == 0) /* Connected quickly! */
|
||||
return(0);
|
||||
|
||||
/* Otherwise, our connection is "in progress." We can use
|
||||
* the select() call to wait up to a specified period of time
|
||||
* for the connection to suceed. If select() returns 0
|
||||
* (after waiting howevermany seconds), our socket never became
|
||||
* writable (host is probably unreachable.) Otherwise, if
|
||||
* select() returns 1, then one of two conditions exist:
|
||||
*
|
||||
* 1. An error occured. We use getsockopt() to check for this.
|
||||
* 2. The connection was set up sucessfully: getsockopt() will
|
||||
* return 0 as an error.
|
||||
*
|
||||
* Thanks goes to Andrew Gierth <andrew@erlenstar.demon.co.uk>
|
||||
* who posted this method of timing out a connect() in
|
||||
* comp.unix.programmer on August 15th, 1997.
|
||||
*/
|
||||
|
||||
FD_ZERO(&sfds);
|
||||
FD_SET(s, &sfds);
|
||||
/*
|
||||
* select could be interrupted by a signal, and if it is,
|
||||
* the timeout should be adjusted and the select restarted
|
||||
* to work around OSes that don't restart select and
|
||||
* implementations of select that don't adjust tv upon
|
||||
* failure to reflect the time remaining
|
||||
*/
|
||||
start_time = time(NULL);
|
||||
for (;;)
|
||||
{
|
||||
tv.tv_sec = (long) timeout;
|
||||
tv.tv_usec = 0;
|
||||
if ((res = select(s+1, NULL, &sfds, NULL, &tv)) >= 0)
|
||||
break;
|
||||
now_time=time(NULL);
|
||||
timeout-= (uint) (now_time - start_time);
|
||||
if (errno != EINTR || (int) timeout <= 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* select() returned something more interesting than zero, let's
|
||||
* see if we have any errors. If the next two statements pass,
|
||||
* we've got an open socket!
|
||||
*/
|
||||
|
||||
s_err=0;
|
||||
if (getsockopt(s, SOL_SOCKET, SO_ERROR, (char*) &s_err, &s_err_size) != 0)
|
||||
return(-1);
|
||||
|
||||
if (s_err)
|
||||
{ /* getsockopt could succeed */
|
||||
errno = s_err;
|
||||
return(-1); /* but return an error... */
|
||||
}
|
||||
return(0); /* It's all good! */
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
int STDCALL
|
||||
mysql_real_query(MYSQL *mysql, const char *query, uint length)
|
||||
mysql_real_query(MYSQL *mysql, const char *query, ulong length)
|
||||
{
|
||||
DBUG_ENTER("mysql_real_query");
|
||||
DBUG_PRINT("enter",("handle: %lx",mysql));
|
||||
|
@ -1940,7 +1673,7 @@ mysql_create_db(MYSQL *mysql, const char *db)
|
|||
{
|
||||
DBUG_ENTER("mysql_createdb");
|
||||
DBUG_PRINT("enter",("db: %s",db));
|
||||
DBUG_RETURN(simple_command(mysql,COM_CREATE_DB,db, (uint) strlen(db),0));
|
||||
DBUG_RETURN(simple_command(mysql,COM_CREATE_DB,db, (ulong) strlen(db),0));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1949,7 +1682,7 @@ mysql_drop_db(MYSQL *mysql, const char *db)
|
|||
{
|
||||
DBUG_ENTER("mysql_drop_db");
|
||||
DBUG_PRINT("enter",("db: %s",db));
|
||||
DBUG_RETURN(simple_command(mysql,COM_DROP_DB,db,(uint) strlen(db),0));
|
||||
DBUG_RETURN(simple_command(mysql,COM_DROP_DB,db,(ulong) strlen(db),0));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -16,10 +16,10 @@
|
|||
|
||||
INCLUDES = @MT_INCLUDES@ -I$(srcdir)/../include -I../include
|
||||
pkglib_LIBRARIES = libmerge.a
|
||||
noinst_HEADERS = mrgdef.h
|
||||
libmerge_a_SOURCES = open.c extra.c info.c _locking.c \
|
||||
rrnd.c update.c delete.c rsame.c panic.c \
|
||||
close.c create.c static.c
|
||||
noinst_HEADERS = mrg_def.h
|
||||
libmerge_a_SOURCES = mrg_open.c mrg_extra.c mrg_info.c mrg_locking.c \
|
||||
mrg_rrnd.c mrg_update.c mrg_delete.c mrg_rsame.c \
|
||||
mrg_panic.c mrg_close.c mrg_create.c mrg_static.c
|
||||
|
||||
OMIT_DEPENDENCIES = pthread.h stdio.h __stdio.h stdlib.h __stdlib.h math.h\
|
||||
__math.h time.h __time.h unistd.h __unistd.h types.h \
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
/* close a isam-database */
|
||||
|
||||
#include "mrgdef.h"
|
||||
#include "mrg_def.h"
|
||||
|
||||
int mrg_close(register MRG_INFO *info)
|
||||
{
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
/* Create a MERGE-file */
|
||||
|
||||
#include "mrgdef.h"
|
||||
#include "mrg_def.h"
|
||||
|
||||
/* create file named 'name' and save filenames in it
|
||||
table_names should be NULL or a vector of string-pointers with
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
/* Delete last read record */
|
||||
|
||||
#include "mrgdef.h"
|
||||
#include "mrg_def.h"
|
||||
|
||||
int mrg_delete(MRG_INFO *info,const byte *record)
|
||||
{
|
|
@ -20,7 +20,7 @@
|
|||
record-cache-flags are set in mrg_rrnd when we are changing database.
|
||||
*/
|
||||
|
||||
#include "mrgdef.h"
|
||||
#include "mrg_def.h"
|
||||
|
||||
int mrg_extra(
|
||||
MRG_INFO *info,
|
|
@ -14,7 +14,7 @@
|
|||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#include "mrgdef.h"
|
||||
#include "mrg_def.h"
|
||||
|
||||
ulong mrg_position(MRG_INFO *info)
|
||||
{
|
|
@ -18,7 +18,7 @@
|
|||
Lock databases against read or write.
|
||||
*/
|
||||
|
||||
#include "mrgdef.h"
|
||||
#include "mrg_def.h"
|
||||
|
||||
int mrg_lock_database(MRG_INFO *info,int lock_type)
|
||||
{
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
/* open a MERGE-database */
|
||||
|
||||
#include "mrgdef.h"
|
||||
#include "mrg_def.h"
|
||||
#include <stddef.h>
|
||||
#include <errno.h>
|
||||
#ifdef VMS
|
|
@ -14,7 +14,7 @@
|
|||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#include "mrgdef.h"
|
||||
#include "mrg_def.h"
|
||||
|
||||
/* if flag == HA_PANIC_CLOSE then all misam files are closed */
|
||||
/* if flag == HA_PANIC_WRITE then all misam files are unlocked and
|
|
@ -19,7 +19,7 @@
|
|||
get by mrg_info(). The next record can be read with pos= -1 */
|
||||
|
||||
|
||||
#include "mrgdef.h"
|
||||
#include "mrg_def.h"
|
||||
|
||||
static MRG_TABLE *find_table(MRG_TABLE *start,MRG_TABLE *end,mrg_off_t pos);
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#include "mrgdef.h"
|
||||
#include "mrg_def.h"
|
||||
|
||||
|
||||
int mrg_rsame(
|
|
@ -20,7 +20,7 @@
|
|||
*/
|
||||
|
||||
#ifndef stdin
|
||||
#include "mrgdef.h"
|
||||
#include "mrg_def.h"
|
||||
#endif
|
||||
|
||||
LIST *mrg_open_list=0;
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
/* Update last read record */
|
||||
|
||||
#include "mrgdef.h"
|
||||
#include "mrg_def.h"
|
||||
|
||||
int mrg_update(
|
||||
register MRG_INFO *info,
|
|
@ -173,7 +173,7 @@ int do_boolean(ALL_IN_ONE *aio, uint nested __attribute__((unused)),
|
|||
aio->key_root);
|
||||
else
|
||||
r=_mi_search(aio->info, aio->keyinfo, aio->info->lastkey,
|
||||
aio->info->lastkey_length, SEARCH_BIGGER,
|
||||
USE_WHOLE_KEY, SEARCH_BIGGER,
|
||||
aio->key_root);
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -126,7 +126,7 @@ static int walk_and_match(FT_WORD *word, uint32 count, ALL_IN_ONE *aio)
|
|||
aio->key_root);
|
||||
else
|
||||
r=_mi_search(aio->info, aio->keyinfo, aio->info->lastkey,
|
||||
aio->info->lastkey_length, SEARCH_BIGGER,
|
||||
USE_WHOLE_KEY, SEARCH_BIGGER,
|
||||
aio->key_root);
|
||||
}
|
||||
if(doc_cnt) {
|
||||
|
|
|
@ -34,7 +34,7 @@ FT_DOCLIST *ft_init_search(void *info, uint keynr, byte *query,
|
|||
/* black magic ON */
|
||||
if ((int) (keynr = _mi_check_index((MI_INFO *)info,keynr)) < 0)
|
||||
return NULL;
|
||||
if (_mi_readinfo((MI_INFO *)info,F_RDLCK,1))
|
||||
if (fast_mi_readinfo((MI_INFO *) info))
|
||||
return NULL;
|
||||
/* black magic OFF */
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ int mi_is_changed(MI_INFO *info)
|
|||
{
|
||||
int result;
|
||||
DBUG_ENTER("mi_is_changed");
|
||||
if (_mi_readinfo(info,F_RDLCK,1))
|
||||
if (fast_mi_readinfo(info))
|
||||
DBUG_RETURN(-1);
|
||||
VOID(_mi_writeinfo(info,0));
|
||||
result=(int) info->data_changed;
|
||||
|
|
|
@ -231,7 +231,7 @@ wrong:
|
|||
static int check_k_link(MI_CHECK *param, register MI_INFO *info, uint nr)
|
||||
{
|
||||
my_off_t next_link;
|
||||
uint block_size=(nr+1)*MI_KEY_BLOCK_LENGTH;
|
||||
uint block_size=(nr+1)*MI_MIN_KEY_BLOCK_LENGTH;
|
||||
ha_rows records;
|
||||
char llbuff[21],*buff;
|
||||
DBUG_ENTER("check_k_link");
|
||||
|
@ -1205,8 +1205,6 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info,
|
|||
param->glob_crc=0;
|
||||
if (param->testflag & T_CALC_CHECKSUM)
|
||||
param->calc_checksum=1;
|
||||
if (!rep_quick)
|
||||
share->state.checksum=0;
|
||||
|
||||
info->update= (short) (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
|
||||
for (i=0 ; i < info->s->base.keys ; i++)
|
||||
|
@ -1301,9 +1299,9 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info,
|
|||
else
|
||||
{
|
||||
info->state->data_file_length=sort_info->max_pos;
|
||||
if (param->testflag & T_CALC_CHECKSUM)
|
||||
share->state.checksum=param->glob_crc;
|
||||
}
|
||||
if (param->testflag & T_CALC_CHECKSUM)
|
||||
share->state.checksum=param->glob_crc;
|
||||
|
||||
if (!(param->testflag & T_SILENT))
|
||||
{
|
||||
|
@ -1886,8 +1884,6 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
|
|||
param->glob_crc=0;
|
||||
if (param->testflag & T_CALC_CHECKSUM)
|
||||
param->calc_checksum=1;
|
||||
if (! rep_quick)
|
||||
share->state.checksum=0;
|
||||
|
||||
rec_per_key_part= param->rec_per_key_part;
|
||||
for (sort_info->key=0 ; sort_info->key < share->base.keys ;
|
||||
|
@ -2018,7 +2014,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
|
|||
"Can't change size of datafile, error: %d",
|
||||
my_errno);
|
||||
}
|
||||
else if (param->testflag & T_CALC_CHECKSUM)
|
||||
if (param->testflag & T_CALC_CHECKSUM)
|
||||
share->state.checksum=param->glob_crc;
|
||||
|
||||
if (my_chsize(share->kfile,info->state->key_file_length,MYF(0)))
|
||||
|
@ -2115,6 +2111,7 @@ static int sort_key_read(SORT_INFO *sort_info, void *key)
|
|||
DBUG_RETURN(sort_write_record(sort_info));
|
||||
} /* sort_key_read */
|
||||
|
||||
|
||||
static int sort_ft_key_read(SORT_INFO *sort_info, void *key)
|
||||
{
|
||||
int error;
|
||||
|
@ -2540,7 +2537,7 @@ int sort_write_record(SORT_INFO *sort_info)
|
|||
DBUG_RETURN(1);
|
||||
}
|
||||
sort_info->filepos+=share->base.pack_reclength;
|
||||
info->s->state.checksum+=mi_static_checksum(info, sort_info->record);
|
||||
/* sort_info->param->glob_crc+=mi_static_checksum(info, sort_info->record); */
|
||||
break;
|
||||
case DYNAMIC_RECORD:
|
||||
if (! info->blobs)
|
||||
|
@ -2564,7 +2561,7 @@ int sort_write_record(SORT_INFO *sort_info)
|
|||
}
|
||||
info->checksum=mi_checksum(info,sort_info->record);
|
||||
reclength=_mi_rec_pack(info,from,sort_info->record);
|
||||
info->s->state.checksum+=info->checksum;
|
||||
/* sort_info->param->glob_crc+=info->checksum; */
|
||||
block_length=reclength+ 3 + test(reclength >= (65520-3));
|
||||
if (block_length < share->base.min_block_length)
|
||||
block_length=share->base.min_block_length;
|
||||
|
@ -2578,7 +2575,7 @@ int sort_write_record(SORT_INFO *sort_info)
|
|||
DBUG_RETURN(1);
|
||||
}
|
||||
sort_info->filepos+=block_length;
|
||||
info->s->state.checksum+=info->checksum;
|
||||
/* sort_info->param->glob_crc+=info->checksum; */
|
||||
break;
|
||||
case COMPRESSED_RECORD:
|
||||
reclength=info->packed_length;
|
||||
|
@ -2591,7 +2588,7 @@ int sort_write_record(SORT_INFO *sort_info)
|
|||
mi_check_print_error(param,"%d when writing to datafile",my_errno);
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
info->s->state.checksum+=info->checksum;
|
||||
/* sort_info->param->glob_crc+=info->checksum; */
|
||||
sort_info->filepos+=reclength+length;
|
||||
break;
|
||||
}
|
||||
|
@ -2808,9 +2805,9 @@ static int sort_delete_record(MI_CHECK *param)
|
|||
DBUG_RETURN(1);
|
||||
}
|
||||
}
|
||||
if (info->s->calc_checksum)
|
||||
info->s->state.checksum-=(*info->s->calc_checksum)(info,
|
||||
sort_info->record);
|
||||
if (param->calc_checksum)
|
||||
param->glob_crc-=(*info->s->calc_checksum)(info,
|
||||
sort_info->record);
|
||||
}
|
||||
error=flush_io_cache(&info->rec_cache) || (*info->s->delete_record)(info);
|
||||
info->dfile=old_file; /* restore actual value */
|
||||
|
|