diff --git a/BUILD/check-cpu b/BUILD/check-cpu index 7619224314b..0283c669fb2 100755 --- a/BUILD/check-cpu +++ b/BUILD/check-cpu @@ -72,6 +72,7 @@ case "$cpu_family--$model_name" in ;; *ppc) cpu_flag="powerpc"; + no_march=1; ;; *) cpu_flag=""; @@ -106,6 +107,9 @@ case "$cc_ver--$cc_verno" in cpu_flag="$cpu_flag_old" fi check_cpu_cflags="-mcpu=$cpu_flag -march=$cpu_flag" + if test -n "$no_march"; then + check_cpu_cflags="-mcpu=$cpu_flag" + fi ;; *) check_cpu_cflags="" diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index d8d16aaa1d8..3230f3c119f 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -205,6 +205,7 @@ patg@krsna. patg@krsna.patg.net patg@patrick-galbraiths-computer.local patg@pc248.lfp.kcls.org +patg@radha.local paul@central.snake.net paul@frost.snake.net paul@ice.local diff --git a/Makefile.am b/Makefile.am index eec27484710..b5ebe8eb8ae 100644 --- a/Makefile.am +++ b/Makefile.am @@ -104,8 +104,8 @@ test: test-force: cd mysql-test; \ - mysql-test-run --force ;\ - mysql-test-run --ps-protocol --force + ./mysql-test-run --force ;\ + ./mysql-test-run --ps-protocol --force # Don't update the files from bitkeeper %::SCCS/s.% diff --git a/VC++Files/client/mysql.dsp b/VC++Files/client/mysql.dsp index ec16e780d3e..e9e79a49d0a 100644 --- a/VC++Files/client/mysql.dsp +++ b/VC++Files/client/mysql.dsp @@ -52,7 +52,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"../client_release/mysql.exe" /libpath:"..\lib_release\\" +# ADD LINK32 mysqlclient.lib mysys.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /debug /machine:I386 /out:"../client_release/mysql.exe" /libpath:"..\lib_release\\" # SUBTRACT LINK32 /incremental:yes !ELSEIF "$(CFG)" == "mysql - Win32 Debug" @@ -78,7 +78,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/mysql.exe" /pdbtype:sept /libpath:"..\lib_debug\\" +# ADD LINK32 mysqlclient.lib mysys.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/mysql.exe" /pdbtype:sept /libpath:"..\lib_debug\\" !ELSEIF "$(CFG)" == "mysql - Win32 classic" @@ -104,9 +104,9 @@ BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=xilink6.exe -# ADD BASE LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"../client_release/mysql.exe" /libpath:"..\lib_release\\" +# ADD BASE LINK32 mysqlclient.lib mysys.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"../client_release/mysql.exe" /libpath:"..\lib_release\\" # SUBTRACT BASE LINK32 /incremental:yes -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"../client_classic/mysql.exe" /libpath:"..\lib_release\\" +# ADD LINK32 mysqlclient.lib mysys.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /debug /machine:I386 /out:"../client_classic/mysql.exe" /libpath:"..\lib_release\\" # SUBTRACT LINK32 /incremental:yes !ENDIF diff --git a/VC++Files/client/mysql_ia64.dsp b/VC++Files/client/mysql_ia64.dsp index 43bc9fa5b09..3fe2e2a2328 100644 --- a/VC++Files/client/mysql_ia64.dsp +++ b/VC++Files/client/mysql_ia64.dsp @@ -53,7 +53,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:IX86 /machine:IA64 -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /out:"../client_release/mysql.exe" /libpath:"..\lib_release\\" /machine:IA64 +# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /debug /out:"../client_release/mysql.exe" /libpath:"..\lib_release\\" /machine:IA64 !ELSEIF "$(CFG)" == "mysql - WinIA64 Debug" @@ -79,7 +79,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:IA64 -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no /debug /out:"../client_debug/mysql.exe" /libpath:"..\lib_debug\\" /machine:IA64 +# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /incremental:no /debug /out:"../client_debug/mysql.exe" /libpath:"..\lib_debug\\" /machine:IA64 !ELSEIF "$(CFG)" == "mysql - WinIA64 classic" @@ -107,7 +107,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /out:"../client_release/mysql.exe" /libpath:"..\lib_release\\" /machine:IA64 -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /out:"../client_classic/mysql.exe" /libpath:"..\lib_release\\" /machine:IA64 +# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /debug /out:"../client_classic/mysql.exe" /libpath:"..\lib_release\\" /machine:IA64 !ENDIF diff --git a/VC++Files/client/mysqladmin.dsp b/VC++Files/client/mysqladmin.dsp index 7a0b3bec1a7..d713325b4e7 100644 --- a/VC++Files/client/mysqladmin.dsp +++ b/VC++Files/client/mysqladmin.dsp @@ -52,7 +52,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqladmin.exe" /libpath:"..\lib_release\\" +# ADD LINK32 mysqlclient.lib mysys.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqladmin.exe" /libpath:"..\lib_release\\" !ELSEIF "$(CFG)" == "mysqladmin - Win32 Debug" @@ -77,7 +77,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/mysqladmin.exe" /pdbtype:sept /libpath:"..\lib_debug\\" +# ADD LINK32 mysqlclient.lib mysys.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/mysqladmin.exe" /pdbtype:sept /libpath:"..\lib_debug\\" !ELSEIF "$(CFG)" == "mysqladmin - Win32 classic" @@ -104,7 +104,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqladmin.exe" /libpath:"..\lib_release\\" -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../client_classic/mysqladmin.exe" /libpath:"..\lib_release\\" +# ADD LINK32 mysqlclient.lib mysys.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /machine:I386 /out:"../client_classic/mysqladmin.exe" /libpath:"..\lib_release\\" !ENDIF diff --git a/VC++Files/client/mysqladmin_ia64.dsp b/VC++Files/client/mysqladmin_ia64.dsp index 5a5e4a99071..f7823479d5a 100644 --- a/VC++Files/client/mysqladmin_ia64.dsp +++ b/VC++Files/client/mysqladmin_ia64.dsp @@ -53,7 +53,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:IA64 -# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib /nologo /subsystem:console /out:"../client_release/mysqladmin.exe" /libpath:"..\lib_release\\" /machine:IA64 +# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /out:"../client_release/mysqladmin.exe" /libpath:"..\lib_release\\" /machine:IA64 !ELSEIF "$(CFG)" == "mysqladmin - WinIA64 Debug" @@ -79,7 +79,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:IA64 -# ADD LINK32 ..\lib_debug\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib /nologo /subsystem:console /incremental:no /debug /out:"../client_debug/mysqladmin.exe" /libpath:"..\lib_debug\\" /machine:IA64 +# ADD LINK32 ..\lib_debug\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /incremental:no /debug /out:"../client_debug/mysqladmin.exe" /libpath:"..\lib_debug\\" /machine:IA64 !ELSEIF "$(CFG)" == "mysqladmin - WinIA64 classic" @@ -107,7 +107,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /out:"../client_release/mysqladmin.exe" /libpath:"..\lib_release\\" /machine:IA64 -# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib /nologo /subsystem:console /out:"../client_classic/mysqladmin.exe" /libpath:"..\lib_release\\" /machine:IA64 +# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /out:"../client_classic/mysqladmin.exe" /libpath:"..\lib_release\\" /machine:IA64 !ENDIF diff --git a/VC++Files/client/mysqlcheck.dsp b/VC++Files/client/mysqlcheck.dsp index 30e7a365f04..399b18d16fc 100644 --- a/VC++Files/client/mysqlcheck.dsp +++ b/VC++Files/client/mysqlcheck.dsp @@ -46,7 +46,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /pdb:"release/mysqlcheck.pdb" /machine:I386 /out:"../client_release/mysqlcheck.exe" /libpath:"..\lib_release\\" +# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /pdb:"release/mysqlcheck.pdb" /machine:I386 /out:"../client_release/mysqlcheck.exe" /libpath:"..\lib_release\\" # SUBTRACT LINK32 /pdb:none # Begin Target diff --git a/VC++Files/client/mysqlcheck_ia64.dsp b/VC++Files/client/mysqlcheck_ia64.dsp index 4b2c2bb4c46..aa49d86a523 100644 --- a/VC++Files/client/mysqlcheck_ia64.dsp +++ b/VC++Files/client/mysqlcheck_ia64.dsp @@ -49,7 +49,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:IA64 -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /pdb:"release/mysqlcheck.pdb" /machine:IA64 /out:"../client_release/mysqlcheck.exe" /libpath:"..\lib_release\\" /incremental:no +# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /pdb:"release/mysqlcheck.pdb" /machine:IA64 /out:"../client_release/mysqlcheck.exe" /libpath:"..\lib_release\\" /incremental:no # SUBTRACT LINK32 !ENDIF diff --git a/VC++Files/client/mysqlclient.dsp b/VC++Files/client/mysqlclient.dsp index 1f76ea3be92..a8a8e066830 100644 --- a/VC++Files/client/mysqlclient.dsp +++ b/VC++Files/client/mysqlclient.dsp @@ -155,6 +155,10 @@ SOURCE="..\strings\ctype-czech.c" # End Source File # Begin Source File +SOURCE="..\strings\ctype-cp932.c" +# End Source File +# Begin Source File + SOURCE="..\strings\ctype-euc_kr.c" # End Source File # Begin Source File diff --git a/VC++Files/client/mysqlclient_ia64.dsp b/VC++Files/client/mysqlclient_ia64.dsp index a69c5cf58af..e38f37d61e6 100644 --- a/VC++Files/client/mysqlclient_ia64.dsp +++ b/VC++Files/client/mysqlclient_ia64.dsp @@ -155,6 +155,10 @@ SOURCE="..\strings\ctype-czech.c" # End Source File # Begin Source File +SOURCE="..\strings\ctype-cp963.c" +# End Source File +# Begin Source File + SOURCE="..\strings\ctype-euc_kr.c" # End Source File # Begin Source File diff --git a/VC++Files/client/mysqldump.dsp b/VC++Files/client/mysqldump.dsp index 3c955639596..45d1d8777aa 100644 --- a/VC++Files/client/mysqldump.dsp +++ b/VC++Files/client/mysqldump.dsp @@ -52,7 +52,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysys.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysys.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqldump.exe" /libpath:"..\lib_release\\" +# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysys.lib zlib.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqldump.exe" /libpath:"..\lib_release\\" !ELSEIF "$(CFG)" == "mysqldump - Win32 Debug" @@ -77,7 +77,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysys.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysys.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/mysqldump.exe" /pdbtype:sept /libpath:"..\lib_debug\\" +# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysys.lib zlib.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/mysqldump.exe" /pdbtype:sept /libpath:"..\lib_debug\\" !ELSEIF "$(CFG)" == "mysqldump - Win32 classic" @@ -104,7 +104,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysys.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqldump.exe" /libpath:"..\lib_release\\" -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysys.lib /nologo /subsystem:console /machine:I386 /out:"../client_classic/mysqldump.exe" /libpath:"..\lib_release\\" +# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysys.lib zlib.lib /nologo /subsystem:console /machine:I386 /out:"../client_classic/mysqldump.exe" /libpath:"..\lib_release\\" !ENDIF diff --git a/VC++Files/client/mysqldump_ia64.dsp b/VC++Files/client/mysqldump_ia64.dsp index 698cd0b9c2c..79a7059cae5 100644 --- a/VC++Files/client/mysqldump_ia64.dsp +++ b/VC++Files/client/mysqldump_ia64.dsp @@ -53,7 +53,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysys.lib /nologo /subsystem:console /machine:IA64 -# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysys.lib bufferoverflowU.lib /nologo /subsystem:console /out:"../client_release/mysqldump.exe" /libpath:"..\lib_release\\" /machine:IA64 +# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysys.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /out:"../client_release/mysqldump.exe" /libpath:"..\lib_release\\" /machine:IA64 !ELSEIF "$(CFG)" == "mysqldump - WinIA64 Debug" @@ -79,7 +79,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysys.lib /nologo /subsystem:console /debug /machine:IA64 -# ADD LINK32 ..\lib_debug\dbug.lib ..\lib_debug\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysys.lib bufferoverflowU.lib /nologo /subsystem:console /incremental:no /debug /out:"../client_debug/mysqldump.exe" /libpath:"..\lib_debug\\" /machine:IA64 +# ADD LINK32 ..\lib_debug\dbug.lib ..\lib_debug\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysys.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /incremental:no /debug /out:"../client_debug/mysqldump.exe" /libpath:"..\lib_debug\\" /machine:IA64 !ELSEIF "$(CFG)" == "mysqldump - WinIA64 classic" @@ -107,7 +107,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysys.lib /nologo /subsystem:console /out:"../client_release/mysqldump.exe" /libpath:"..\lib_release\\" /machine:IA64 -# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysys.lib bufferoverflowU.lib /nologo /subsystem:console /out:"../client_classic/mysqldump.exe" /libpath:"..\lib_release\\" /machine:IA64 +# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysys.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /out:"../client_classic/mysqldump.exe" /libpath:"..\lib_release\\" /machine:IA64 !ENDIF diff --git a/VC++Files/client/mysqlimport.dsp b/VC++Files/client/mysqlimport.dsp index d5fd8557397..1b650dab731 100644 --- a/VC++Files/client/mysqlimport.dsp +++ b/VC++Files/client/mysqlimport.dsp @@ -52,7 +52,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqlimport.exe" /libpath:"..\lib_release\\" +# ADD LINK32 mysqlclient.lib mysys.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqlimport.exe" /libpath:"..\lib_release\\" # SUBTRACT LINK32 /incremental:yes !ELSEIF "$(CFG)" == "mysqlimport - Win32 Debug" @@ -78,7 +78,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib setargv.obj /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/mysqlimport.exe" /pdbtype:sept /libpath:"..\lib_debug\\" +# ADD LINK32 mysqlclient.lib mysys.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib setargv.obj /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/mysqlimport.exe" /pdbtype:sept /libpath:"..\lib_debug\\" !ELSEIF "$(CFG)" == "mysqlimport - Win32 classic" @@ -104,9 +104,9 @@ BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=xilink6.exe -# ADD BASE LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqlimport.exe" /libpath:"..\lib_release\\" +# ADD BASE LINK32 mysqlclient.lib mysys.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqlimport.exe" /libpath:"..\lib_release\\" # SUBTRACT BASE LINK32 /incremental:yes -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../client_classic/mysqlimport.exe" /libpath:"..\lib_release\\" +# ADD LINK32 mysqlclient.lib mysys.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /machine:I386 /out:"../client_classic/mysqlimport.exe" /libpath:"..\lib_release\\" # SUBTRACT LINK32 /incremental:yes !ENDIF diff --git a/VC++Files/client/mysqlimport_ia64.dsp b/VC++Files/client/mysqlimport_ia64.dsp index cd8f5523efd..c6f51c0ef6f 100644 --- a/VC++Files/client/mysqlimport_ia64.dsp +++ b/VC++Files/client/mysqlimport_ia64.dsp @@ -53,7 +53,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:IA64 -# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib /nologo /subsystem:console /out:"../client_release/mysqlimport.exe" /libpath:"..\lib_release\\" /machine:IA64 +# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /out:"../client_release/mysqlimport.exe" /libpath:"..\lib_release\\" /machine:IA64 !ELSEIF "$(CFG)" == "mysqlimport - WinIA64 Debug" @@ -79,7 +79,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:IA64 -# ADD LINK32 setargv.obj ..\lib_debug\zlib.lib ..\lib_debug\dbug.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib /nologo /subsystem:console /incremental:no /debug /out:"../client_debug/mysqlimport.exe" /libpath:"..\lib_debug\\" /machine:IA64 +# ADD LINK32 setargv.obj ..\lib_debug\zlib.lib ..\lib_debug\dbug.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /incremental:no /debug /out:"../client_debug/mysqlimport.exe" /libpath:"..\lib_debug\\" /machine:IA64 !ELSEIF "$(CFG)" == "mysqlimport - WinIA64 classic" @@ -107,7 +107,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /out:"../client_release/mysqlimport.exe" /libpath:"..\lib_release\\" /machine:IA64 -# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib /nologo /subsystem:console /out:"../client_classic/mysqlimport.exe" /libpath:"..\lib_release\\" /machine:IA64 +# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /out:"../client_classic/mysqlimport.exe" /libpath:"..\lib_release\\" /machine:IA64 !ENDIF diff --git a/VC++Files/client/mysqlshow.dsp b/VC++Files/client/mysqlshow.dsp index b9fd0d27e46..f9377763c49 100644 --- a/VC++Files/client/mysqlshow.dsp +++ b/VC++Files/client/mysqlshow.dsp @@ -52,7 +52,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqlshow.exe" /libpath:"..\lib_release\\" +# ADD LINK32 mysqlclient.lib mysys.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqlshow.exe" /libpath:"..\lib_release\\" !ELSEIF "$(CFG)" == "mysqlshow - Win32 Debug" @@ -77,7 +77,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/mysqlshow.exe" /pdbtype:sept /libpath:"..\lib_debug\\" +# ADD LINK32 mysqlclient.lib mysys.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/mysqlshow.exe" /pdbtype:sept /libpath:"..\lib_debug\\" !ELSEIF "$(CFG)" == "mysqlshow - Win32 classic" @@ -103,8 +103,8 @@ BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=xilink6.exe -# ADD BASE LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqlshow.exe" /libpath:"..\lib_release\\" -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../client_classic/mysqlshow.exe" /libpath:"..\lib_release\\" +# ADD BASE LINK32 mysqlclient.lib mysys.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqlshow.exe" /libpath:"..\lib_release\\" +# ADD LINK32 mysqlclient.lib mysys.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /machine:I386 /out:"../client_classic/mysqlshow.exe" /libpath:"..\lib_release\\" !ENDIF diff --git a/VC++Files/client/mysqlshow_ia64.dsp b/VC++Files/client/mysqlshow_ia64.dsp index dd83a3f1ef5..4995f3f9ae8 100644 --- a/VC++Files/client/mysqlshow_ia64.dsp +++ b/VC++Files/client/mysqlshow_ia64.dsp @@ -53,7 +53,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:IA64 -# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib /nologo /subsystem:console /out:"../client_release/mysqlshow.exe" /libpath:"..\lib_release\\" /machine:IA64 +# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /out:"../client_release/mysqlshow.exe" /libpath:"..\lib_release\\" /machine:IA64 !ELSEIF "$(CFG)" == "mysqlshow - WinIA64 Debug" @@ -79,7 +79,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:IA64 -# ADD LINK32 ..\lib_debug\zlib.lib ..\lib_debug\dbug.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib /nologo /subsystem:console /incremental:no /debug /out:"../client_debug/mysqlshow.exe" /libpath:"..\lib_debug\\" /machine:IA64 +# ADD LINK32 ..\lib_debug\zlib.lib ..\lib_debug\dbug.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /incremental:no /debug /out:"../client_debug/mysqlshow.exe" /libpath:"..\lib_debug\\" /machine:IA64 !ELSEIF "$(CFG)" == "mysqlshow - WinIA64 classic" @@ -107,7 +107,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /out:"../client_release/mysqlshow.exe" /libpath:"..\lib_release\\" /machine:IA64 -# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib /nologo /subsystem:console /out:"../client_classic/mysqlshow.exe" /libpath:"..\lib_release\\" /machine:IA64 +# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /out:"../client_classic/mysqlshow.exe" /libpath:"..\lib_release\\" /machine:IA64 !ENDIF diff --git a/VC++Files/client/mysqltest.dsp b/VC++Files/client/mysqltest.dsp index 1ebd7a59b0c..aee7ec869b8 100644 --- a/VC++Files/client/mysqltest.dsp +++ b/VC++Files/client/mysqltest.dsp @@ -78,7 +78,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib mysqlclient.lib wsock32.lib mysys.lib regex.lib /nologo /out:"..\client_classic\mysqltest.exe" /incremental:no /libpath:"..\lib_release\" /pdb:".\classic\mysqltest.pdb" /pdbtype:sept /subsystem:console /MACHINE:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib mysqlclient.lib wsock32.lib mysys.lib regex.lib /nologo /out:"..\client_classic\mysqltest.exe" /incremental:no /libpath:"..\lib_release\" /pdb:".\classic\mysqltest.pdb" /pdbtype:sept /subsystem:console /MACHINE:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib mysqlclient.lib wsock32.lib mysys.lib regex.lib zlib.lib /nologo /out:"..\client_classic\mysqltest.exe" /incremental:no /libpath:"..\lib_release\" /pdb:".\classic\mysqltest.pdb" /pdbtype:sept /subsystem:console /MACHINE:I386 !ELSEIF "$(CFG)" == "mysqltest - Win32 Release" @@ -103,7 +103,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib mysqlclient.lib wsock32.lib mysys.lib regex.lib /nologo /out:"..\client_release\mysqltest.exe" /incremental:no /libpath:"..\lib_release\" /pdb:".\release\mysqltest.pdb" /pdbtype:sept /subsystem:console /MACHINE:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib mysqlclient.lib wsock32.lib mysys.lib regex.lib /nologo /out:"..\client_release\mysqltest.exe" /incremental:no /libpath:"..\lib_release\" /pdb:".\release\mysqltest.pdb" /pdbtype:sept /subsystem:console /MACHINE:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib mysqlclient.lib wsock32.lib mysys.lib regex.lib zlib.lib /nologo /out:"..\client_release\mysqltest.exe" /incremental:no /libpath:"..\lib_release\" /pdb:".\release\mysqltest.pdb" /pdbtype:sept /subsystem:console /MACHINE:I386 !ENDIF diff --git a/VC++Files/client/mysqltest_ia64.dsp b/VC++Files/client/mysqltest_ia64.dsp index 160683725e6..86edb4ab177 100644 --- a/VC++Files/client/mysqltest_ia64.dsp +++ b/VC++Files/client/mysqltest_ia64.dsp @@ -55,7 +55,7 @@ BSC32=bscmake.exe LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib mysqlclient.lib wsock32.lib mysys.lib regex.lib /nologo /subsystem:console /debug /out:"..\client_debug\mysqltest.exe" /libpath:"..\lib_debug\\" # SUBTRACT BASE LINK32 /pdb:none -# ADD LINK32 ..\lib_debug\zlib.lib ..\lib_debug\dbug.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysqlclient.lib wsock32.lib mysys.lib regex.lib bufferoverflowU.lib /nologo /subsystem:console /incremental:no /debug /out:"..\client_debug\mysqltest.exe" /libpath:"..\lib_debug\\" /machine:IA64 +# ADD LINK32 ..\lib_debug\zlib.lib ..\lib_debug\dbug.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysqlclient.lib wsock32.lib mysys.lib regex.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /incremental:no /debug /out:"..\client_debug\mysqltest.exe" /libpath:"..\lib_debug\\" /machine:IA64 # SUBTRACT LINK32 /pdb:none !ELSEIF "$(CFG)" == "mysqltest - WinIA64 classic" @@ -84,7 +84,7 @@ BSC32=bscmake.exe LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib mysqlclient.lib wsock32.lib mysys.lib regex.lib /nologo /subsystem:console /out:"..\client_classic\mysqltest.exe" /libpath:"..\lib_release\\" # SUBTRACT BASE LINK32 /pdb:none -# ADD LINK32 ..\lib_release\zlib.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysqlclient.lib wsock32.lib mysys.lib regex.lib bufferoverflowU.lib /nologo /subsystem:console /out:"..\client_classic\mysqltest.exe" /libpath:"..\lib_release\\" /machine:IA64 +# ADD LINK32 ..\lib_release\zlib.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysqlclient.lib wsock32.lib mysys.lib regex.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /out:"..\client_classic\mysqltest.exe" /libpath:"..\lib_release\\" /machine:IA64 # SUBTRACT LINK32 /pdb:none !ELSEIF "$(CFG)" == "mysqltest - WinIA64 Release" @@ -113,7 +113,7 @@ BSC32=bscmake.exe LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib mysqlclient.lib wsock32.lib mysys.lib regex.lib /nologo /subsystem:console /out:"..\client_release\mysqltest.exe" /libpath:"..\lib_release\\" # SUBTRACT BASE LINK32 /pdb:none -# ADD LINK32 ..\lib_release\zlib.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysqlclient.lib wsock32.lib mysys.lib regex.lib bufferoverflowU.lib /nologo /subsystem:console /out:"..\client_release\mysqltest.exe" /libpath:"..\lib_release\\" /machine:IA64 +# ADD LINK32 ..\lib_release\zlib.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysqlclient.lib wsock32.lib mysys.lib regex.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /out:"..\client_release\mysqltest.exe" /libpath:"..\lib_release\\" /machine:IA64 # SUBTRACT LINK32 /pdb:none !ENDIF diff --git a/VC++Files/libmysql/libmysql.dsp b/VC++Files/libmysql/libmysql.dsp index 1db5ed538a4..4f93ac93c40 100644 --- a/VC++Files/libmysql/libmysql.dsp +++ b/VC++Files/libmysql/libmysql.dsp @@ -54,7 +54,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 -# ADD LINK32 wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 /def:"libmysql.def" /out:"..\lib_release\libmysql.dll" /libpath:"." /libpath:"..\lib_release" +# ADD LINK32 mysys.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 /def:"libmysql.def" /out:"..\lib_release\libmysql.dll" /libpath:"." /libpath:"..\lib_release" # SUBTRACT LINK32 /pdb:none # Begin Special Build Tool SOURCE="$(InputPath)" @@ -87,7 +87,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 zlib.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /incremental:no /map /debug /machine:I386 /def:"libmysql.def" /out:"..\lib_debug\libmysql.dll" /pdbtype:sept /libpath:"." /libpath:"..\lib_debug" +# ADD LINK32 zlib.lib mysys.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /incremental:no /map /debug /machine:I386 /def:"libmysql.def" /out:"..\lib_debug\libmysql.dll" /pdbtype:sept /libpath:"." /libpath:"..\lib_debug" # SUBTRACT LINK32 /pdb:none # Begin Special Build Tool SOURCE="$(InputPath)" @@ -147,6 +147,10 @@ SOURCE="..\strings\ctype-czech.c" # End Source File # Begin Source File +SOURCE="..\strings\ctype-cp932.c" +# End Source File +# Begin Source File + SOURCE="..\strings\ctype-euc_kr.c" # End Source File # Begin Source File diff --git a/VC++Files/libmysql/libmysql_ia64.dsp b/VC++Files/libmysql/libmysql_ia64.dsp index fa851cb81c5..75586ef2cf6 100644 --- a/VC++Files/libmysql/libmysql_ia64.dsp +++ b/VC++Files/libmysql/libmysql_ia64.dsp @@ -146,6 +146,10 @@ SOURCE="..\strings\ctype-czech.c" # End Source File # Begin Source File +SOURCE="..\strings\ctype-cp932.c" +# End Source File +# Begin Source File + SOURCE="..\strings\ctype-euc_kr.c" # End Source File # Begin Source File diff --git a/VC++Files/mysql-test/mysql_test_run_new.dsp b/VC++Files/mysql-test/mysql_test_run_new.dsp index 61392b00b94..467ff939502 100644 --- a/VC++Files/mysql-test/mysql_test_run_new.dsp +++ b/VC++Files/mysql-test/mysql_test_run_new.dsp @@ -52,7 +52,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /out:"..\mysql-test\mysql_test_run_new.exe" /incremental:yes /debug /pdb:".\Debug\mysql_test_run_new.pdb" /pdbtype:sept /map:".\Debug\mysql_test_run_new.map" /subsystem:console -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /out:"..\mysql-test\mysql_test_run_new.exe" /incremental:yes /debug /pdb:".\Debug\mysql_test_run_new.pdb" /pdbtype:sept /map:".\Debug\mysql_test_run_new.map" /subsystem:console +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib Ws2_32.lib zlib.lib /nologo /out:"..\mysql-test\mysql_test_run_new.exe" /incremental:yes /libpath:"..\lib_debug\" /debug /pdb:".\Debug\mysql_test_run_new.pdb" /pdbtype:sept /map:".\Debug\mysql_test_run_new.map" /subsystem:console !ELSEIF "$(CFG)" == "mysql_test_run_new - Win32 Release" @@ -77,7 +77,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /out:"..\mysql-test\mysql_test_run_new.exe" /incremental:no /pdb:".\Release\mysql_test_run_new.pdb" /pdbtype:sept /subsystem:console -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /out:"..\mysql-test\mysql_test_run_new.exe" /incremental:no /pdb:".\Release\mysql_test_run_new.pdb" /pdbtype:sept /subsystem:console +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib Ws2_32.lib zlib.lib /nologo /out:"..\mysql-test\mysql_test_run_new.exe" /incremental:no /libpath:"..\lib_release\" /pdb:".\Release\mysql_test_run_new.pdb" /pdbtype:sept /subsystem:console !ENDIF diff --git a/VC++Files/mysql-test/mysql_test_run_new_ia64.dsp b/VC++Files/mysql-test/mysql_test_run_new_ia64.dsp index a6252d0cb7b..023b38bd3c6 100644 --- a/VC++Files/mysql-test/mysql_test_run_new_ia64.dsp +++ b/VC++Files/mysql-test/mysql_test_run_new_ia64.dsp @@ -54,7 +54,7 @@ BSC32=bscmake.exe LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /subsystem:console /map /debug /out:"..\mysql-test\mysql_test_run_new.exe" /machine:IA64 # SUBTRACT BASE LINK32 /pdb:none -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Ws2_32.lib bufferoverflowU.lib /nologo /subsystem:console /incremental:no /map /debug /out:"..\mysql-test\mysql_test_run_new.exe" /machine:IA64 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Ws2_32.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /incremental:no /libpath:"..\lib_debug\" /map /debug /out:"..\mysql-test\mysql_test_run_new.exe" /machine:IA64 # SUBTRACT LINK32 /pdb:none !ELSEIF "$(CFG)" == "mysql_test_run_new - WinIA64 Release" @@ -83,7 +83,7 @@ BSC32=bscmake.exe LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /subsystem:console /out:"..\mysql-test\mysql_test_run_new.exe" /machine:IA64 # SUBTRACT BASE LINK32 /pdb:none -# ADD LINK32 t kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Ws2_32.lib bufferoverflowU.lib /nologo /subsystem:console /out:"..\mysql-test\mysql_test_run_new.exe" /machine:IA64 +# ADD LINK32 t kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Ws2_32.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /libpath:"..\lib_release\" /out:"..\mysql-test\mysql_test_run_new.exe" /machine:IA64 # SUBTRACT LINK32 /pdb:none !ENDIF diff --git a/VC++Files/mysql.dsw b/VC++Files/mysql.dsw index 25bcab8338b..6ebda999c35 100644 --- a/VC++Files/mysql.dsw +++ b/VC++Files/mysql.dsw @@ -80,6 +80,9 @@ Package=<4> Begin Project Dependency Project_Dep_Name zlib End Project Dependency + Begin Project Dependency + Project_Dep_Name mysys + End Project Dependency }}} ############################################################################### @@ -320,6 +323,9 @@ Package=<4> Begin Project Dependency Project_Dep_Name zlib End Project Dependency + Begin Project Dependency + Project_Dep_Name mysys + End Project Dependency }}} ############################################################################### @@ -476,6 +482,9 @@ Package=<4> Begin Project Dependency Project_Dep_Name mysqlclient End Project Dependency + Begin Project Dependency + Project_Dep_Name mysys + End Project Dependency }}} ############################################################################### @@ -533,6 +542,9 @@ Package=<4> Begin Project Dependency Project_Dep_Name mysqlclient End Project Dependency + Begin Project Dependency + Project_Dep_Name mysys + End Project Dependency }}} ############################################################################### diff --git a/VC++Files/mysqlbinlog/mysqlbinlog.dsp b/VC++Files/mysqlbinlog/mysqlbinlog.dsp index 8b8895d6f17..1b129072d8e 100644 --- a/VC++Files/mysqlbinlog/mysqlbinlog.dsp +++ b/VC++Files/mysqlbinlog/mysqlbinlog.dsp @@ -51,7 +51,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqlbinlog.exe" /libpath:"..\lib_release\\" +# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqlbinlog.exe" /libpath:"..\lib_release\\" # SUBTRACT LINK32 /pdb:none /debug !ELSEIF "$(CFG)" == "mysqlbinlog - Win32 Debug" @@ -76,7 +76,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/mysqlbinlog.exe" /pdbtype:sept /libpath:"..\lib_debug\\" +# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/mysqlbinlog.exe" /pdbtype:sept /libpath:"..\lib_debug\\" !ELSEIF "$(CFG)" == "mysqlbinlog - Win32 classic" @@ -102,7 +102,7 @@ BSC32=bscmake.exe LINK32=xilink6.exe # ADD BASE LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqlbinlog.exe" /libpath:"..\lib_release\\" # SUBTRACT BASE LINK32 /pdb:none /debug -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../client_classic/mysqlbinlog.exe" /libpath:"..\lib_release\\" +# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /machine:I386 /out:"../client_classic/mysqlbinlog.exe" /libpath:"..\lib_release\\" # SUBTRACT LINK32 /pdb:none /debug !ENDIF diff --git a/VC++Files/mysqlbinlog/mysqlbinlog_ia64.dsp b/VC++Files/mysqlbinlog/mysqlbinlog_ia64.dsp index 334c5087365..0bb6e9ed747 100644 --- a/VC++Files/mysqlbinlog/mysqlbinlog_ia64.dsp +++ b/VC++Files/mysqlbinlog/mysqlbinlog_ia64.dsp @@ -52,7 +52,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:IA64 -# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib /nologo /subsystem:console /out:"../client_release/mysqlbinlog.exe" /libpath:"..\lib_release\\" /machine:IA64 +# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /out:"../client_release/mysqlbinlog.exe" /libpath:"..\lib_release\\" /machine:IA64 # SUBTRACT LINK32 /debug !ELSEIF "$(CFG)" == "mysqlbinlog - WinIA64 Debug" @@ -78,7 +78,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:IA64 -# ADD LINK32 ..\lib_debug\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib /nologo /subsystem:console /incremental:no /debug /out:"../client_debug/mysqlbinlog.exe" /libpath:"..\lib_debug\\" /machine:IA64 +# ADD LINK32 ..\lib_debug\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /incremental:no /debug /out:"../client_debug/mysqlbinlog.exe" /libpath:"..\lib_debug\\" /machine:IA64 !ELSEIF "$(CFG)" == "mysqlbinlog - WinIA64 classic" @@ -105,7 +105,7 @@ BSC32=bscmake.exe LINK32=link.exe # ADD BASE LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /out:"../client_release/mysqlbinlog.exe" /libpath:"..\lib_release\\" /machine:IA64 # SUBTRACT BASE LINK32 /debug -# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib /nologo /subsystem:console /out:"../client_classic/mysqlbinlog.exe" /libpath:"..\lib_release\\" /machine:IA64 +# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /out:"../client_classic/mysqlbinlog.exe" /libpath:"..\lib_release\\" /machine:IA64 # SUBTRACT LINK32 /debug !ENDIF diff --git a/VC++Files/mysqlcheck/mysqlcheck.dsp b/VC++Files/mysqlcheck/mysqlcheck.dsp index bd24a14128d..51a817cc067 100644 --- a/VC++Files/mysqlcheck/mysqlcheck.dsp +++ b/VC++Files/mysqlcheck/mysqlcheck.dsp @@ -51,7 +51,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqlcheck.exe" /libpath:"..\lib_release\\" +# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqlcheck.exe" /libpath:"..\lib_release\\" !ELSEIF "$(CFG)" == "mysqlcheck - Win32 Debug" @@ -75,7 +75,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/mysqlcheck.exe" /pdbtype:sept /libpath:"..\lib_debug\\" +# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/mysqlcheck.exe" /pdbtype:sept /libpath:"..\lib_debug\\" !ELSEIF "$(CFG)" == "mysqlcheck - Win32 classic" @@ -100,7 +100,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqlcheck.exe" /libpath:"..\lib_release\\" -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../client_classic/mysqlcheck.exe" /libpath:"..\lib_release\\" +# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /machine:I386 /out:"../client_classic/mysqlcheck.exe" /libpath:"..\lib_release\\" !ENDIF diff --git a/VC++Files/mysqlcheck/mysqlcheck_ia64.dsp b/VC++Files/mysqlcheck/mysqlcheck_ia64.dsp index 1f1cf76276f..04f10a2ddb8 100644 --- a/VC++Files/mysqlcheck/mysqlcheck_ia64.dsp +++ b/VC++Files/mysqlcheck/mysqlcheck_ia64.dsp @@ -52,7 +52,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:IA64 -# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib /nologo /subsystem:console /out:"../client_release/mysqlcheck.exe" /libpath:"..\lib_release\\" /machine:IA64 +# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /out:"../client_release/mysqlcheck.exe" /libpath:"..\lib_release\\" /machine:IA64 !ELSEIF "$(CFG)" == "mysqlcheck - WinIA64 Debug" @@ -77,7 +77,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:IA64 -# ADD LINK32 ..\lib_debug\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib /nologo /subsystem:console /incremental:no /debug /out:"../client_debug/mysqlcheck.exe" /libpath:"..\lib_debug\\" /machine:IA64 +# ADD LINK32 ..\lib_debug\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /incremental:no /debug /out:"../client_debug/mysqlcheck.exe" /libpath:"..\lib_debug\\" /machine:IA64 !ELSEIF "$(CFG)" == "mysqlcheck - WinIA64 classic" @@ -103,7 +103,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /out:"../client_release/mysqlcheck.exe" /libpath:"..\lib_release\\" /machine:IA64 -# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib /nologo /subsystem:console /out:"../client_classic/mysqlcheck.exe" /libpath:"..\lib_release\\" /machine:IA64 +# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /out:"../client_classic/mysqlcheck.exe" /libpath:"..\lib_release\\" /machine:IA64 !ENDIF diff --git a/VC++Files/sql/mysqld.dsp b/VC++Files/sql/mysqld.dsp index a140b99080b..3642585b4d6 100644 --- a/VC++Files/sql/mysqld.dsp +++ b/VC++Files/sql/mysqld.dsp @@ -75,7 +75,7 @@ LINK32=xilink6.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /G6 /MTd /W3 /Z7 /Od /I "../bdb/build_win32" /I "../include" /I "../regex" /I "../extra/yassl/include" /I "../zlib" /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "HAVE_INNOBASE_DB" /D "HAVE_BERKELEY_DB" /D "HAVE_BLACKHOLE_DB" /D "HAVE_FEDERATED_DB" /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /D "HAVE_DLOPEN" /FD /c +# ADD CPP /nologo /G6 /MTd /W3 /Z7 /Od /I "../bdb/build_win32" /I "../include" /I "../regex" /I "../extra/yassl/include" /I "../zlib" /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "HAVE_INNOBASE_DB" /D "HAVE_BERKELEY_DB" /D "HAVE_ARCHIVE_DB" /D "HAVE_BLACKHOLE_DB" /D "HAVE_FEDERATED_DB" /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /D "HAVE_DLOPEN" /FD /c # SUBTRACT CPP /Fr /YX # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" @@ -130,7 +130,7 @@ LINK32=xilink6.exe # PROP Target_Dir "" # ADD BASE CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../regex" /D "NDEBUG" /D "__NT__" /D "DBUG_OFF" /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /FD /c # SUBTRACT BASE CPP /YX -# ADD CPP /nologo /G6 /MT /W3 /O2 /I "../bdb/build_win32" /I "../include" /I "../regex" /I "../extra/yassl/include" /I "../zlib" /D "NDEBUG" /D "__NT__" /D "DBUG_OFF" /D "HAVE_INNOBASE_DB" /D "HAVE_BERKELEY_DB" /D "HAVE_BLACKHOLE_DB" /D "HAVE_FEDERATED_DB" /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /D "HAVE_DLOPEN" /D MYSQL_SERVER_SUFFIX=-nt-max /FD /c +# ADD CPP /nologo /G6 /MT /W3 /O2 /I "../bdb/build_win32" /I "../include" /I "../regex" /I "../extra/yassl/include" /I "../zlib" /D "NDEBUG" /D "__NT__" /D "DBUG_OFF" /D "HAVE_INNOBASE_DB" /D "HAVE_BERKELEY_DB" /D "HAVE_ARCHIVE_DB" /D "HAVE_BLACKHOLE_DB" /D "HAVE_FEDERATED_DB" /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /D "HAVE_DLOPEN" /D MYSQL_SERVER_SUFFIX=-nt-max /FD /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" @@ -159,7 +159,7 @@ LINK32=xilink6.exe # PROP Target_Dir "" # ADD BASE CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../regex" /D "NDEBUG" /D "DBUG_OFF" /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /FD /c # SUBTRACT BASE CPP /YX -# ADD CPP /nologo /G6 /MT /W3 /O2 /I "../bdb/build_win32" /I "../include" /I "../regex" /I "../extra/yassl/include" /I "../zlib" /D "NDEBUG" /D "DBUG_OFF" /D "USE_SYMDIR" /D "HAVE_INNOBASE_DB" /D "HAVE_BERKELEY_DB" /D "HAVE_BLACKHOLE_DB" /D "HAVE_FEDERATED_DB" /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /D "HAVE_DLOPEN" /D MYSQL_SERVER_SUFFIX=-max /FD /c +# ADD CPP /nologo /G6 /MT /W3 /O2 /I "../bdb/build_win32" /I "../include" /I "../regex" /I "../extra/yassl/include" /I "../zlib" /D "NDEBUG" /D "DBUG_OFF" /D "USE_SYMDIR" /D "HAVE_INNOBASE_DB" /D "HAVE_BERKELEY_DB" /D "HAVE_ARCHIVE_DB" /D "HAVE_BLACKHOLE_DB" /D "HAVE_FEDERATED_DB" /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /D "HAVE_DLOPEN" /D MYSQL_SERVER_SUFFIX=-max /FD /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" @@ -452,6 +452,10 @@ SOURCE=.\gstream.cpp # End Source File # Begin Source File +SOURCE=.\examples\ha_archive.cpp +# End Source File +# Begin Source File + SOURCE=.\ha_blackhole.cpp # End Source File # Begin Source File diff --git a/VC++Files/strings/strings_ia64.dsp b/VC++Files/strings/strings_ia64.dsp index a34a238dfdc..c0b7b9c292c 100644 --- a/VC++Files/strings/strings_ia64.dsp +++ b/VC++Files/strings/strings_ia64.dsp @@ -120,6 +120,10 @@ SOURCE=".\ctype-czech.c" # End Source File # Begin Source File +SOURCE=".\ctype-cp932.c" +# End Source File +# Begin Source File + SOURCE=".\ctype-euc_kr.c" # End Source File # Begin Source File diff --git a/client/client_priv.h b/client/client_priv.h index d656e54a2b8..c8aa7385276 100644 --- a/client/client_priv.h +++ b/client/client_priv.h @@ -49,5 +49,5 @@ enum options_client #ifdef HAVE_NDBCLUSTER_DB OPT_NDBCLUSTER, OPT_NDB_CONNECTSTRING, #endif - OPT_IGNORE_TABLE,OPT_INSERT_IGNORE,OPT_SHOW_WARNINGS + OPT_IGNORE_TABLE,OPT_INSERT_IGNORE,OPT_SHOW_WARNINGS,OPT_DROP_DATABASE }; diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc index 32e0dfdb837..5164661b69a 100644 --- a/client/mysqladmin.cc +++ b/client/mysqladmin.cc @@ -271,7 +271,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), option_wait=1; } else - option_wait= ~0; + option_wait= ~(uint)0; break; case '?': case 'I': /* Info */ diff --git a/client/mysqldump.c b/client/mysqldump.c index 953e690f083..907b6233590 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -85,7 +85,7 @@ static my_bool verbose=0,tFlag=0,dFlag=0,quick= 1, extended_insert= 1, opt_delete_master_logs=0, tty_password=0, opt_single_transaction=0, opt_comments= 0, opt_compact= 0, opt_hex_blob=0, opt_order_by_primary=0, opt_ignore=0, - opt_complete_insert= 0; + opt_complete_insert= 0, opt_drop_database= 0; static ulong opt_max_allowed_packet, opt_net_buffer_length; static MYSQL mysql_connection,*sock=0; static my_bool insert_pat_inited=0; @@ -161,6 +161,9 @@ static struct my_option my_long_options[] = "Dump all the databases. This will be same as --databases with all databases selected.", (gptr*) &opt_alldbs, (gptr*) &opt_alldbs, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"add-drop-database", OPT_DROP_DATABASE, "Add a 'DROP DATABASE' before each create.", + (gptr*) &opt_drop_database, (gptr*) &opt_drop_database, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, + 0}, {"add-drop-table", OPT_DROP, "Add a 'drop table' before each create.", (gptr*) &opt_drop, (gptr*) &opt_drop, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, @@ -1144,9 +1147,9 @@ static uint get_table_structure(char *table, char *db) else dynstr_set(&insert_pat, ""); - insert_option= (opt_delayed && opt_ignore) ? " DELAYED IGNORE " : - opt_delayed ? " DELAYED " : - opt_ignore ? " IGNORE " : ""; + insert_option= ((opt_delayed && opt_ignore) ? " DELAYED IGNORE " : + opt_delayed ? " DELAYED " : + opt_ignore ? " IGNORE " : ""); if (verbose) fprintf(stderr, "-- Retrieving table structure for table %s...\n", table); @@ -2116,12 +2119,20 @@ static int init_dumping(char *database) if (mysql_query(sock, qbuf) || !(dbinfo = mysql_store_result(sock))) { /* Old server version, dump generic CREATE DATABASE */ + if (opt_drop_database) + fprintf(md_result_file, + "\n/*!40000 DROP DATABASE IF EXISTS %s;*/\n", + qdatabase); fprintf(md_result_file, "\nCREATE DATABASE /*!32312 IF NOT EXISTS*/ %s;\n", qdatabase); } else { + if (opt_drop_database) + fprintf(md_result_file, + "\n/*!40000 DROP DATABASE IF EXISTS %s*/;\n", + qdatabase); row = mysql_fetch_row(dbinfo); if (row[1]) { diff --git a/client/sql_string.cc b/client/sql_string.cc index 0424723d97f..be4354227a5 100644 --- a/client/sql_string.cc +++ b/client/sql_string.cc @@ -16,11 +16,12 @@ /* This file is originally from the mysql distribution. Coded by monty */ -#ifdef __GNUC__ +#include + +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif -#include #include #include #include diff --git a/client/sql_string.h b/client/sql_string.h index 2debeb61787..242b31e7ed6 100644 --- a/client/sql_string.h +++ b/client/sql_string.h @@ -16,7 +16,7 @@ /* This file is originally from the mysql distribution. Coded by monty */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ #endif diff --git a/configure.in b/configure.in index 332b851402d..936e4ed22e1 100644 --- a/configure.in +++ b/configure.in @@ -17,7 +17,7 @@ SHARED_LIB_VERSION=14:0:0 # ndb version NDB_VERSION_MAJOR=5 NDB_VERSION_MINOR=0 -NDB_VERSION_BUILD=6 +NDB_VERSION_BUILD=7 NDB_VERSION_STATUS="beta" # Set all version vars based on $VERSION. How do we do this more elegant ? @@ -1195,16 +1195,10 @@ EOF # echo -n "making sure specific build files are writable... " for file in \ - Docs/include.texi \ Docs/mysql.info \ - Docs/manual.txt \ - Docs/manual_toc.html \ - Docs/manual.html \ Docs/INSTALL-BINARY \ INSTALL-SOURCE \ - COPYING \ - COPYING.LIB \ - MIRRORS + COPYING do if test -e $file; then chmod +w $file diff --git a/extra/yassl/include/buffer.hpp b/extra/yassl/include/buffer.hpp index cdf44ee60a5..8d94675f5b0 100644 --- a/extra/yassl/include/buffer.hpp +++ b/extra/yassl/include/buffer.hpp @@ -28,6 +28,7 @@ #define yaSSL_BUFFER_HPP #include // assert +#include "yassl_types.hpp" // ysDelete #include "yassl_error.hpp" // Error #include "memory.hpp" // mySTL::auto_ptr #include "algorithm.hpp" // mySTL::swap @@ -183,7 +184,7 @@ inline void checked_delete(T* p) { typedef char complete_type[sizeof(T) ? 1 : -1]; (void)sizeof(complete_type); - delete p; + ysDelete(p); } diff --git a/extra/yassl/include/crypto_wrapper.hpp b/extra/yassl/include/crypto_wrapper.hpp index fa60c774cd9..ca9d870677e 100644 --- a/extra/yassl/include/crypto_wrapper.hpp +++ b/extra/yassl/include/crypto_wrapper.hpp @@ -43,7 +43,7 @@ namespace yaSSL { // Digest policy should implement a get_digest, update, and get sizes for pad and // digest -struct Digest { +struct Digest : public virtual_base { virtual void get_digest(byte*) = 0; virtual void get_digest(byte*, const byte*, unsigned int) = 0; virtual void update(const byte*, unsigned int) = 0; @@ -178,7 +178,7 @@ private: // BulkCipher policy should implement encrypt, decrypt, get block size, // and set keys for encrypt and decrypt -struct BulkCipher { +struct BulkCipher : public virtual_base { virtual void encrypt(byte*, const byte*, unsigned int) = 0; virtual void decrypt(byte*, const byte*, unsigned int) = 0; virtual void set_encryptKey(const byte*, const byte* = 0) = 0; @@ -308,7 +308,7 @@ private: // Authentication policy should implement sign, and verify -struct Auth { +struct Auth : public virtual_base { virtual void sign(byte*, const byte*, unsigned int, const RandomPool&) = 0; virtual bool verify(const byte*, unsigned int, const byte*, unsigned int) = 0; diff --git a/extra/yassl/include/factory.hpp b/extra/yassl/include/factory.hpp index 96798466352..7f7aaf8bd7f 100644 --- a/extra/yassl/include/factory.hpp +++ b/extra/yassl/include/factory.hpp @@ -67,7 +67,7 @@ public: init(*this); } - // reservce place in vector before registering, used by init funcion + // reserve place in vector before registering, used by init funcion void Reserve(size_t sz) { callbacks_.reserve(sz); diff --git a/extra/yassl/include/socket_wrapper.hpp b/extra/yassl/include/socket_wrapper.hpp index 2a4ac142ec8..a103cca1b37 100644 --- a/extra/yassl/include/socket_wrapper.hpp +++ b/extra/yassl/include/socket_wrapper.hpp @@ -68,7 +68,7 @@ class Socket { socket_t socket_; // underlying socket descriptor public: explicit Socket(socket_t s = INVALID_SOCKET); - virtual ~Socket(); + ~Socket(); void set_fd(socket_t s); uint get_ready() const; diff --git a/extra/yassl/include/yassl_imp.hpp b/extra/yassl/include/yassl_imp.hpp index 52108b6aa1c..3de58901f8e 100644 --- a/extra/yassl/include/yassl_imp.hpp +++ b/extra/yassl/include/yassl_imp.hpp @@ -63,7 +63,7 @@ struct RecordLayerHeader { // base for all messages -struct Message { +struct Message : public virtual_base { virtual input_buffer& set(input_buffer&) =0; virtual output_buffer& get(output_buffer&) const =0; @@ -175,7 +175,7 @@ private: // Base Class for all handshake messages -class HandShakeBase { +class HandShakeBase : public virtual_base { int length_; public: int get_length() const; @@ -327,7 +327,7 @@ private: }; -struct ServerKeyBase { +struct ServerKeyBase : public virtual_base { virtual ~ServerKeyBase() {} virtual void build(SSL&) {} virtual void read(SSL&, input_buffer&) {} @@ -342,7 +342,7 @@ struct Fortezza_Server : public ServerKeyBase { }; -struct SignatureBase { +struct SignatureBase : public virtual_base { virtual ~SignatureBase() {} }; @@ -461,7 +461,7 @@ struct PreMasterSecret { }; -struct ClientKeyBase { +struct ClientKeyBase : public virtual_base { virtual ~ClientKeyBase() {} virtual void build(SSL&) {} virtual void read(SSL&, input_buffer&) {} diff --git a/extra/yassl/include/yassl_int.hpp b/extra/yassl/include/yassl_int.hpp index 02895d3897b..876f730a07d 100644 --- a/extra/yassl/include/yassl_int.hpp +++ b/extra/yassl/include/yassl_int.hpp @@ -31,8 +31,8 @@ #include "yassl_imp.hpp" #include "crypto_wrapper.hpp" #include "cert_wrapper.hpp" -#include "lock.hpp" #include "log.hpp" +#include "lock.hpp" namespace yaSSL { @@ -122,7 +122,8 @@ public: friend sslFactory& GetSSL_Factory(); // singleton creator private: - static sslFactory instance; + static sslFactory instance_; + sslFactory(const sslFactory&); // hide copy sslFactory& operator=(const sslFactory&); // and assign }; @@ -207,9 +208,10 @@ public: friend Sessions& GetSessions(); // singleton creator private: + static Sessions instance_; + Sessions(const Sessions&); // hide copy Sessions& operator=(const Sessions&); // and assign - static Sessions instance; }; diff --git a/extra/yassl/include/yassl_types.hpp b/extra/yassl/include/yassl_types.hpp index 1ad4998bade..fc6bef89aab 100644 --- a/extra/yassl/include/yassl_types.hpp +++ b/extra/yassl/include/yassl_types.hpp @@ -28,6 +28,9 @@ #define yaSSL_TYPES_HPP #include +#include +#include "type_traits.hpp" + namespace yaSSL { @@ -40,9 +43,41 @@ extern new_t ys; // pass in parameter void* operator new (size_t, yaSSL::new_t); void* operator new[](size_t, yaSSL::new_t); +void operator delete (void*, yaSSL::new_t); +void operator delete[](void*, yaSSL::new_t); + + namespace yaSSL { +template +void ysDelete(T* ptr) +{ + if (ptr) ptr->~T(); + ::operator delete(ptr, yaSSL::ys); +} + +template +void ysArrayDelete(T* ptr) +{ + // can't do array placement destruction since not tracking size in + // allocation, only allow builtins to use array placement since they + // don't need destructors called + typedef char builtin[TaoCrypt::IsFundamentalType::Yes ? 1 : -1]; + (void)sizeof(builtin); + + ::operator delete[](ptr, yaSSL::ys); +} + + +// to resolve compiler generated operator delete on base classes with +// virtual destructors, make sure doesn't get called +class virtual_base { +public: + static void operator delete(void*) { assert(0); } +}; + + typedef unsigned char uint8; typedef unsigned short uint16; typedef unsigned int uint32; diff --git a/extra/yassl/mySTL/helpers.hpp b/extra/yassl/mySTL/helpers.hpp index 779389e322a..5f9b4beaa40 100644 --- a/extra/yassl/mySTL/helpers.hpp +++ b/extra/yassl/mySTL/helpers.hpp @@ -28,6 +28,7 @@ #define mySTL_HELPERS_HPP #include +#include // placement new #ifdef __IBMCPP__ diff --git a/extra/yassl/mySTL/list.hpp b/extra/yassl/mySTL/list.hpp index be149b1a984..8aaeefaafe8 100644 --- a/extra/yassl/mySTL/list.hpp +++ b/extra/yassl/mySTL/list.hpp @@ -29,7 +29,7 @@ #include "helpers.hpp" -#include // ::operator new and delete, placement too +#include namespace mySTL { @@ -38,13 +38,15 @@ namespace mySTL { template class list { + #ifdef __SUNPRO_CC /* - Sun Forte 7 C++ v. 5.4 needs class 'node' be public to be visible to - the nested class 'iterator' (a non-standard behaviour). + Sun Forte 7 C++ v. 5.4 needs class 'node' public to be visible to + the nested class 'iterator' (a non-standard behaviour). */ public: #endif + struct node { node(T t) : prev_(0), next_(0), value_(t) {} @@ -94,22 +96,22 @@ public: return *this; } - iterator& operator++(int) + iterator operator++(int) { iterator tmp = *this; current_ = current_->next_; - return *this; + return tmp; } - iterator& operator--(int) + iterator operator--(int) { iterator tmp = *this; current_ = current_->prev_; - return *this; + return tmp; } bool operator==(const iterator& other) const - { + { return current_ == other.current_; } @@ -152,7 +154,7 @@ list::~list() for (; start; start = next_) { next_ = start->next_; destroy(start); - ::operator delete(start); + free(start); } } @@ -160,7 +162,7 @@ list::~list() template void list::push_front(T t) { - void* mem = ::operator new(sizeof(node)); + void* mem = malloc(sizeof(node)); if (!mem) abort(); node* add = new (mem) node(t); @@ -190,7 +192,7 @@ void list::pop_front() head_->prev_ = 0; } destroy(front); - ::operator delete(front); + free(front); --sz_; } @@ -206,7 +208,7 @@ T list::front() const template void list::push_back(T t) { - void* mem = ::operator new(sizeof(node)); + void* mem = malloc(sizeof(node)); if (!mem) abort(); node* add = new (mem) node(t); @@ -236,7 +238,7 @@ void list::pop_back() tail_->next_ = 0; } destroy(rear); - ::operator delete(rear); + free(rear); --sz_; } @@ -280,7 +282,7 @@ bool list::remove(T t) del->next_->prev_ = del->prev_; destroy(del); - ::operator delete(del); + free(del); --sz_; } return true; @@ -303,7 +305,7 @@ bool list::erase(iterator iter) del->next_->prev_ = del->prev_; destroy(del); - ::operator delete(del); + free(del); --sz_; } return true; diff --git a/extra/yassl/mySTL/memory.hpp b/extra/yassl/mySTL/memory.hpp index 4049ed80813..729abae7ebc 100644 --- a/extra/yassl/mySTL/memory.hpp +++ b/extra/yassl/mySTL/memory.hpp @@ -37,30 +37,42 @@ namespace mySTL { -template +template struct auto_ptr_ref { - T* ptr_; - explicit auto_ptr_ref(T* p) : ptr_(p) {} + T* ptr_; + Deletor del_; + auto_ptr_ref(T* p, Deletor d) : ptr_(p), del_(d) {} }; -template +template class auto_ptr { - T* ptr_; + T* ptr_; + Deletor del_; + + void Destroy() + { + del_(ptr_); + } public: - explicit auto_ptr(T* p = 0) : ptr_(p) {} + auto_ptr(T* p, Deletor d) : ptr_(p), del_(d) {} + + explicit auto_ptr(Deletor d) : ptr_(0), del_(d) {} + ~auto_ptr() { - delete ptr_; + Destroy(); } - auto_ptr(auto_ptr& other) : ptr_(other.release()) {} + auto_ptr(auto_ptr& other) : ptr_(other.release()), del_(other.del_) {} + auto_ptr& operator=(auto_ptr& that) { if (this != &that) { - delete ptr_; + Destroy(); ptr_ = that.release(); + del_ = that.del_; } return *this; } @@ -91,19 +103,20 @@ public: void reset(T* p = 0) { if (ptr_ != p) { - delete ptr_; + Destroy(); ptr_ = p; } } // auto_ptr_ref conversions - auto_ptr(auto_ptr_ref ref) : ptr_(ref.ptr_) {} + auto_ptr(auto_ptr_ref ref) : ptr_(ref.ptr_), del_(ref.del_) {} auto_ptr& operator=(auto_ptr_ref ref) { if (this->ptr_ != ref.ptr_) { - delete ptr_; + Destroy(); ptr_ = ref.ptr_; + del_ = ref.del_; } return *this; } @@ -111,13 +124,13 @@ public: template operator auto_ptr() { - return auto_ptr(this->release()); + return auto_ptr(this->release(), this->del_); } template operator auto_ptr_ref() { - return auto_ptr_ref(this->release()); + return auto_ptr_ref(this->release(), this->del_); } }; diff --git a/extra/yassl/mySTL/vector.hpp b/extra/yassl/mySTL/vector.hpp index 6d5a9b6c057..e7f63c37c7c 100644 --- a/extra/yassl/mySTL/vector.hpp +++ b/extra/yassl/mySTL/vector.hpp @@ -27,11 +27,10 @@ #ifndef mySTL_VECTOR_HPP #define mySTL_VECTOR_HPP - #include "helpers.hpp" // construct, destory, fill, etc. #include "algorithm.hpp" // swap -#include // ::operator new and delete, placement too #include // assert +#include // malloc namespace mySTL { @@ -46,13 +45,13 @@ struct vector_base { vector_base() : start_(0), finish_(0), end_of_storage_(0) {} vector_base(size_t n) { - start_ = static_cast(::operator new(n * sizeof(T))); + start_ = static_cast(malloc(n * sizeof(T))); if (!start_) abort(); finish_ = start_; end_of_storage_ = start_ + n; } - ~vector_base() { ::operator delete(start_); } + ~vector_base() { if (start_) free(start_); } void Swap(vector_base& that) { diff --git a/extra/yassl/src/Makefile.am b/extra/yassl/src/Makefile.am index 3dbd7bac03a..1f5f1ee7a4e 100644 --- a/extra/yassl/src/Makefile.am +++ b/extra/yassl/src/Makefile.am @@ -3,5 +3,5 @@ INCLUDES = -I../include -I../taocrypt/include -I../mySTL noinst_LIBRARIES = libyassl.a libyassl_a_SOURCES = buffer.cpp cert_wrapper.cpp crypto_wrapper.cpp \ handshake.cpp lock.cpp log.cpp socket_wrapper.cpp ssl.cpp \ - timer.cpp yassl_imp.cpp yassl_error.cpp yassl_int.cpp + template_instnt.cpp timer.cpp yassl_imp.cpp yassl_error.cpp yassl_int.cpp EXTRA_DIST = ../include/*.hpp ../include/openssl/*.h diff --git a/extra/yassl/src/buffer.cpp b/extra/yassl/src/buffer.cpp index c97103c6f6d..a3a09121800 100644 --- a/extra/yassl/src/buffer.cpp +++ b/extra/yassl/src/buffer.cpp @@ -24,7 +24,6 @@ * with SSL types and sockets */ -#include "runtime.hpp" #include "buffer.hpp" #include "yassl_types.hpp" @@ -76,7 +75,7 @@ input_buffer::input_buffer(uint s, const byte* t, uint len) input_buffer::~input_buffer() { - delete [] buffer_; + ysArrayDelete(buffer_); } @@ -96,7 +95,7 @@ byte* input_buffer::get_buffer() const } -// after a raw write user can set new size +// after a raw write user can set new (ys) size // if you know the size before the write use assign() void input_buffer::add_size(uint i) { @@ -212,7 +211,7 @@ output_buffer::output_buffer(uint s, const byte* t, uint len) output_buffer::~output_buffer() { - delete [] buffer_; + ysArrayDelete(buffer_); } diff --git a/extra/yassl/src/cert_wrapper.cpp b/extra/yassl/src/cert_wrapper.cpp index 98861d01287..7a8c7dfe253 100644 --- a/extra/yassl/src/cert_wrapper.cpp +++ b/extra/yassl/src/cert_wrapper.cpp @@ -24,7 +24,6 @@ * */ -#include "runtime.hpp" #include "cert_wrapper.hpp" #include "yassl_int.hpp" @@ -46,7 +45,7 @@ x509::x509(uint sz) : length_(sz), buffer_(new (ys) opaque[sz]) x509::~x509() { - delete [] buffer_; + ysArrayDelete(buffer_); } @@ -98,7 +97,7 @@ CertManager::CertManager() CertManager::~CertManager() { - delete peerX509_; + ysDelete(peerX509_); mySTL::for_each(signers_.begin(), signers_.end(), del_ptr_zero()) ; @@ -273,13 +272,13 @@ int CertManager::SetPrivateKey(const x509& key) privateKey_.assign(key.get_buffer(), key.get_length()); // set key type - if (x509* cert509 = list_.front()) { - TaoCrypt::Source source(cert509->get_buffer(), cert509->get_length()); - TaoCrypt::CertDecoder cert(source, false); - cert.DecodeToKey(); - if (int err = cert.GetError().What()) + if (x509* cert = list_.front()) { + TaoCrypt::Source source(cert->get_buffer(), cert->get_length()); + TaoCrypt::CertDecoder cd(source, false); + cd.DecodeToKey(); + if (int err = cd.GetError().What()) return err; - if (cert.GetKeyType() == TaoCrypt::RSAk) + if (cd.GetKeyType() == TaoCrypt::RSAk) keyType_ = rsa_sa_algo; else keyType_ = dsa_sa_algo; diff --git a/extra/yassl/src/crypto_wrapper.cpp b/extra/yassl/src/crypto_wrapper.cpp index c083c56f313..ff1b4b630c2 100644 --- a/extra/yassl/src/crypto_wrapper.cpp +++ b/extra/yassl/src/crypto_wrapper.cpp @@ -61,7 +61,7 @@ struct MD5::MD5Impl { MD5::MD5() : pimpl_(new (ys) MD5Impl) {} -MD5::~MD5() { delete pimpl_; } +MD5::~MD5() { ysDelete(pimpl_); } MD5::MD5(const MD5& that) : Digest(), pimpl_(new (ys) @@ -119,11 +119,10 @@ struct SHA::SHAImpl { SHA::SHA() : pimpl_(new (ys) SHAImpl) {} -SHA::~SHA() { delete pimpl_; } +SHA::~SHA() { ysDelete(pimpl_); } -SHA::SHA(const SHA& that) : Digest(), pimpl_(new (ys) - SHAImpl(that.pimpl_->sha_)) {} +SHA::SHA(const SHA& that) : Digest(), pimpl_(new (ys) SHAImpl(that.pimpl_->sha_)) {} SHA& SHA::operator=(const SHA& that) { @@ -177,11 +176,10 @@ struct RMD::RMDImpl { RMD::RMD() : pimpl_(new (ys) RMDImpl) {} -RMD::~RMD() { delete pimpl_; } +RMD::~RMD() { ysDelete(pimpl_); } -RMD::RMD(const RMD& that) : Digest(), pimpl_(new (ys) - RMDImpl(that.pimpl_->rmd_)) {} +RMD::RMD(const RMD& that) : Digest(), pimpl_(new (ys) RMDImpl(that.pimpl_->rmd_)) {} RMD& RMD::operator=(const RMD& that) { @@ -238,7 +236,7 @@ HMAC_MD5::HMAC_MD5(const byte* secret, unsigned int len) } -HMAC_MD5::~HMAC_MD5() { delete pimpl_; } +HMAC_MD5::~HMAC_MD5() { ysDelete(pimpl_); } uint HMAC_MD5::get_digestSize() const @@ -288,7 +286,7 @@ HMAC_SHA::HMAC_SHA(const byte* secret, unsigned int len) } -HMAC_SHA::~HMAC_SHA() { delete pimpl_; } +HMAC_SHA::~HMAC_SHA() { ysDelete(pimpl_); } uint HMAC_SHA::get_digestSize() const @@ -339,7 +337,7 @@ HMAC_RMD::HMAC_RMD(const byte* secret, unsigned int len) } -HMAC_RMD::~HMAC_RMD() { delete pimpl_; } +HMAC_RMD::~HMAC_RMD() { ysDelete(pimpl_); } uint HMAC_RMD::get_digestSize() const @@ -383,7 +381,7 @@ struct DES::DESImpl { DES::DES() : pimpl_(new (ys) DESImpl) {} -DES::~DES() { delete pimpl_; } +DES::~DES() { ysDelete(pimpl_); } void DES::set_encryptKey(const byte* k, const byte* iv) @@ -419,7 +417,7 @@ struct DES_EDE::DES_EDEImpl { DES_EDE::DES_EDE() : pimpl_(new (ys) DES_EDEImpl) {} -DES_EDE::~DES_EDE() { delete pimpl_; } +DES_EDE::~DES_EDE() { ysDelete(pimpl_); } void DES_EDE::set_encryptKey(const byte* k, const byte* iv) @@ -457,7 +455,7 @@ struct RC4::RC4Impl { RC4::RC4() : pimpl_(new (ys) RC4Impl) {} -RC4::~RC4() { delete pimpl_; } +RC4::~RC4() { ysDelete(pimpl_); } void RC4::set_encryptKey(const byte* k, const byte*) @@ -499,7 +497,7 @@ struct AES::AESImpl { AES::AES(unsigned int ks) : pimpl_(new (ys) AESImpl(ks)) {} -AES::~AES() { delete pimpl_; } +AES::~AES() { ysDelete(pimpl_); } int AES::get_keySize() const @@ -540,7 +538,7 @@ struct RandomPool::RandomImpl { RandomPool::RandomPool() : pimpl_(new (ys) RandomImpl) {} -RandomPool::~RandomPool() { delete pimpl_; } +RandomPool::~RandomPool() { ysDelete(pimpl_); } int RandomPool::GetError() const { @@ -593,7 +591,7 @@ DSS::DSS(const byte* key, unsigned int sz, bool publicKey) DSS::~DSS() { - delete pimpl_; + ysDelete(pimpl_); } @@ -663,7 +661,7 @@ RSA::RSA(const byte* key, unsigned int sz, bool publicKey) RSA::~RSA() { - delete pimpl_; + ysDelete(pimpl_); } @@ -727,7 +725,7 @@ struct Integer::IntegerImpl { Integer::Integer() : pimpl_(new (ys) IntegerImpl) {} -Integer::~Integer() { delete pimpl_; } +Integer::~Integer() { ysDelete(pimpl_); } @@ -759,7 +757,12 @@ struct DiffieHellman::DHImpl { DHImpl(TaoCrypt::RandomNumberGenerator& r) : ranPool_(r), publicKey_(0), privateKey_(0), agreedKey_(0) {} - ~DHImpl() {delete[] agreedKey_; delete[] privateKey_; delete[] publicKey_;} + ~DHImpl() + { + ysArrayDelete(agreedKey_); + ysArrayDelete(privateKey_); + ysArrayDelete(publicKey_); + } DHImpl(const DHImpl& that) : dh_(that.dh_), ranPool_(that.ranPool_), publicKey_(0), privateKey_(0), agreedKey_(0) @@ -831,7 +834,7 @@ DiffieHellman::DiffieHellman(const Integer& p, const Integer& g, pimpl_->publicKey_); } -DiffieHellman::~DiffieHellman() { delete pimpl_; } +DiffieHellman::~DiffieHellman() { ysDelete(pimpl_); } // Client side and view, use server that for p and g @@ -957,7 +960,7 @@ x509* PemToDer(const char* fname, CertType type) Base64Decoder b64Dec(der); uint sz = der.size(); - mySTL::auto_ptr x(new (ys) x509(sz)); + mySTL::auto_ptr x(new (ys) x509(sz), ysDelete); memcpy(x->use_buffer(), der.get_buffer(), sz); fclose(file); @@ -967,12 +970,25 @@ x509* PemToDer(const char* fname, CertType type) } // namespace + #ifdef __GNUC__ -template class TaoCrypt::HMAC; -template class TaoCrypt::HMAC; -template class TaoCrypt::HMAC; -template class TaoCrypt::Mode_BASE<16>; -template class TaoCrypt::Mode_BASE<8>; -#endif +namespace yaSSL { +template void ysDelete(DiffieHellman::DHImpl*); +template void ysDelete(Integer::IntegerImpl*); +template void ysDelete(RSA::RSAImpl*); +template void ysDelete(DSS::DSSImpl*); +template void ysDelete(RandomPool::RandomImpl*); +template void ysDelete(AES::AESImpl*); +template void ysDelete(RC4::RC4Impl*); +template void ysDelete(DES_EDE::DES_EDEImpl*); +template void ysDelete(DES::DESImpl*); +template void ysDelete(HMAC_RMD::HMAC_RMDImpl*); +template void ysDelete(HMAC_SHA::HMAC_SHAImpl*); +template void ysDelete(HMAC_MD5::HMAC_MD5Impl*); +template void ysDelete(RMD::RMDImpl*); +template void ysDelete(SHA::SHAImpl*); +template void ysDelete(MD5::MD5Impl*); +} +#endif // __GNUC__ #endif // !USE_CRYPTOPP_LIB diff --git a/extra/yassl/src/handshake.cpp b/extra/yassl/src/handshake.cpp index 35c4cbd4922..e49d1ec76cc 100644 --- a/extra/yassl/src/handshake.cpp +++ b/extra/yassl/src/handshake.cpp @@ -357,7 +357,7 @@ void p_hash(output_buffer& result, const output_buffer& secret, uint lastLen = result.get_capacity() % len; opaque previous[SHA_LEN]; // max size opaque current[SHA_LEN]; // max size - mySTL::auto_ptr hmac; + mySTL::auto_ptr hmac(ysDelete); if (lastLen) times += 1; @@ -571,7 +571,7 @@ void hmac(SSL& ssl, byte* digest, const byte* buffer, uint sz, void TLS_hmac(SSL& ssl, byte* digest, const byte* buffer, uint sz, ContentType content, bool verify) { - mySTL::auto_ptr hmac; + mySTL::auto_ptr hmac(ysDelete); opaque seq[SEQ_SZ] = { 0x00, 0x00, 0x00, 0x00 }; opaque length[LENGTH_SZ]; opaque inner[SIZEOF_ENUM + VERSION_SZ + LENGTH_SZ]; // type + version + len @@ -648,7 +648,7 @@ void build_certHashes(SSL& ssl, Hashes& hashes) } -mySTL::auto_ptr null_buffer; +mySTL::auto_ptr null_buffer(ysDelete); // do process input requests mySTL::auto_ptr @@ -666,7 +666,7 @@ DoProcessReply(SSL& ssl, mySTL::auto_ptr buffered) buffered = null_buffer; } - // add new data + // add new (ys) data uint read = ssl.getSocket().receive(buffer.get_buffer() + buffSz, ready); buffer.add_size(read); uint offset = 0; @@ -696,7 +696,7 @@ DoProcessReply(SSL& ssl, mySTL::auto_ptr buffered) // each message in record if (ssl.getSecurity().get_parms().pending_ == false) // cipher on decrypt_message(ssl, buffer, hdr.length_); - mySTL::auto_ptr msg(mf.CreateObject(hdr.type_)); + mySTL::auto_ptr msg(mf.CreateObject(hdr.type_), ysDelete); if (!msg.get()) { ssl.SetError(factory_error); return buffered = null_buffer; @@ -715,7 +715,7 @@ DoProcessReply(SSL& ssl, mySTL::auto_ptr buffered) void processReply(SSL& ssl) { if (ssl.GetError()) return; - mySTL::auto_ptr buffered; + mySTL::auto_ptr buffered(ysDelete); for (;;) { mySTL::auto_ptr tmp = DoProcessReply(ssl, buffered); @@ -760,7 +760,7 @@ void sendClientKeyExchange(SSL& ssl, BufferOutput buffer) RecordLayerHeader rlHeader; HandShakeHeader hsHeader; - mySTL::auto_ptr out(new (ys) output_buffer); + mySTL::auto_ptr out(new (ys) output_buffer, ysDelete); buildHeaders(ssl, hsHeader, rlHeader, ck); buildOutput(*out.get(), rlHeader, hsHeader, ck); hashHandShake(ssl, *out.get()); @@ -781,7 +781,7 @@ void sendServerKeyExchange(SSL& ssl, BufferOutput buffer) RecordLayerHeader rlHeader; HandShakeHeader hsHeader; - mySTL::auto_ptr out(new (ys) output_buffer); + mySTL::auto_ptr out(new (ys) output_buffer, ysDelete); buildHeaders(ssl, hsHeader, rlHeader, sk); buildOutput(*out.get(), rlHeader, hsHeader, sk); hashHandShake(ssl, *out.get()); @@ -806,7 +806,7 @@ void sendChangeCipher(SSL& ssl, BufferOutput buffer) ChangeCipherSpec ccs; RecordLayerHeader rlHeader; buildHeader(ssl, rlHeader, ccs); - mySTL::auto_ptr out(new (ys) output_buffer); + mySTL::auto_ptr out(new (ys) output_buffer, ysDelete); buildOutput(*out.get(), rlHeader, ccs); if (buffer == buffered) @@ -823,7 +823,7 @@ void sendFinished(SSL& ssl, ConnectionEnd side, BufferOutput buffer) Finished fin; buildFinished(ssl, fin, side == client_end ? client : server); - mySTL::auto_ptr out(new (ys) output_buffer); + mySTL::auto_ptr out(new (ys) output_buffer, ysDelete); cipherFinished(ssl, fin, *out.get()); // hashes handshake if (ssl.getSecurity().get_resuming()) { @@ -907,7 +907,7 @@ void sendServerHello(SSL& ssl, BufferOutput buffer) ServerHello sh(ssl.getSecurity().get_connection().version_); RecordLayerHeader rlHeader; HandShakeHeader hsHeader; - mySTL::auto_ptr out(new (ys) output_buffer); + mySTL::auto_ptr out(new (ys) output_buffer, ysDelete); buildServerHello(ssl, sh); ssl.set_random(sh.get_random(), server_end); @@ -930,7 +930,7 @@ void sendServerHelloDone(SSL& ssl, BufferOutput buffer) ServerHelloDone shd; RecordLayerHeader rlHeader; HandShakeHeader hsHeader; - mySTL::auto_ptr out(new (ys) output_buffer); + mySTL::auto_ptr out(new (ys) output_buffer, ysDelete); buildHeaders(ssl, hsHeader, rlHeader, shd); buildOutput(*out.get(), rlHeader, hsHeader, shd); @@ -951,7 +951,7 @@ void sendCertificate(SSL& ssl, BufferOutput buffer) Certificate cert(ssl.getCrypto().get_certManager().get_cert()); RecordLayerHeader rlHeader; HandShakeHeader hsHeader; - mySTL::auto_ptr out(new (ys) output_buffer); + mySTL::auto_ptr out(new (ys) output_buffer, ysDelete); buildHeaders(ssl, hsHeader, rlHeader, cert); buildOutput(*out.get(), rlHeader, hsHeader, cert); @@ -973,7 +973,7 @@ void sendCertificateRequest(SSL& ssl, BufferOutput buffer) request.Build(); RecordLayerHeader rlHeader; HandShakeHeader hsHeader; - mySTL::auto_ptr out(new (ys) output_buffer); + mySTL::auto_ptr out(new (ys) output_buffer, ysDelete); buildHeaders(ssl, hsHeader, rlHeader, request); buildOutput(*out.get(), rlHeader, hsHeader, request); @@ -995,7 +995,7 @@ void sendCertificateVerify(SSL& ssl, BufferOutput buffer) verify.Build(ssl); RecordLayerHeader rlHeader; HandShakeHeader hsHeader; - mySTL::auto_ptr out(new (ys) output_buffer); + mySTL::auto_ptr out(new (ys) output_buffer, ysDelete); buildHeaders(ssl, hsHeader, rlHeader, verify); buildOutput(*out.get(), rlHeader, hsHeader, verify); diff --git a/extra/yassl/src/lock.cpp b/extra/yassl/src/lock.cpp index 221ec0cdb4f..b8f6212ad3f 100644 --- a/extra/yassl/src/lock.cpp +++ b/extra/yassl/src/lock.cpp @@ -22,7 +22,6 @@ /* Locking functions */ -#include "runtime.hpp" #include "lock.hpp" diff --git a/extra/yassl/src/log.cpp b/extra/yassl/src/log.cpp index eb4776d3d19..538b80b8280 100644 --- a/extra/yassl/src/log.cpp +++ b/extra/yassl/src/log.cpp @@ -22,13 +22,12 @@ /* Debug logging functions */ -#include "runtime.hpp" #include "log.hpp" #ifdef YASSL_LOG - #include - #include - #include + #include + #include + #include #endif diff --git a/extra/yassl/src/socket_wrapper.cpp b/extra/yassl/src/socket_wrapper.cpp index 0dd30e6b696..f0d530f187c 100644 --- a/extra/yassl/src/socket_wrapper.cpp +++ b/extra/yassl/src/socket_wrapper.cpp @@ -26,7 +26,6 @@ */ -#include "runtime.hpp" #include "socket_wrapper.hpp" #include "yassl_error.hpp" diff --git a/extra/yassl/src/ssl.cpp b/extra/yassl/src/ssl.cpp index 53bd8a75ab6..466884f3cd9 100644 --- a/extra/yassl/src/ssl.cpp +++ b/extra/yassl/src/ssl.cpp @@ -32,7 +32,6 @@ /* see man pages for function descriptions */ -#include "runtime.hpp" #include "openssl/ssl.h" #include "handshake.hpp" #include "yassl_int.hpp" @@ -52,25 +51,25 @@ SSL_METHOD* SSLv3_method() SSL_METHOD* SSLv3_server_method() { - return new SSL_METHOD(server_end, ProtocolVersion(3,0)); + return new (ys) SSL_METHOD(server_end, ProtocolVersion(3,0)); } SSL_METHOD* SSLv3_client_method() { - return new SSL_METHOD(client_end, ProtocolVersion(3,0)); + return new (ys) SSL_METHOD(client_end, ProtocolVersion(3,0)); } SSL_METHOD* TLSv1_server_method() { - return new SSL_METHOD(server_end, ProtocolVersion(3,1)); + return new (ys) SSL_METHOD(server_end, ProtocolVersion(3,1)); } SSL_METHOD* TLSv1_client_method() { - return new SSL_METHOD(client_end, ProtocolVersion(3,1)); + return new (ys) SSL_METHOD(client_end, ProtocolVersion(3,1)); } @@ -83,25 +82,25 @@ SSL_METHOD* SSLv23_server_method() SSL_CTX* SSL_CTX_new(SSL_METHOD* method) { - return new SSL_CTX(method); + return new (ys) SSL_CTX(method); } void SSL_CTX_free(SSL_CTX* ctx) { - delete ctx; + ysDelete(ctx); } SSL* SSL_new(SSL_CTX* ctx) { - return new SSL(ctx); + return new (ys) SSL(ctx); } void SSL_free(SSL* ssl) { - delete ssl; + ysDelete(ssl); } @@ -638,7 +637,7 @@ void OpenSSL_add_all_algorithms() // compatibility only DH* DH_new(void) { - DH* dh = new DH; + DH* dh = new (ys) DH; if (dh) dh->p = dh->g = 0; return dh; @@ -647,9 +646,9 @@ DH* DH_new(void) void DH_free(DH* dh) { - delete dh->g; - delete dh->p; - delete dh; + ysDelete(dh->g); + ysDelete(dh->p); + ysDelete(dh); } @@ -659,7 +658,7 @@ BIGNUM* BN_bin2bn(const unsigned char* num, int sz, BIGNUM* retVal) { using mySTL::auto_ptr; bool created = false; - auto_ptr bn; + auto_ptr bn(ysDelete); if (!retVal) { created = true; @@ -712,14 +711,14 @@ const char* X509_verify_cert_error_string(long /* error */) const EVP_MD* EVP_md5(void) { // TODO: FIX add to some list for destruction - return new MD5; + return new (ys) MD5; } const EVP_CIPHER* EVP_des_ede3_cbc(void) { // TODO: FIX add to some list for destruction - return new DES_EDE; + return new (ys) DES_EDE; } diff --git a/extra/yassl/src/template_instnt.cpp b/extra/yassl/src/template_instnt.cpp new file mode 100644 index 00000000000..4ad1ec29249 --- /dev/null +++ b/extra/yassl/src/template_instnt.cpp @@ -0,0 +1,67 @@ +#include "runtime.hpp" +#include "handshake.hpp" +#include "yassl_int.hpp" +#include "crypto_wrapper.hpp" +#include "hmac.hpp" +#include "md5.hpp" +#include "sha.hpp" +#include "ripemd.hpp" +#include "openssl/ssl.h" + +#ifdef __GNUC__ +#if !defined(USE_CRYPTOPP_LIB) +namespace TaoCrypt { +template class HMAC; +template class HMAC; +template class HMAC; +} +#endif + +namespace mySTL { +template class mySTL::list; +template yaSSL::del_ptr_zero mySTL::for_each(mySTL::list::iterator, mySTL::list::iterator, yaSSL::del_ptr_zero); +template mySTL::pair* mySTL::uninit_copy*, mySTL::pair*>(mySTL::pair*, mySTL::pair*, mySTL::pair*); +template mySTL::pair* mySTL::uninit_copy*, mySTL::pair*>(mySTL::pair*, mySTL::pair*, mySTL::pair*); +template void mySTL::destroy*>(mySTL::pair*, mySTL::pair*); +template void mySTL::destroy*>(mySTL::pair*, mySTL::pair*); +template mySTL::pair* mySTL::uninit_copy*, mySTL::pair*>(mySTL::pair*, mySTL::pair*, mySTL::pair*); +template void mySTL::destroy*>(mySTL::pair*, mySTL::pair*); +template mySTL::pair* mySTL::uninit_copy*, mySTL::pair*>(mySTL::pair*, mySTL::pair*, mySTL::pair*); +template class mySTL::list; +template class mySTL::list; +template class mySTL::list; +template class mySTL::list; +template class mySTL::list; +template void mySTL::destroy*>(mySTL::pair*, mySTL::pair*); +template yaSSL::del_ptr_zero mySTL::for_each::iterator, yaSSL::del_ptr_zero>(mySTL::list::iterator, mySTL::list::iterator, yaSSL::del_ptr_zero); +template yaSSL::del_ptr_zero mySTL::for_each::iterator, yaSSL::del_ptr_zero>(mySTL::list::iterator, mySTL::list::iterator, yaSSL::del_ptr_zero); +template yaSSL::del_ptr_zero mySTL::for_each::iterator, yaSSL::del_ptr_zero>(mySTL::list::iterator, mySTL::list::iterator, yaSSL::del_ptr_zero); +template yaSSL::del_ptr_zero mySTL::for_each::iterator, yaSSL::del_ptr_zero>(mySTL::list::iterator, mySTL::list::iterator, yaSSL::del_ptr_zero); +template yaSSL::del_ptr_zero mySTL::for_each::iterator, yaSSL::del_ptr_zero>(mySTL::list::iterator, mySTL::list::iterator, yaSSL::del_ptr_zero); +} + +namespace yaSSL { +template void ysDelete(yaSSL::SSL_CTX*); +template void ysDelete(yaSSL::SSL*); +template void ysDelete(yaSSL::BIGNUM*); +template void ysDelete(unsigned char*); +template void ysDelete(yaSSL::DH*); +template void ysDelete(TaoCrypt::Signer*); +template void ysDelete(yaSSL::SSL_SESSION*); +template void ysDelete(input_buffer*); +template void ysDelete(output_buffer*); +template void ysDelete(x509*); +template void ysDelete(Auth*); +template void ysDelete(HandShakeBase*); +template void ysDelete(ServerKeyBase*); +template void ysDelete(ClientKeyBase*); +template void ysDelete(SSL_METHOD*); +template void ysDelete(DiffieHellman*); +template void ysDelete(BulkCipher*); +template void ysDelete(Digest*); +template void ysDelete(X509*); +template void ysDelete(Message*); +template void ysArrayDelete(unsigned char*); +template void ysArrayDelete(char*); +} +#endif diff --git a/extra/yassl/src/timer.cpp b/extra/yassl/src/timer.cpp index 49e7bb36776..547c31205c6 100644 --- a/extra/yassl/src/timer.cpp +++ b/extra/yassl/src/timer.cpp @@ -23,7 +23,6 @@ * */ -#include "runtime.hpp" #include "timer.hpp" namespace yaSSL { diff --git a/extra/yassl/src/yassl_error.cpp b/extra/yassl/src/yassl_error.cpp index c53aef2068d..6ae5a9f6663 100644 --- a/extra/yassl/src/yassl_error.cpp +++ b/extra/yassl/src/yassl_error.cpp @@ -23,7 +23,6 @@ /* yaSSL error implements and an exception class */ -#include "runtime.hpp" #include "yassl_error.hpp" namespace yaSSL { diff --git a/extra/yassl/src/yassl_imp.cpp b/extra/yassl/src/yassl_imp.cpp index c1485cce986..1d9db46816b 100644 --- a/extra/yassl/src/yassl_imp.cpp +++ b/extra/yassl/src/yassl_imp.cpp @@ -130,7 +130,7 @@ void DH_Server::build(SSL& ssl) parms_.alloc_pub(pubSz)); short sigSz = 0; - mySTL::auto_ptr auth; + mySTL::auto_ptr auth(ysDelete); const CertManager& cert = ssl.getCrypto().get_certManager(); if (ssl.getSecurity().get_parms().sig_algo_ == rsa_sa_algo) @@ -234,7 +234,7 @@ EncryptedPreMasterSecret::EncryptedPreMasterSecret() EncryptedPreMasterSecret::~EncryptedPreMasterSecret() { - delete[] secret_; + ysArrayDelete(secret_); } @@ -284,7 +284,7 @@ ClientDiffieHellmanPublic::ClientDiffieHellmanPublic() ClientDiffieHellmanPublic::~ClientDiffieHellmanPublic() { - delete[] Yc_; + ysArrayDelete(Yc_); } @@ -400,8 +400,8 @@ DH_Server::DH_Server() DH_Server::~DH_Server() { - delete[] keyMessage_; - delete[] signature_; + ysArrayDelete(keyMessage_); + ysArrayDelete(signature_); } @@ -594,7 +594,7 @@ void HandShakeHeader::Process(input_buffer& input, SSL& ssl) { ssl.verifyState(*this); const HandShakeFactory& hsf = ssl.getFactory().getHandShake(); - mySTL::auto_ptr hs(hsf.CreateObject(type_)); + mySTL::auto_ptr hs(hsf.CreateObject(type_), ysDelete); if (!hs.get()) { ssl.SetError(factory_error); return; @@ -1067,9 +1067,9 @@ ServerDHParams::ServerDHParams() ServerDHParams::~ServerDHParams() { - delete[] Ys_; - delete[] g_; - delete[] p_; + ysArrayDelete(Ys_); + ysArrayDelete(g_); + ysArrayDelete(p_); } @@ -1466,7 +1466,7 @@ ServerKeyExchange::ServerKeyExchange() ServerKeyExchange::~ServerKeyExchange() { - delete server_key_; + ysDelete(server_key_); } @@ -1647,7 +1647,7 @@ CertificateVerify::CertificateVerify() : signature_(0) CertificateVerify::~CertificateVerify() { - delete[] signature_; + ysArrayDelete(signature_); } @@ -1657,7 +1657,7 @@ void CertificateVerify::Build(SSL& ssl) uint16 sz = 0; byte len[VERIFY_HEADER]; - mySTL::auto_ptr sig; + mySTL::auto_ptr sig(ysArrayDelete); // sign const CertManager& cert = ssl.getCrypto().get_certManager(); @@ -1796,7 +1796,7 @@ ClientKeyExchange::ClientKeyExchange() ClientKeyExchange::~ClientKeyExchange() { - delete client_key_; + ysDelete(client_key_); } @@ -1969,7 +1969,7 @@ Connection::Connection(ProtocolVersion v, RandomPool& ran) Connection::~Connection() { - CleanMaster(); CleanPreMaster(); delete[] pre_master_secret_; + CleanMaster(); CleanPreMaster(); ysArrayDelete(pre_master_secret_); } @@ -2004,7 +2004,7 @@ void Connection::CleanPreMaster() volatile opaque* p = pre_master_secret_; clean(p, pre_secret_len_, random_); - delete[] pre_master_secret_; + ysArrayDelete(pre_master_secret_); pre_master_secret_ = 0; } } @@ -2089,30 +2089,5 @@ void InitClientKeyFactory(ClientKeyFactory& ckf) ckf.Register(fortezza_kea, CreateFortezzaClient); } + } // namespace - -#ifdef __GNUC__ -namespace mySTL { -template class mySTL::list; -template yaSSL::del_ptr_zero mySTL::for_each(mySTL::list::iterator, mySTL::list::iterator, yaSSL::del_ptr_zero); -template mySTL::pair* mySTL::uninit_copy*, mySTL::pair*>(mySTL::pair*, mySTL::pair*, mySTL::pair*); -template mySTL::pair* mySTL::uninit_copy*, mySTL::pair*>(mySTL::pair*, mySTL::pair*, mySTL::pair*); -template void mySTL::destroy*>(mySTL::pair*, mySTL::pair*); -template void mySTL::destroy*>(mySTL::pair*, mySTL::pair*); -template mySTL::pair* mySTL::uninit_copy*, mySTL::pair*>(mySTL::pair*, mySTL::pair*, mySTL::pair*); -template void mySTL::destroy*>(mySTL::pair*, mySTL::pair*); -template mySTL::pair* mySTL::uninit_copy*, mySTL::pair*>(mySTL::pair*, mySTL::pair*, mySTL::pair*); -template class mySTL::list; -template class mySTL::list; -template class mySTL::list; -template class mySTL::list; -template class mySTL::list; -template void mySTL::destroy*>(mySTL::pair*, mySTL::pair*); -template yaSSL::del_ptr_zero mySTL::for_each::iterator, yaSSL::del_ptr_zero>(mySTL::list::iterator, mySTL::list::iterator, yaSSL::del_ptr_zero); -template yaSSL::del_ptr_zero mySTL::for_each::iterator, yaSSL::del_ptr_zero>(mySTL::list::iterator, mySTL::list::iterator, yaSSL::del_ptr_zero); -template yaSSL::del_ptr_zero mySTL::for_each::iterator, yaSSL::del_ptr_zero>(mySTL::list::iterator, mySTL::list::iterator, yaSSL::del_ptr_zero); -template yaSSL::del_ptr_zero mySTL::for_each::iterator, yaSSL::del_ptr_zero>(mySTL::list::iterator, mySTL::list::iterator, yaSSL::del_ptr_zero); -template yaSSL::del_ptr_zero mySTL::for_each::iterator, yaSSL::del_ptr_zero>(mySTL::list::iterator, mySTL::list::iterator, yaSSL::del_ptr_zero); -} -#endif - diff --git a/extra/yassl/src/yassl_int.cpp b/extra/yassl/src/yassl_int.cpp index c552cfa7189..06be7a15503 100644 --- a/extra/yassl/src/yassl_int.cpp +++ b/extra/yassl/src/yassl_int.cpp @@ -24,7 +24,6 @@ * draft along with type conversion functions. */ -#include "runtime.hpp" #include "yassl_int.hpp" #include "handshake.hpp" #include "timer.hpp" @@ -33,34 +32,39 @@ void* operator new(size_t sz, yaSSL::new_t) { - void* ptr = ::operator new(sz); - + void* ptr = malloc(sz ? sz : 1); if (!ptr) abort(); return ptr; } -void* operator new[](size_t sz, yaSSL::new_t n) +void* operator new[](size_t sz, yaSSL::new_t) { -#if defined(_MSC_VER) && (_MSC_VER < 1300) - void* ptr = ::operator new(sz); // no ::operator new[] -#else - void* ptr = ::operator new[](sz); -#endif - + void* ptr = malloc(sz ? sz : 1); if (!ptr) abort(); return ptr; } +void operator delete(void* ptr, yaSSL::new_t) +{ + if (ptr) free(ptr); +} + +void operator delete[](void* ptr, yaSSL::new_t) +{ + if (ptr) free(ptr); +} + + namespace yaSSL { using mySTL::min; +new_t ys; // for yaSSL library new -new_t ys; // for library new // convert a 32 bit integer into a 24 bit one @@ -936,12 +940,14 @@ struct SumBuffer { } // namespace for locals using namespace yassl_int_cpp_local1; + uint SSL::bufferedData() { return mySTL::for_each(buffers_.getData().begin(),buffers_.getData().end(), SumData()).total_; } + // use input buffer to fill data void SSL::fillData(Data& data) { @@ -962,7 +968,7 @@ void SSL::fillData(Data& data) if (readSz == frontSz) { buffers_.useData().pop_front(); - delete front; + ysDelete(front); } if (data.get_length() == dataSz) break; @@ -986,7 +992,7 @@ void SSL::flushBuffer() out.write(front->get_buffer(), front->get_size()); buffers_.useHandShake().pop_front(); - delete front; + ysDelete(front); } Send(out.get_buffer(), out.get_size()); } @@ -1346,18 +1352,19 @@ SSL_SESSION::~SSL_SESSION() } -Sessions Sessions::instance; // simple singleton +Sessions Sessions::instance_; // simple singleton Sessions& GetSessions() { - return Sessions::instance; + return Sessions::instance_; } -sslFactory sslFactory::instance; + +sslFactory sslFactory::instance_; // simple singleton sslFactory& GetSSL_Factory() { - return sslFactory::instance; + return sslFactory::instance_; } @@ -1397,6 +1404,7 @@ struct sess_match { } // local namespace using namespace yassl_int_cpp_local2; + // lookup session by id, return a copy if space provided SSL_SESSION* Sessions::lookup(const opaque* id, SSL_SESSION* copy) { @@ -1479,9 +1487,9 @@ SSL_CTX::SSL_CTX(SSL_METHOD* meth) SSL_CTX::~SSL_CTX() { - delete method_; - delete certificate_; - delete privateKey_; + ysDelete(method_); + ysDelete(certificate_); + ysDelete(privateKey_); mySTL::for_each(caList_.begin(), caList_.end(), del_ptr_zero()); } @@ -1687,9 +1695,9 @@ Crypto::Crypto() Crypto::~Crypto() { - delete dh_; - delete cipher_; - delete digest_; + ysDelete(dh_); + ysDelete(cipher_); + ysDelete(digest_); } @@ -1939,7 +1947,7 @@ X509_NAME::X509_NAME(const char* n, size_t sz) X509_NAME::~X509_NAME() { - delete[] name_; + ysArrayDelete(name_); } @@ -1952,7 +1960,7 @@ char* X509_NAME::GetName() X509::X509(const char* i, size_t iSz, const char* s, size_t sSz) : issuer_(i, iSz), subject_(s, sSz) {} - + X509_NAME* X509::GetIssuer() { diff --git a/extra/yassl/taocrypt/include/aes.hpp b/extra/yassl/taocrypt/include/aes.hpp index b2c93eff9fe..b8436d35c5f 100644 --- a/extra/yassl/taocrypt/include/aes.hpp +++ b/extra/yassl/taocrypt/include/aes.hpp @@ -37,11 +37,12 @@ enum { AES_BLOCK_SIZE = 16 }; // AES encryption and decryption, see FIPS-197 -class AES : public Mode_BASE { +class AES : public Mode_BASE { public: enum { BLOCK_SIZE = AES_BLOCK_SIZE }; - AES(CipherDir DIR, Mode MODE) : dir_(DIR), mode_(MODE) {} + AES(CipherDir DIR, Mode MODE) + : Mode_BASE(BLOCK_SIZE), dir_(DIR), mode_(MODE) {} void Process(byte*, const byte*, word32); void SetKey(const byte* iv, word32 sz, CipherDir fake = ENCRYPTION); diff --git a/extra/yassl/taocrypt/include/algebra.hpp b/extra/yassl/taocrypt/include/algebra.hpp index 74f244507f6..a09ac8dce16 100644 --- a/extra/yassl/taocrypt/include/algebra.hpp +++ b/extra/yassl/taocrypt/include/algebra.hpp @@ -24,11 +24,10 @@ #ifndef TAO_CRYPT_ALGEBRA_HPP #define TAO_CRYPT_ALGEBRA_HPP -#include "misc.hpp" +#include "integer.hpp" namespace TaoCrypt { -class Integer; // "const Element&" returned by member functions are references // to internal data members. Since each object may have only @@ -38,11 +37,11 @@ class Integer; // But this should be fine: // abcd = group.Add(a, group.Add(b, group.Add(c,d)); -//! Abstract Group -template class TAOCRYPT_NO_VTABLE AbstractGroup +// Abstract Group +class TAOCRYPT_NO_VTABLE AbstractGroup : public virtual_base { public: - typedef T Element; + typedef Integer Element; virtual ~AbstractGroup() {} @@ -65,14 +64,13 @@ public: const Integer *exponents, unsigned int exponentsCount) const; }; -//! Abstract Ring -template class TAOCRYPT_NO_VTABLE AbstractRing - : public AbstractGroup +// Abstract Ring +class TAOCRYPT_NO_VTABLE AbstractRing : public AbstractGroup { public: - typedef T Element; + typedef Integer Element; - AbstractRing() {m_mg.m_pRing = this;} + AbstractRing() : AbstractGroup() {m_mg.m_pRing = this;} AbstractRing(const AbstractRing &source) {m_mg.m_pRing = this;} AbstractRing& operator=(const AbstractRing &source) {return *this;} @@ -91,14 +89,14 @@ public: virtual void SimultaneousExponentiate(Element *results, const Element&, const Integer *exponents, unsigned int exponentsCount) const; - virtual const AbstractGroup& MultiplicativeGroup() const + virtual const AbstractGroup& MultiplicativeGroup() const {return m_mg;} private: - class MultiplicativeGroupT : public AbstractGroup + class MultiplicativeGroupT : public AbstractGroup { public: - const AbstractRing& GetRing() const + const AbstractRing& GetRing() const {return *m_pRing;} bool Equal(const Element &a, const Element &b) const @@ -137,44 +135,19 @@ private: {GetRing().SimultaneousExponentiate(results, base, exponents, exponentsCount);} - const AbstractRing *m_pRing; + const AbstractRing* m_pRing; }; MultiplicativeGroupT m_mg; }; -// ******************************************************** -//! Base and Exponent -template -struct BaseAndExponent +// Abstract Euclidean Domain +class TAOCRYPT_NO_VTABLE AbstractEuclideanDomain + : public AbstractRing { public: - BaseAndExponent() {} - BaseAndExponent(const T &base, const E &exponent) : base(base), - exponent(exponent) {} - bool operator<(const BaseAndExponent &rhs) const - {return exponent < rhs.exponent;} - T base; - E exponent; -}; - -// VC60 workaround: incomplete member template support -template - Element GeneralCascadeMultiplication(const AbstractGroup &group, - Iterator begin, Iterator end); -template - Element GeneralCascadeExponentiation(const AbstractRing &ring, - Iterator begin, Iterator end); - -// ******************************************************** - -//! Abstract Euclidean Domain -template class TAOCRYPT_NO_VTABLE AbstractEuclideanDomain - : public AbstractRing -{ -public: - typedef T Element; + typedef Integer Element; virtual void DivisionAlgorithm(Element &r, Element &q, const Element &a, const Element &d) const =0; @@ -186,13 +159,12 @@ protected: mutable Element result; }; -// ******************************************************** -//! EuclideanDomainOf -template class EuclideanDomainOf : public AbstractEuclideanDomain +// EuclideanDomainOf +class EuclideanDomainOf : public AbstractEuclideanDomain { public: - typedef T Element; + typedef Integer Element; EuclideanDomainOf() {} @@ -249,68 +221,8 @@ private: mutable Element result; }; -//! Quotient Ring -template class QuotientRing : public AbstractRing -{ -public: - typedef T EuclideanDomain; - typedef typename T::Element Element; - - QuotientRing(const EuclideanDomain &domain, const Element &modulus) - : m_domain(domain), m_modulus(modulus) {} - - const EuclideanDomain & GetDomain() const - {return m_domain;} - - const Element& GetModulus() const - {return m_modulus;} - - bool Equal(const Element &a, const Element &b) const - {return m_domain.Equal(m_domain.Mod(m_domain.Subtract(a, b), - m_modulus), m_domain.Identity());} - - const Element& Identity() const - {return m_domain.Identity();} - - const Element& Add(const Element &a, const Element &b) const - {return m_domain.Add(a, b);} - - Element& Accumulate(Element &a, const Element &b) const - {return m_domain.Accumulate(a, b);} - - const Element& Inverse(const Element &a) const - {return m_domain.Inverse(a);} - - const Element& Subtract(const Element &a, const Element &b) const - {return m_domain.Subtract(a, b);} - - Element& Reduce(Element &a, const Element &b) const - {return m_domain.Reduce(a, b);} - - const Element& Double(const Element &a) const - {return m_domain.Double(a);} - - bool IsUnit(const Element &a) const - {return m_domain.IsUnit(m_domain.Gcd(a, m_modulus));} - - const Element& MultiplicativeIdentity() const - {return m_domain.MultiplicativeIdentity();} - - const Element& Multiply(const Element &a, const Element &b) const - {return m_domain.Mod(m_domain.Multiply(a, b), m_modulus);} - - const Element& Square(const Element &a) const - {return m_domain.Mod(m_domain.Square(a), m_modulus);} - - const Element& MultiplicativeInverse(const Element &a) const; - -protected: - EuclideanDomain m_domain; - Element m_modulus; -}; } // namespace - #endif // TAO_CRYPT_ALGEBRA_HPP diff --git a/extra/yassl/taocrypt/include/asn.hpp b/extra/yassl/taocrypt/include/asn.hpp index 974bbf4c86f..14fcf22d843 100644 --- a/extra/yassl/taocrypt/include/asn.hpp +++ b/extra/yassl/taocrypt/include/asn.hpp @@ -106,7 +106,7 @@ class DH; // General BER decoding -class BER_Decoder { +class BER_Decoder : public virtual_base { protected: Source& source_; public: @@ -184,7 +184,7 @@ class PublicKey { word32 sz_; public: explicit PublicKey(const byte* k = 0, word32 s = 0); - ~PublicKey() { delete[] key_; } + ~PublicKey() { tcArrayDelete(key_); } const byte* GetKey() const { return key_; } word32 size() const { return sz_; } @@ -287,7 +287,7 @@ word32 DecodeDSA_Signature(byte* decoded, const byte* encoded, word32 sz); // General DER encoding -class DER_Encoder { +class DER_Encoder : public virtual_base { public: DER_Encoder() {} virtual ~DER_Encoder() {} diff --git a/extra/yassl/taocrypt/include/block.hpp b/extra/yassl/taocrypt/include/block.hpp index f490fb0b6e7..c5eec55d37e 100644 --- a/extra/yassl/taocrypt/include/block.hpp +++ b/extra/yassl/taocrypt/include/block.hpp @@ -34,10 +34,6 @@ #include // ptrdiff_t -#if defined(_MSC_VER) && defined(_CRTAPI1) -#define TAOCRYPT_MSVCRT6 -#endif - namespace TaoCrypt { @@ -47,13 +43,13 @@ template class AllocatorBase { public: - typedef T value_type; - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef T* pointer; - typedef const T* const_pointer; - typedef T& reference; - typedef const T& const_reference; + typedef T value_type; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef T* pointer; + typedef const T* const_pointer; + typedef T& reference; + typedef const T& const_reference; pointer address(reference r) const {return (&r);} const_pointer address(const_reference r) const {return (&r); } @@ -110,7 +106,7 @@ public: void deallocate(void* p, size_type n) { memset(p, 0, n * sizeof(T)); - delete [] (T*)p; + tcArrayDelete((T*)p); } pointer reallocate(T* p, size_type oldSize, size_type newSize, diff --git a/extra/yassl/taocrypt/include/des.hpp b/extra/yassl/taocrypt/include/des.hpp index e8100b4e198..127b8ddc6d5 100644 --- a/extra/yassl/taocrypt/include/des.hpp +++ b/extra/yassl/taocrypt/include/des.hpp @@ -36,12 +36,13 @@ namespace TaoCrypt { enum { DES_BLOCK_SIZE = 8 }; // Base for all DES types -class DES_BASE : public Mode_BASE { +class DES_BASE : public Mode_BASE { public: enum { BLOCK_SIZE = DES_BLOCK_SIZE, KEY_SIZE = 32, BOXES = 8, BOX_SIZE = 64 }; - DES_BASE(CipherDir DIR, Mode MODE) : dir_(DIR), mode_(MODE) {} + DES_BASE(CipherDir DIR, Mode MODE) + : Mode_BASE(BLOCK_SIZE), dir_(DIR), mode_(MODE) {} void Process(byte*, const byte*, word32); protected: diff --git a/extra/yassl/taocrypt/include/error.hpp b/extra/yassl/taocrypt/include/error.hpp index 6170d0349b5..55ab39313f5 100644 --- a/extra/yassl/taocrypt/include/error.hpp +++ b/extra/yassl/taocrypt/include/error.hpp @@ -65,7 +65,8 @@ UNKOWN_HASH_E = 1034, // "unknown hash OID" DSA_SZ_E = 1035, // "bad DSA r or s size" BEFORE_DATE_E = 1036, // "before date in the future" AFTER_DATE_E = 1037, // "after date in the past" -SIG_CONFIRM_E = 1038 // "bad signature confirmation" +SIG_CONFIRM_E = 1038, // "bad self signature confirmation" +SIG_OTHER_E = 1039 // "bad other signature confirmation" }; diff --git a/extra/yassl/taocrypt/include/hash.hpp b/extra/yassl/taocrypt/include/hash.hpp index 1703de23713..257aa1be419 100644 --- a/extra/yassl/taocrypt/include/hash.hpp +++ b/extra/yassl/taocrypt/include/hash.hpp @@ -32,7 +32,7 @@ namespace TaoCrypt { // HASH -class HASH { +class HASH : public virtual_base { public: virtual ~HASH() {} @@ -51,8 +51,8 @@ class HASHwithTransform : public HASH { public: HASHwithTransform(word32 digSz, word32 buffSz) : digest_(new (tc) word32[digSz]), buffer_(new (tc) byte[buffSz]) {} - virtual ~HASHwithTransform() { delete[] buffer_; delete[] digest_; } - + virtual ~HASHwithTransform() { tcArrayDelete(buffer_); + tcArrayDelete(digest_); } virtual ByteOrder getByteOrder() const = 0; virtual word32 getPadSize() const = 0; diff --git a/extra/yassl/taocrypt/include/integer.hpp b/extra/yassl/taocrypt/include/integer.hpp index 3713d09d9f9..f9ef267ce4c 100644 --- a/extra/yassl/taocrypt/include/integer.hpp +++ b/extra/yassl/taocrypt/include/integer.hpp @@ -29,8 +29,8 @@ #include "block.hpp" #include "random.hpp" #include "file.hpp" -#include #include "algorithm.hpp" // mySTL::swap +#include #ifdef TAOCRYPT_X86ASM_AVAILABLE @@ -128,9 +128,6 @@ public: Integer(signed long value); Integer(Sign s, word highWord, word lowWord); - explicit Integer(const char* str); - explicit Integer(const wchar_t* str); - // BER Decode Source explicit Integer(Source&); @@ -139,9 +136,8 @@ public: ~Integer() {} - static const Integer &Zero(); - static const Integer &One(); - static const Integer &Two(); + static const Integer& Zero(); + static const Integer& One(); Integer& Ref() { return *this; } @@ -254,15 +250,10 @@ public: private: friend class ModularArithmetic; friend class MontgomeryRepresentation; - friend class HalfMontgomeryRepresentation; Integer(word value, unsigned int length); - - static const Integer zero; - static const Integer one; - static const Integer two; - int PositiveCompare(const Integer& t) const; + friend void PositiveAdd(Integer& sum, const Integer& a, const Integer& b); friend void PositiveSubtract(Integer& diff, const Integer& a, const Integer& b); @@ -272,6 +263,9 @@ private: Integer& dividend, const Integer& divisor); AlignedWordBlock reg_; Sign sign_; + + static const Integer zero_; + static const Integer one_; }; inline bool operator==(const Integer& a, const Integer& b) @@ -308,6 +302,7 @@ inline void swap(Integer &a, Integer &b) Integer CRT(const Integer& xp, const Integer& p, const Integer& xq, const Integer& q, const Integer& u); + inline Integer ModularExponentiation(const Integer& a, const Integer& e, const Integer& m) { diff --git a/extra/yassl/taocrypt/include/misc.hpp b/extra/yassl/taocrypt/include/misc.hpp index b5b0a4575fc..812cdd93879 100644 --- a/extra/yassl/taocrypt/include/misc.hpp +++ b/extra/yassl/taocrypt/include/misc.hpp @@ -27,9 +27,18 @@ #include #include #include +#include "types.hpp" +#include "type_traits.hpp" + +/* +namespace GCC_ABI { + extern "C" int __cxa_pure_virtual(); +} */ namespace TaoCrypt { +// using GCC_ABI::__cxa_pure_virtual; + // library allocation struct new_t {}; // TaoCrypt New type extern new_t tc; // pass in parameter @@ -39,74 +48,38 @@ extern new_t tc; // pass in parameter void* operator new (size_t, TaoCrypt::new_t); void* operator new[](size_t, TaoCrypt::new_t); +void operator delete (void*, TaoCrypt::new_t); +void operator delete[](void*, TaoCrypt::new_t); + namespace TaoCrypt { +template +void tcDelete(T* ptr) +{ + if (ptr) ptr->~T(); + ::operator delete(ptr, TaoCrypt::tc); +} -// define this if running on a big-endian CPU -#if !defined(LITTLE_ENDIAN_ORDER) && (defined(__BIG_ENDIAN__) || \ - defined(__sparc) || defined(__sparc__) || defined(__hppa__) || \ - defined(__mips__) || (defined(__MWERKS__) && !defined(__INTEL__))) - #define BIG_ENDIAN_ORDER -#endif +template +void tcArrayDelete(T* ptr) +{ + // can't do array placement destruction since not tracking size in + // allocation, only allow builtins to use array placement since they + // don't need destructors called + typedef char builtin[IsFundamentalType::Yes ? 1 : -1]; + (void)sizeof(builtin); -#ifndef BIG_ENDIAN_ORDER - #define LITTLE_ENDIAN_ORDER -#endif + ::operator delete[](ptr, TaoCrypt::tc); +} -typedef unsigned char byte; -typedef unsigned short word16; -typedef unsigned int word32; - -#if defined(__GNUC__) || defined(__MWERKS__) || defined(_LONGLONG_TYPE) - #define WORD64_AVAILABLE - typedef unsigned long long word64; - #define W64LIT(x) x##LL -#elif defined(_MSC_VER) || defined(__BCPLUSPLUS__) - #define WORD64_AVAILABLE - typedef unsigned __int64 word64; - #define W64LIT(x) x##ui64 -#elif defined(__DECCXX) - #define WORD64_AVAILABLE - typedef unsigned long word64; -#endif - -// define largest word type -#ifdef WORD64_AVAILABLE - typedef word64 lword; -#else - typedef word32 lword; -#endif - -// FIXME the !defined(__sun) is a temporarely solution until asm for -// __x86_64__ and Solaris is written -#if defined(__alpha__) || defined(__ia64__) || defined(_ARCH_PPC64) || \ - defined(__mips64) || (defined(__x86_64__) && !defined(__sun)) -// These platforms have 64-bit CPU registers. Unfortunately most C++ compilers -// don't allow any way to access the 64-bit by 64-bit multiply instruction -// without using assembly, so in order to use word64 as word, the assembly -// instruction must be defined in Dword::Multiply(). - typedef word32 hword; - typedef word64 word; -#else - #define TAOCRYPT_NATIVE_DWORD_AVAILABLE - #ifdef WORD64_AVAILABLE - #define TAOCRYPT_SLOW_WORD64 - // define this if your CPU is not64-bit to use alternative code - // that avoids word64 - typedef word16 hword; - typedef word32 word; - typedef word64 dword; - #else - typedef byte hword; - typedef word16 word; - typedef word32 dword; - #endif -#endif - -const word32 WORD_SIZE = sizeof(word); -const word32 WORD_BITS = WORD_SIZE * 8; +// to resolve compiler generated operator delete on base classes with +// virtual destructors, make sure doesn't get called +class virtual_base { +public: + static void operator delete(void*) { assert(0); } +}; #if defined(_MSC_VER) || defined(__BCPLUSPLUS__) diff --git a/extra/yassl/taocrypt/include/modarith.hpp b/extra/yassl/taocrypt/include/modarith.hpp index 88a2cc95c7c..66a841b05c3 100644 --- a/extra/yassl/taocrypt/include/modarith.hpp +++ b/extra/yassl/taocrypt/include/modarith.hpp @@ -27,14 +27,13 @@ #define TAO_CRYPT_MODARITH_HPP #include "misc.hpp" -#include "integer.hpp" #include "algebra.hpp" namespace TaoCrypt { -//! ModularArithmetic -class ModularArithmetic : public AbstractRing +// ModularArithmetic +class ModularArithmetic : public AbstractRing { public: @@ -45,7 +44,7 @@ public: : modulus(modulus), result((word)0, modulus.reg_.size()) {} ModularArithmetic(const ModularArithmetic &ma) - : AbstractRing(), + : AbstractRing(), modulus(ma.modulus), result((word)0, modulus.reg_.size()) {} const Integer& GetModulus() const {return modulus;} @@ -149,12 +148,12 @@ public: Integer CascadeExponentiate(const Integer &x, const Integer &e1, const Integer &y, const Integer &e2) const - {return AbstractRing::CascadeExponentiate(x, e1, y, e2);} + {return AbstractRing::CascadeExponentiate(x, e1, y, e2);} void SimultaneousExponentiate(Element *results, const Element &base, const Integer *exponents, unsigned int exponentsCount) const - {AbstractRing::SimultaneousExponentiate(results, base, - exponents, exponentsCount);} + {AbstractRing::SimultaneousExponentiate(results, base, + exponents, exponentsCount);} private: Integer u; diff --git a/extra/yassl/taocrypt/include/modes.hpp b/extra/yassl/taocrypt/include/modes.hpp index 2a21ad46b76..585231c9b9e 100644 --- a/extra/yassl/taocrypt/include/modes.hpp +++ b/extra/yassl/taocrypt/include/modes.hpp @@ -56,10 +56,11 @@ private: // Mode Base for block ciphers, static size -template -class Mode_BASE { +class Mode_BASE : public virtual_base { public: - Mode_BASE() {} + enum { MaxBlockSz = 16 }; + + explicit Mode_BASE(int sz) : blockSz_(sz) { assert(sz <= MaxBlockSz); } virtual ~Mode_BASE() {} virtual void ProcessAndXorBlock(const byte*, const byte*, byte*) const = 0; @@ -68,10 +69,11 @@ public: void CBC_Encrypt(byte*, const byte*, word32); void CBC_Decrypt(byte*, const byte*, word32); - void SetIV(const byte* iv) { memcpy(reg_, iv, BLOCK_SIZE); } + void SetIV(const byte* iv) { memcpy(reg_, iv, blockSz_); } private: - byte reg_[BLOCK_SIZE]; - byte tmp_[BLOCK_SIZE]; + byte reg_[MaxBlockSz]; + byte tmp_[MaxBlockSz]; + int blockSz_; Mode_BASE(const Mode_BASE&); // hide copy Mode_BASE& operator=(const Mode_BASE&); // and assign @@ -79,51 +81,48 @@ private: // ECB Process blocks -template -void Mode_BASE::ECB_Process(byte* out, const byte* in, word32 sz) +inline void Mode_BASE::ECB_Process(byte* out, const byte* in, word32 sz) { - word32 blocks = sz / BLOCK_SIZE; + word32 blocks = sz / blockSz_; while (blocks--) { ProcessAndXorBlock(in, 0, out); - out += BLOCK_SIZE; - in += BLOCK_SIZE; + out += blockSz_; + in += blockSz_; } } // CBC Encrypt -template -void Mode_BASE::CBC_Encrypt(byte* out, const byte* in, word32 sz) +inline void Mode_BASE::CBC_Encrypt(byte* out, const byte* in, word32 sz) { - word32 blocks = sz / BLOCK_SIZE; + word32 blocks = sz / blockSz_; while (blocks--) { - xorbuf(reg_, in, BLOCK_SIZE); + xorbuf(reg_, in, blockSz_); ProcessAndXorBlock(reg_, 0, reg_); - memcpy(out, reg_, BLOCK_SIZE); - out += BLOCK_SIZE; - in += BLOCK_SIZE; + memcpy(out, reg_, blockSz_); + out += blockSz_; + in += blockSz_; } } // CBC Decrypt -template -void Mode_BASE::CBC_Decrypt(byte* out, const byte* in, word32 sz) +inline void Mode_BASE::CBC_Decrypt(byte* out, const byte* in, word32 sz) { - word32 blocks = sz / BLOCK_SIZE; - byte hold[BLOCK_SIZE]; + word32 blocks = sz / blockSz_; + byte hold[MaxBlockSz]; while (blocks--) { - memcpy(tmp_, in, BLOCK_SIZE); + memcpy(tmp_, in, blockSz_); ProcessAndXorBlock(tmp_, 0, out); - xorbuf(out, reg_, BLOCK_SIZE); - memcpy(hold, reg_, BLOCK_SIZE); // swap reg_ and tmp_ - memcpy(reg_, tmp_, BLOCK_SIZE); - memcpy(tmp_, hold, BLOCK_SIZE); - out += BLOCK_SIZE; - in += BLOCK_SIZE; + xorbuf(out, reg_, blockSz_); + memcpy(hold, reg_, blockSz_); // swap reg_ and tmp_ + memcpy(reg_, tmp_, blockSz_); + memcpy(tmp_, hold, blockSz_); + out += blockSz_; + in += blockSz_; } } diff --git a/extra/yassl/taocrypt/include/runtime.hpp b/extra/yassl/taocrypt/include/runtime.hpp index 43f1b72fd51..01106b6f960 100644 --- a/extra/yassl/taocrypt/include/runtime.hpp +++ b/extra/yassl/taocrypt/include/runtime.hpp @@ -31,30 +31,6 @@ #if __GNUC__ > 2 -#include - - -static void* operator new (size_t sz) -{ - return malloc (sz ? sz : 1); -} - -static void* operator new[](size_t sz) -{ - return malloc (sz ? sz : 1); -} - -static void operator delete (void* ptr) -{ - if (ptr) free(ptr); -} - -static void operator delete[] (void* ptr) -{ - if (ptr) free(ptr); -} - - extern "C" { #include diff --git a/extra/yassl/taocrypt/include/type_traits.hpp b/extra/yassl/taocrypt/include/type_traits.hpp new file mode 100644 index 00000000000..caf71f90e11 --- /dev/null +++ b/extra/yassl/taocrypt/include/type_traits.hpp @@ -0,0 +1,80 @@ +/* type_traits.hpp + * + * Copyright (C) 2003 Sawtooth Consulting Ltd. + * + * This file is part of yaSSL. + * + * yaSSL 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. + * + * yaSSL 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 + */ + +/* type_traits defines fundamental types + * see discussion in C++ Templates, $19.1 +*/ + + +#ifndef TAO_CRYPT_TYPE_TRAITS_HPP +#define TAO_CRYPT_TYPE_TRAITS_HPP + +#include "types.hpp" + +namespace TaoCrypt { + + +// primary template: in general T is not a fundamental type + +template +class IsFundamentalType { + public: + enum { Yes = 0, No = 1 }; +}; + + +// macro to specialize for fundamental types +#define MK_FUNDAMENTAL_TYPE(T) \ + template<> class IsFundamentalType { \ + public: \ + enum { Yes = 1, No = 0 }; \ + }; + + +MK_FUNDAMENTAL_TYPE(void) + +MK_FUNDAMENTAL_TYPE(bool) +MK_FUNDAMENTAL_TYPE( char) +MK_FUNDAMENTAL_TYPE(signed char) +MK_FUNDAMENTAL_TYPE(unsigned char) + +MK_FUNDAMENTAL_TYPE(signed short) +MK_FUNDAMENTAL_TYPE(unsigned short) +MK_FUNDAMENTAL_TYPE(signed int) +MK_FUNDAMENTAL_TYPE(unsigned int) +MK_FUNDAMENTAL_TYPE(signed long) +MK_FUNDAMENTAL_TYPE(unsigned long) + +MK_FUNDAMENTAL_TYPE(float) +MK_FUNDAMENTAL_TYPE( double) +MK_FUNDAMENTAL_TYPE(long double) + +#ifdef WORD64_AVAILABLE + MK_FUNDAMENTAL_TYPE(word64) +#endif + + +#undef MK_FUNDAMENTAL_TYPE + + +} // namespace + +#endif // TAO_CRYPT_TYPE_TRAITS_HPP diff --git a/extra/yassl/taocrypt/include/types.hpp b/extra/yassl/taocrypt/include/types.hpp new file mode 100644 index 00000000000..0d57022a2d0 --- /dev/null +++ b/extra/yassl/taocrypt/include/types.hpp @@ -0,0 +1,99 @@ +/* types.hpp + * + * Copyright (C) 2003 Sawtooth Consulting Ltd. + * + * This file is part of yaSSL. + * + * yaSSL 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. + * + * yaSSL 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 + */ + +/* based on Wei Dai's misc.h from CryptoPP, basic crypt types */ + + +#ifndef TAO_CRYPT_TYPES_HPP +#define TAO_CRYPT_TYPES_HPP + +namespace TaoCrypt { + +// define this if running on a big-endian CPU +#if !defined(LITTLE_ENDIAN_ORDER) && (defined(__BIG_ENDIAN__) || \ + defined(__sparc) || defined(__sparc__) || defined(__hppa__) || \ + defined(__mips__) || (defined(__MWERKS__) && !defined(__INTEL__))) + #define BIG_ENDIAN_ORDER +#endif + +#ifndef BIG_ENDIAN_ORDER + #define LITTLE_ENDIAN_ORDER +#endif + + +typedef unsigned char byte; +typedef unsigned short word16; +typedef unsigned int word32; + +#if defined(__GNUC__) || defined(__MWERKS__) || defined(_LONGLONG_TYPE) + #define WORD64_AVAILABLE + typedef unsigned long long word64; + #define W64LIT(x) x##LL +#elif defined(_MSC_VER) || defined(__BCPLUSPLUS__) + #define WORD64_AVAILABLE + typedef unsigned __int64 word64; + #define W64LIT(x) x##ui64 +#elif defined(__DECCXX) + #define WORD64_AVAILABLE + typedef unsigned long word64; +#endif + +// define largest word type +#ifdef WORD64_AVAILABLE + typedef word64 lword; +#else + typedef word32 lword; +#endif + + +// TODO: FIXME, add asm multiply for x86_64 on Solaris and remove !__sun + +#if defined(__alpha__) || defined(__ia64__) || defined(_ARCH_PPC64) || \ + defined(__mips64) || (defined(__x86_64__) && !defined(__sun)) +// These platforms have 64-bit CPU registers. Unfortunately most C++ compilers +// don't allow any way to access the 64-bit by 64-bit multiply instruction +// without using assembly, so in order to use word64 as word, the assembly +// instruction must be defined in Dword::Multiply(). + typedef word32 hword; + typedef word64 word; +#else + #define TAOCRYPT_NATIVE_DWORD_AVAILABLE + #ifdef WORD64_AVAILABLE + #define TAOCRYPT_SLOW_WORD64 + // define this if your CPU is not64-bit to use alternative code + // that avoids word64 + typedef word16 hword; + typedef word32 word; + typedef word64 dword; + #else + typedef byte hword; + typedef word16 word; + typedef word32 dword; + #endif +#endif + +const word32 WORD_SIZE = sizeof(word); +const word32 WORD_BITS = WORD_SIZE * 8; + + +} // namespace + +#endif // TAO_CRYPT_TYPES_HPP diff --git a/extra/yassl/taocrypt/src/Makefile.am b/extra/yassl/taocrypt/src/Makefile.am index b00e6081c23..4005be94fb2 100644 --- a/extra/yassl/taocrypt/src/Makefile.am +++ b/extra/yassl/taocrypt/src/Makefile.am @@ -3,5 +3,6 @@ INCLUDES = -I../include -I../../mySTL noinst_LIBRARIES = libtaocrypt.a libtaocrypt_a_SOURCES = aes.cpp aestables.cpp algebra.cpp arc4.cpp asn.cpp \ coding.cpp dh.cpp des.cpp dsa.cpp file.cpp hash.cpp integer.cpp \ - md2.cpp md5.cpp misc.cpp random.cpp ripemd.cpp rsa.cpp sha.cpp + md2.cpp md5.cpp misc.cpp random.cpp ripemd.cpp rsa.cpp sha.cpp \ + template_instnt.cpp EXTRA_DIST = ../include/*.hpp diff --git a/extra/yassl/taocrypt/src/aestables.cpp b/extra/yassl/taocrypt/src/aestables.cpp index 7ba25bc9ffb..5a125dfd44d 100644 --- a/extra/yassl/taocrypt/src/aestables.cpp +++ b/extra/yassl/taocrypt/src/aestables.cpp @@ -21,7 +21,6 @@ /* based on Wei Dai's aestables.cpp from CryptoPP */ -#include "runtime.hpp" #include "aes.hpp" diff --git a/extra/yassl/taocrypt/src/algebra.cpp b/extra/yassl/taocrypt/src/algebra.cpp index 1924be9b618..7608e78b0ed 100644 --- a/extra/yassl/taocrypt/src/algebra.cpp +++ b/extra/yassl/taocrypt/src/algebra.cpp @@ -23,60 +23,58 @@ #include "runtime.hpp" #include "algebra.hpp" -#include "integer.hpp" #include "vector.hpp" // mySTL::vector (simple) namespace TaoCrypt { -template const T& AbstractGroup::Double(const Element &a) const + +const Integer& AbstractGroup::Double(const Element &a) const { return Add(a, a); } -template const T& AbstractGroup::Subtract(const Element &a, - const Element &b) const +const Integer& AbstractGroup::Subtract(const Element &a, const Element &b) const { // make copy of a in case Inverse() overwrites it Element a1(a); return Add(a1, Inverse(b)); } -template T& AbstractGroup::Accumulate(Element &a, - const Element &b) const +Integer& AbstractGroup::Accumulate(Element &a, const Element &b) const { return a = Add(a, b); } -template T& AbstractGroup::Reduce(Element &a, - const Element &b) const +Integer& AbstractGroup::Reduce(Element &a, const Element &b) const { return a = Subtract(a, b); } -template const T& AbstractRing::Square(const Element &a) const +const Integer& AbstractRing::Square(const Element &a) const { return Multiply(a, a); } -template const T& AbstractRing::Divide(const Element &a, - const Element &b) const + +const Integer& AbstractRing::Divide(const Element &a, const Element &b) const { // make copy of a in case MultiplicativeInverse() overwrites it Element a1(a); return Multiply(a1, MultiplicativeInverse(b)); } -template const T& AbstractEuclideanDomain::Mod(const Element &a, - const Element &b) const + +const Integer& AbstractEuclideanDomain::Mod(const Element &a, + const Element &b) const { Element q; DivisionAlgorithm(result, q, a, b); return result; } -template const T& AbstractEuclideanDomain::Gcd(const Element &a, - const Element &b) const +const Integer& AbstractEuclideanDomain::Gcd(const Element &a, + const Element &b) const { Element g[3]={b, a}; unsigned int i0=0, i1=1, i2=2; @@ -90,45 +88,17 @@ template const T& AbstractEuclideanDomain::Gcd(const Element &a, return result = g[i0]; } -template const typename - QuotientRing::Element& QuotientRing::MultiplicativeInverse( - const Element &a) const -{ - Element g[3]={m_modulus, a}; -#ifdef __BCPLUSPLUS__ - // BC++50 workaround - Element v[3]; - v[0]=m_domain.Identity(); - v[1]=m_domain.MultiplicativeIdentity(); -#else - Element v[3]={m_domain.Identity(), m_domain.MultiplicativeIdentity()}; -#endif - Element y; - unsigned int i0=0, i1=1, i2=2; - while (!Equal(g[i1], Identity())) - { - // y = g[i0] / g[i1]; - // g[i2] = g[i0] % g[i1]; - m_domain.DivisionAlgorithm(g[i2], y, g[i0], g[i1]); - // v[i2] = v[i0] - (v[i1] * y); - v[i2] = m_domain.Subtract(v[i0], m_domain.Multiply(v[i1], y)); - unsigned int t = i0; i0 = i1; i1 = i2; i2 = t; - } - - return m_domain.IsUnit(g[i0]) ? m_domain.Divide(v[i0], g[i0]) : - m_domain.Identity(); -} - -template T AbstractGroup::ScalarMultiply(const Element &base, - const Integer &exponent) const +Integer AbstractGroup::ScalarMultiply(const Element &base, + const Integer &exponent) const { Element result; SimultaneousMultiply(&result, base, &exponent, 1); return result; } -template T AbstractGroup::CascadeScalarMultiply(const Element &x, + +Integer AbstractGroup::CascadeScalarMultiply(const Element &x, const Integer &e1, const Element &y, const Integer &e2) const { const unsigned expLen = max(e1.BitCount(), e2.BitCount()); @@ -258,8 +228,8 @@ struct WindowSlider bool fastNegate, negateNext, firstTime, finished; }; -template -void AbstractGroup::SimultaneousMultiply(T *results, const T &base, + +void AbstractGroup::SimultaneousMultiply(Integer *results, const Integer &base, const Integer *expBegin, unsigned int expCount) const { mySTL::vector > buckets(expCount); @@ -321,34 +291,37 @@ void AbstractGroup::SimultaneousMultiply(T *results, const T &base, } } -template T AbstractRing::Exponentiate(const Element &base, - const Integer &exponent) const +Integer AbstractRing::Exponentiate(const Element &base, + const Integer &exponent) const { Element result; SimultaneousExponentiate(&result, base, &exponent, 1); return result; } -template T AbstractRing::CascadeExponentiate(const Element &x, + +Integer AbstractRing::CascadeExponentiate(const Element &x, const Integer &e1, const Element &y, const Integer &e2) const { - return MultiplicativeGroup().AbstractGroup::CascadeScalarMultiply( + return MultiplicativeGroup().AbstractGroup::CascadeScalarMultiply( x, e1, y, e2); } -template Element GeneralCascadeExponentiation( - const AbstractRing &ring, Iterator begin, Iterator end) -{ - return GeneralCascadeMultiplication(ring.MultiplicativeGroup(), - begin, end); -} -template -void AbstractRing::SimultaneousExponentiate(T *results, const T &base, +void AbstractRing::SimultaneousExponentiate(Integer *results, + const Integer &base, const Integer *exponents, unsigned int expCount) const { - MultiplicativeGroup().AbstractGroup::SimultaneousMultiply(results, base, + MultiplicativeGroup().AbstractGroup::SimultaneousMultiply(results, base, exponents, expCount); } + } // namespace + +#ifdef __GNUC__ +namespace mySTL { +template TaoCrypt::WindowSlider* uninit_copy(TaoCrypt::WindowSlider*, TaoCrypt::WindowSlider*, TaoCrypt::WindowSlider*); +template void destroy(TaoCrypt::WindowSlider*, TaoCrypt::WindowSlider*); +} +#endif diff --git a/extra/yassl/taocrypt/src/arc4.cpp b/extra/yassl/taocrypt/src/arc4.cpp index 1e521b48f0c..bbd77cd822c 100644 --- a/extra/yassl/taocrypt/src/arc4.cpp +++ b/extra/yassl/taocrypt/src/arc4.cpp @@ -21,7 +21,6 @@ /* based on Wei Dai's arc4.cpp from CryptoPP */ -#include "runtime.hpp" #include "arc4.hpp" diff --git a/extra/yassl/taocrypt/src/asn.cpp b/extra/yassl/taocrypt/src/asn.cpp index d0d22a6c61d..720fe7cd532 100644 --- a/extra/yassl/taocrypt/src/asn.cpp +++ b/extra/yassl/taocrypt/src/asn.cpp @@ -199,14 +199,14 @@ void PublicKey::SetKey(const byte* k) void PublicKey::AddToEnd(const byte* data, word32 len) { - mySTL::auto_ptr tmp(new (tc) byte[sz_ + len]); + mySTL::auto_ptr tmp(new (tc) byte[sz_ + len], tcArrayDelete); memcpy(tmp.get(), key_, sz_); memcpy(tmp.get() + sz_, data, len); byte* del = 0; mySTL::swap(del, key_); - delete[] del; + tcArrayDelete(del); key_ = tmp.release(); sz_ += len; @@ -228,7 +228,7 @@ Signer::Signer(const byte* k, word32 kSz, const char* n, const byte* h) Signer::~Signer() { - delete[] name_; + tcArrayDelete(name_); } @@ -433,9 +433,9 @@ CertDecoder::CertDecoder(Source& s, bool decode, SignerList* signers) CertDecoder::~CertDecoder() { - delete[] subject_; - delete[] issuer_; - delete[] signature_; + tcArrayDelete(subject_); + tcArrayDelete(issuer_); + tcArrayDelete(signature_); } @@ -480,7 +480,7 @@ void CertDecoder::Decode(SignerList* signers) } else if (!ValidateSignature(signers)) - source_.SetError(SIG_CONFIRM_E); + source_.SetError(SIG_OTHER_E); } @@ -807,7 +807,7 @@ bool CertDecoder::ValidateSignature(SignerList* signers) bool CertDecoder::ConfirmSignature(Source& pub) { HashType ht; - mySTL::auto_ptr hasher; + mySTL::auto_ptr hasher(tcDelete); if (signatureOID_ == MD5wRSA) { hasher.reset(new (tc) MD5); diff --git a/extra/yassl/taocrypt/src/coding.cpp b/extra/yassl/taocrypt/src/coding.cpp index 944a47c288e..6514ed4d46d 100644 --- a/extra/yassl/taocrypt/src/coding.cpp +++ b/extra/yassl/taocrypt/src/coding.cpp @@ -22,7 +22,6 @@ /* coding.cpp implements hex and base64 encoding/decoing */ -#include "runtime.hpp" #include "coding.hpp" #include "file.hpp" diff --git a/extra/yassl/taocrypt/src/dh.cpp b/extra/yassl/taocrypt/src/dh.cpp index af50d471b52..d5f93f6c0f6 100644 --- a/extra/yassl/taocrypt/src/dh.cpp +++ b/extra/yassl/taocrypt/src/dh.cpp @@ -23,10 +23,8 @@ /* dh.cpp implements Diffie-Hellman support */ -#include "runtime.hpp" #include "dh.hpp" #include "asn.hpp" -#include namespace TaoCrypt { diff --git a/extra/yassl/taocrypt/src/dsa.cpp b/extra/yassl/taocrypt/src/dsa.cpp index 4716ebb22df..b89b42ac9d8 100644 --- a/extra/yassl/taocrypt/src/dsa.cpp +++ b/extra/yassl/taocrypt/src/dsa.cpp @@ -20,15 +20,12 @@ */ -#include "runtime.hpp" #include "dsa.hpp" #include "sha.hpp" #include "asn.hpp" #include "modarith.hpp" #include "stdexcept.hpp" -#include "algebra.cpp" // for GCC 3.2 on aix ? - namespace TaoCrypt { diff --git a/extra/yassl/taocrypt/src/file.cpp b/extra/yassl/taocrypt/src/file.cpp index 4d48b9e7bca..75df80608ae 100644 --- a/extra/yassl/taocrypt/src/file.cpp +++ b/extra/yassl/taocrypt/src/file.cpp @@ -22,7 +22,6 @@ /* file.cpp implements File Sources and Sinks */ -#include "runtime.hpp" #include "file.hpp" diff --git a/extra/yassl/taocrypt/src/integer.cpp b/extra/yassl/taocrypt/src/integer.cpp index 9be0a25b363..67f3c963cac 100644 --- a/extra/yassl/taocrypt/src/integer.cpp +++ b/extra/yassl/taocrypt/src/integer.cpp @@ -32,17 +32,15 @@ # pragma warning(disable: 4250 4660 4661 4786 4355) #endif -#include "runtime.hpp" #include "integer.hpp" #include "modarith.hpp" #include "asn.hpp" #include "stdexcept.hpp" -#include "algebra.cpp" #ifdef __DECCXX - #include // for asm multiply overflow + #include // for asm overflow assembly #endif @@ -63,7 +61,7 @@ #pragma message("You do not seem to have the Visual C++ Processor Pack ") #pragma message("installed, so use of SSE2 intrinsics will be disabled.") #elif defined(__GNUC__) && defined(__i386__) -/* #warning You do not have GCC 3.3 or later, or did not specify the -msse2 \ +/* #warning You do not have GCC 3.3 or later, or did not specify the -msse2 \ compiler option. Use of SSE2 intrinsics will be disabled. */ #endif @@ -130,7 +128,7 @@ void AlignedAllocator::deallocate(void* p, size_type n) #endif } else - delete [] (T *)p; + tcArrayDelete((T *)p); } #endif // SSE2 @@ -178,7 +176,7 @@ DWord() {} #elif defined(__DECCXX) r.halfs_.high = asm("umulh %a0, %a1, %v0", a, b); #else - #error unsupported alpha compiler for asm multiply overflow + #error can not implement multiply overflow #endif #elif defined(__ia64__) r.halfs_.low = a*b; @@ -392,6 +390,7 @@ S DivideThreeWordsByTwo(S* A, S B0, S B1, D* dummy_VC6_WorkAround = 0) return Q; } + // do a 4 word by 2 word divide, returns 2 word quotient in Q0 and Q1 template inline D DivideFourWordsByTwo(S *T, const D &Al, const D &Ah, const D &B) @@ -470,66 +469,6 @@ static inline unsigned int RoundupSize(unsigned int n) } -template -static Integer StringToInteger(const T *str) -{ - word radix; - - unsigned int length; - for (length = 0; str[length] != 0; length++) {} - - Integer v; - - if (length == 0) - return v; - - switch (str[length-1]) - { - case 'h': - case 'H': - radix=16; - break; - case 'o': - case 'O': - radix=8; - break; - case 'b': - case 'B': - radix=2; - break; - default: - radix=10; - } - - if (length > 2 && str[0] == '0' && str[1] == 'x') - radix = 16; - - for (unsigned i=0; i= '0' && str[i] <= '9') - digit = str[i] - '0'; - else if (str[i] >= 'A' && str[i] <= 'F') - digit = str[i] - 'A' + 10; - else if (str[i] >= 'a' && str[i] <= 'f') - digit = str[i] - 'a' + 10; - else - digit = radix; - - if (digit < radix) - { - v *= radix; - v += digit; - } - } - - if (str[0] == '-') - v.Negate(); - - return v; -} - static int Compare(const word *A, const word *B, unsigned int N) { while (N--) @@ -2308,85 +2247,6 @@ void RecursiveMultiplyBottom(word *R, word *T, const word *A, const word *B, } } -/* -template -void RecursiveMultiplyTop(word *R, word *T, const word *L, const word *A, - const word *B, unsigned int N, const P *dummy=0) -{ - assert(N>=2 && N%2==0); - - if (N==4) - { - P::Multiply4(T, A, B); - ((dword *)R)[0] = ((dword *)T)[2]; - ((dword *)R)[1] = ((dword *)T)[3]; - } - else if (N==2) - { - P::Multiply2(T, A, B); - ((dword *)R)[0] = ((dword *)T)[1]; - } - else - { - const unsigned int N2 = N/2; - int carry; - - int aComp = Compare(A0, A1, N2); - int bComp = Compare(B0, B1, N2); - - switch (2*aComp + aComp + bComp) - { - case -4: - P::Subtract(R0, A1, A0, N2); - P::Subtract(R1, B0, B1, N2); - RecursiveMultiply

(T0, T2, R0, R1, N2); - P::Subtract(T1, T1, R0, N2); - carry = -1; - break; - case -2: - P::Subtract(R0, A1, A0, N2); - P::Subtract(R1, B0, B1, N2); - RecursiveMultiply

(T0, T2, R0, R1, N2); - carry = 0; - break; - case 2: - P::Subtract(R0, A0, A1, N2); - P::Subtract(R1, B1, B0, N2); - RecursiveMultiply

(T0, T2, R0, R1, N2); - carry = 0; - break; - case 4: - P::Subtract(R0, A1, A0, N2); - P::Subtract(R1, B0, B1, N2); - RecursiveMultiply

(T0, T2, R0, R1, N2); - P::Subtract(T1, T1, R1, N2); - carry = -1; - break; - default: - SetWords(T0, 0, N); - carry = 0; - } - - RecursiveMultiply

(T2, R0, A1, B1, N2); - - // now T[01] holds (A1-A0)*(B0-B1), T[23] holds A1*B1 - - word c2 = P::Subtract(R0, L+N2, L, N2); - c2 += P::Subtract(R0, R0, T0, N2); - word t = (Compare(R0, T2, N2) == -1); - - carry += t; - carry += Increment(R0, N2, c2+t); - carry += P::Add(R0, R0, T1, N2); - carry += P::Add(R0, R0, T3, N2); - assert (carry >= 0 && carry <= 2); - - CopyWords(R1, T3, N2); - Increment(R1, N2, carry); - } -} -*/ - void RecursiveMultiplyTop(word *R, word *T, const word *L, const word *A, const word *B, unsigned int N) @@ -2739,20 +2599,6 @@ Integer::Integer(word value, unsigned int length) } -Integer::Integer(const char *str) - : reg_(2), sign_(POSITIVE) -{ - *this = StringToInteger(str); -} - - -Integer::Integer(const wchar_t *str) - : reg_(2), sign_(POSITIVE) -{ - *this = StringToInteger(str); -} - - Integer::Integer(const byte *encodedInteger, unsigned int byteCount, Signedness s) { @@ -2844,25 +2690,19 @@ unsigned int Integer::Encode(byte* output, unsigned int outputLen, } -const Integer Integer::zero(1,2); +const Integer Integer::zero_; const Integer &Integer::Zero() { - return zero; + return zero_; } -const Integer Integer::one(1,2); + +const Integer Integer::one_(1,2); const Integer &Integer::One() { - return one; -} - -const Integer Integer::two(1,2); - -const Integer &Integer::Two() -{ - return two; + return one_; } @@ -3358,76 +3198,6 @@ Integer Integer::Times(const Integer &b) const #undef R2 #undef R3 -/* -// do a 3 word by 2 word divide, returns quotient and leaves remainder in A -static word SubatomicDivide(word *A, word B0, word B1) -{ - // assert {A[2],A[1]} < {B1,B0}, so quotient can fit in a word - assert(A[2] < B1 || (A[2]==B1 && A[1] < B0)); - - dword p, u; - word Q; - - // estimate the quotient: do a 2 word by 1 word divide - if (B1+1 == 0) - Q = A[2]; - else - Q = word(MAKE_DWORD(A[1], A[2]) / (B1+1)); - - // now subtract Q*B from A - p = (dword) B0*Q; - u = (dword) A[0] - LOW_WORD(p); - A[0] = LOW_WORD(u); - u = (dword) A[1] - HIGH_WORD(p) - (word)(0-HIGH_WORD(u)) - (dword)B1*Q; - A[1] = LOW_WORD(u); - A[2] += HIGH_WORD(u); - - // Q <= actual quotient, so fix it - while (A[2] || A[1] > B1 || (A[1]==B1 && A[0]>=B0)) - { - u = (dword) A[0] - B0; - A[0] = LOW_WORD(u); - u = (dword) A[1] - B1 - (word)(0-HIGH_WORD(u)); - A[1] = LOW_WORD(u); - A[2] += HIGH_WORD(u); - Q++; - assert(Q); // shouldn't overflow - } - - return Q; -} -*/ - - -/* -// do a 4 word by 2 word divide, returns 2 word quotient in Q0 and Q1 -static inline void AtomicDivide(word *Q, const word *A, const word *B) -{ - if (!B[0] && !B[1]) // if divisor is 0, we assume divisor==2**(2*WORD_BITS) - { - Q[0] = A[2]; - Q[1] = A[3]; - } - else - { - word T[4]; - T[0] = A[0]; T[1] = A[1]; T[2] = A[2]; T[3] = A[3]; - Q[1] = SubatomicDivide(T+1, B[0], B[1]); - Q[0] = SubatomicDivide(T, B[0], B[1]); - -#ifndef NDEBUG - // multiply quotient and divisor and add remainder - // make sure it equals dividend - assert(!T[2] && !T[3] && (T[1] < B[1] || (T[1]==B[1] && T[0]().Gcd(a, b); + return EuclideanDomainOf().Gcd(a, b); } Integer Integer::InverseMod(const Integer &m) const @@ -3955,7 +3725,7 @@ Integer ModularArithmetic::CascadeExponentiate(const Integer &x, dr.ConvertIn(y), e2)); } else - return AbstractRing::CascadeExponentiate(x, e1, y, e2); + return AbstractRing::CascadeExponentiate(x, e1, y, e2); } void ModularArithmetic::SimultaneousExponentiate(Integer *results, @@ -3971,7 +3741,7 @@ void ModularArithmetic::SimultaneousExponentiate(Integer *results, results[i] = dr.ConvertOut(results[i]); } else - AbstractRing::SimultaneousExponentiate(results, base, + AbstractRing::SimultaneousExponentiate(results, base, exponents, exponentsCount); } @@ -4170,10 +3940,6 @@ Integer CRT(const Integer &xp, const Integer &p, const Integer &xq, } #ifdef __GNUC__ -template Integer StringToInteger(char const*); -template Integer StringToInteger(wchar_t const*); -template class EuclideanDomainOf; -template class AbstractEuclideanDomain; template unsigned int DivideThreeWordsByTwo(unsigned int*, unsigned int, unsigned int, DWord*); #endif diff --git a/extra/yassl/taocrypt/src/misc.cpp b/extra/yassl/taocrypt/src/misc.cpp index e4573abac3f..1780b3050e9 100644 --- a/extra/yassl/taocrypt/src/misc.cpp +++ b/extra/yassl/taocrypt/src/misc.cpp @@ -22,33 +22,65 @@ /* based on Wei Dai's misc.cpp from CryptoPP */ -#include "runtime.hpp" #include "misc.hpp" #include // for NewHandler void* operator new(size_t sz, TaoCrypt::new_t) { - void* ptr = ::operator new(sz); - + void* ptr = malloc(sz ? sz : 1); if (!ptr) abort(); return ptr; } -void* operator new[](size_t sz, TaoCrypt::new_t tc) +void* operator new[](size_t sz, TaoCrypt::new_t) { -#if defined(_MSC_VER) && (_MSC_VER < 1300) - void* ptr = ::operator new(sz); // no ::operator new[] -#else - void* ptr = ::operator new[](sz); -#endif - + void* ptr = malloc(sz ? sz : 1); if (!ptr) abort(); return ptr; } +void operator delete(void* ptr, TaoCrypt::new_t) +{ + if (ptr) free(ptr); +} + +void operator delete[](void* ptr, TaoCrypt::new_t) +{ + if (ptr) free(ptr); +} + + +/* uncomment to test +// make sure not using globals anywhere by forgetting to use overloaded +void* operator new(size_t sz) +{ + assert(0); + return malloc(sz); +} + +void operator delete(void* ptr) +{ + assert(0); +} + +void* operator new[](size_t sz) +{ + assert(0); + return malloc(sz); +} + +void operator delete[](void* ptr) +{ + assert(0); +} +*/ + +/* namespace GCC_ABI { + extern "C" int __cxa_pure_virtual() { assert(0); return 0; } +} */ namespace TaoCrypt { diff --git a/extra/yassl/taocrypt/src/random.cpp b/extra/yassl/taocrypt/src/random.cpp index 5c9e3b0f02a..921e710540d 100644 --- a/extra/yassl/taocrypt/src/random.cpp +++ b/extra/yassl/taocrypt/src/random.cpp @@ -24,9 +24,7 @@ specific seed, switch to /dev/random for more security but may block */ -#include "runtime.hpp" #include "random.hpp" -#include "stdexcept.hpp" #if defined(WIN32) #define _WIN32_WINNT 0x0400 diff --git a/extra/yassl/taocrypt/src/rsa.cpp b/extra/yassl/taocrypt/src/rsa.cpp index ecb2288f1c2..4027ff7d57d 100644 --- a/extra/yassl/taocrypt/src/rsa.cpp +++ b/extra/yassl/taocrypt/src/rsa.cpp @@ -21,13 +21,11 @@ /* based on Wei Dai's rsa.cpp from CryptoPP */ -#include "runtime.hpp" #include "rsa.hpp" #include "asn.hpp" #include "modarith.hpp" #include "stdexcept.hpp" -#include "algebra.cpp" // for GCC 3.2 on aix ? namespace TaoCrypt { @@ -211,28 +209,5 @@ word32 SSL_Decrypt(const RSA_PublicKey& key, const byte* sig, byte* plain) lengths.PaddedBlockBitLength(), plain); } -#ifdef __GNUC__ -template AllocatorWithCleanup::pointer StdReallocate >(AllocatorWithCleanup&, unsigned char*, AllocatorWithCleanup::size_type, AllocatorWithCleanup::size_type, bool); -template AllocatorWithCleanup::pointer StdReallocate >(AllocatorWithCleanup&, unsigned int*, AllocatorWithCleanup::size_type, AllocatorWithCleanup::size_type, bool); -template class AbstractGroup; -template class AbstractRing; -template class RSA_Decryptor; -template class RSA_Encryptor; -template class RSA_Encryptor; -#endif } // namespace - -#ifdef __GNUC__ -namespace mySTL { -template TaoCrypt::Integer* uninit_copy(TaoCrypt::Integer*, TaoCrypt::Integer*, TaoCrypt::Integer*); -template TaoCrypt::Integer* uninit_fill_n(TaoCrypt::Integer*, unsigned int, TaoCrypt::Integer const&); -template TaoCrypt::WindowSlider* uninit_copy(TaoCrypt::WindowSlider*, TaoCrypt::WindowSlider*, TaoCrypt::WindowSlider*); -template vector* uninit_fill_n*, unsigned int, vector >(vector*, unsigned int, vector const&); -template void destroy(TaoCrypt::Integer*, TaoCrypt::Integer*); -template void destroy(TaoCrypt::WindowSlider*, TaoCrypt::WindowSlider*); -template void destroy*>(vector*, vector*); -} -#endif - - diff --git a/extra/yassl/taocrypt/src/template_instnt.cpp b/extra/yassl/taocrypt/src/template_instnt.cpp new file mode 100644 index 00000000000..28dbdc5c739 --- /dev/null +++ b/extra/yassl/taocrypt/src/template_instnt.cpp @@ -0,0 +1,31 @@ +#include "integer.hpp" +#include "rsa.hpp" +#include "algebra.hpp" +#include "vector.hpp" +#include "hash.hpp" + +#ifdef __GNUC__ +namespace TaoCrypt { +#if defined(SSE2_INTRINSICS_AVAILABLE) +template AlignedAllocator::pointer StdReallocate >(AlignedAllocator&, unsigned int*, AlignedAllocator::size_type, AlignedAllocator::size_type, bool); +#endif +template AllocatorWithCleanup::pointer StdReallocate >(AllocatorWithCleanup&, unsigned char*, AllocatorWithCleanup::size_type, AllocatorWithCleanup::size_type, bool); +template AllocatorWithCleanup::pointer StdReallocate >(AllocatorWithCleanup&, unsigned int*, AllocatorWithCleanup::size_type, AllocatorWithCleanup::size_type, bool); +template class RSA_Decryptor; +template class RSA_Encryptor; +template class RSA_Encryptor; +} + +namespace mySTL { +template vector* uninit_fill_n*, unsigned int, vector >(vector*, unsigned int, vector const&); +template void destroy*>(vector*, vector*); +template TaoCrypt::Integer* uninit_copy(TaoCrypt::Integer*, TaoCrypt::Integer*, TaoCrypt::Integer*); +template TaoCrypt::Integer* uninit_fill_n(TaoCrypt::Integer*, unsigned int, TaoCrypt::Integer const&); +template void destroy(TaoCrypt::Integer*, TaoCrypt::Integer*); +} + +template void TaoCrypt::tcDelete(TaoCrypt::HASH*); +template void TaoCrypt::tcArrayDelete(unsigned*); +template void TaoCrypt::tcArrayDelete(unsigned char*); +template void TaoCrypt::tcArrayDelete(char*); +#endif diff --git a/include/config-win.h b/include/config-win.h index a4f81a0ec6a..b17e4df4e26 100644 --- a/include/config-win.h +++ b/include/config-win.h @@ -76,6 +76,7 @@ functions */ #define F_EXCLUSIVE 1 /* We have only exclusive locking */ #define F_TO_EOF (INT_MAX32/2) /* size for lock of all file */ #define F_OK 0 /* parameter to access() */ +#define W_OK 2 #define S_IROTH S_IREAD /* for my_lib */ @@ -399,6 +400,7 @@ inline double ulonglong2double(ulonglong value) /* #undef HAVE_CHARSET_cp850 */ /* #undef HAVE_CHARSET_cp852 */ /* #undef HAVE_CHARSET_cp866 */ +#define HAVE_CHARSET_cp932 1 /* #undef HAVE_CHARSET_dec8 */ #define HAVE_CHARSET_eucjpms 1 #define HAVE_CHARSET_euckr 1 diff --git a/include/my_global.h b/include/my_global.h index 75a99133e33..b4dfb5b7f7d 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -48,6 +48,11 @@ #define USE_PRAGMA_INTERFACE #endif +/* Determine when to use "#pragma implementation" */ +#if !defined(__INTEL_COMPILER) && defined(__GNUC__) && (__GNUC__ < 3) +#define USE_PRAGMA_IMPLEMENTATION +#endif + #if defined(i386) && !defined(__i386__) #define __i386__ #endif @@ -310,12 +315,14 @@ C_MODE_END #endif #if defined(__ia64__) #define new my_arg_new +#define need_to_restore_new 1 #endif C_MODE_START #include C_MODE_END -#if defined(__ia64__) +#ifdef need_to_restore_new /* probably safer than #ifdef new */ #undef new +#undef need_to_restore_new #endif #endif #include /* Recommended by debian */ diff --git a/include/my_sys.h b/include/my_sys.h index 10358470c77..62affb31740 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -605,6 +605,7 @@ extern int my_access(const char *path, int amode); #else #define my_access access #endif +extern int check_if_legal_filename(const char *path); #ifndef TERMINATE extern void TERMINATE(FILE *file); diff --git a/innobase/row/row0mysql.c b/innobase/row/row0mysql.c index fd720046e31..fafbef4c999 100644 --- a/innobase/row/row0mysql.c +++ b/innobase/row/row0mysql.c @@ -3151,6 +3151,7 @@ row_drop_table_for_mysql( foreign = UT_LIST_GET_FIRST(table->referenced_list); while (foreign && foreign->foreign_table == table) { + check_next_foreign: foreign = UT_LIST_GET_NEXT(referenced_list, foreign); } @@ -3179,6 +3180,10 @@ row_drop_table_for_mysql( goto funct_exit; } + if (foreign && trx->check_foreigns) { + goto check_next_foreign; + } + if (table->n_mysql_handles_opened > 0) { ibool added; diff --git a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c index e136aee43e8..541b73b831d 100644 --- a/innobase/srv/srv0start.c +++ b/innobase/srv/srv0start.c @@ -1736,7 +1736,7 @@ innobase_shutdown_for_mysql(void) " InnoDB: MySQL has requested a very fast shutdown without flushing " "the InnoDB buffer pool to data files. At the next mysqld startup " "InnoDB will do a crash recovery!\n"); - } + } #ifdef __NETWARE__ if(!panic_shutdown) @@ -1758,8 +1758,9 @@ innobase_shutdown_for_mysql(void) to die; all which counts is that we flushed the log; a 'very fast' shutdown is essentially a crash. */ - if (srv_fast_shutdown) - return((int) DB_SUCCESS); + if (srv_fast_shutdown == 2) { + return(DB_SUCCESS); + } /* All threads end up waiting for certain events. Put those events to the signaled state. Then the threads will exit themselves in diff --git a/mysql-test/lib/init_db.sql b/mysql-test/lib/init_db.sql index 18699497b64..9671de49ca5 100644 --- a/mysql-test/lib/init_db.sql +++ b/mysql-test/lib/init_db.sql @@ -50,6 +50,9 @@ CREATE TABLE host ( Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, + Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, + Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, + Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, PRIMARY KEY Host (Host,Db) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin @@ -489,10 +492,11 @@ CREATE TABLE procs_priv ( Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Routine_name char(64) binary DEFAULT '' NOT NULL, + Routine_type enum('FUNCTION','PROCEDURE') NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, - Timestamp timestamp(14), Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL, - PRIMARY KEY (Host,Db,User,Routine_name), + Timestamp timestamp(14), + PRIMARY KEY (Host,Db,User,Routine_name,Routine_type), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index cd1e634a831..45b1e948ac2 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -1212,8 +1212,8 @@ start_master() $NOT_FIRST_MASTER_EXTRA_OPTS" fi - CUR_MYERR=$MASTER_MYERR - CUR_MYSOCK=$MASTER_MYSOCK + CUR_MYERR=$MASTER_MYERR$1 + CUR_MYSOCK=$MASTER_MYSOCK$1 # For embedded server we collect the server flags and return if [ "x$USE_EMBEDDED_SERVER" = "x1" ] ; then diff --git a/mysql-test/r/count_distinct.result b/mysql-test/r/count_distinct.result index 1bc1ad6a31e..a21748359b9 100644 --- a/mysql-test/r/count_distinct.result +++ b/mysql-test/r/count_distinct.result @@ -60,3 +60,9 @@ count(distinct a) 1 1 drop table t1; +create table t1 (f1 int, f2 int); +insert into t1 values (0,1),(1,2); +select count(distinct if(f1,3,f2)) from t1; +count(distinct if(f1,3,f2)) +2 +drop table t1; diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result index 34ccab9bcc5..ae09b8d730c 100644 --- a/mysql-test/r/create.result +++ b/mysql-test/r/create.result @@ -579,3 +579,21 @@ select * from t2; b 1 drop table t1,t2; +use test; +create table t1 (a int); +create table t1 select * from t1; +ERROR HY000: You can't specify target table 't1' for update in FROM clause +create table t2 union = (t1) select * from t1; +ERROR HY000: You can't specify target table 't1' for update in FROM clause +flush tables with read lock; +unlock tables; +drop table t1; +create table t1(column.name int); +ERROR 42000: Incorrect table name 'column' +create table t1(test.column.name int); +ERROR 42000: Incorrect table name 'column' +create table t1(xyz.t1.name int); +ERROR 42000: Incorrect database name 'xyz' +create table t1(t1.name int); +create table t2(test.t2.name int); +drop table t1,t2; diff --git a/mysql-test/r/default.result b/mysql-test/r/default.result new file mode 100644 index 00000000000..7db20c2b096 --- /dev/null +++ b/mysql-test/r/default.result @@ -0,0 +1,138 @@ +drop table if exists t1,t2,t3,t4,t5,t6; +drop database if exists mysqltest; +CREATE TABLE t1 (a varchar(30) binary NOT NULL DEFAULT ' ', +b varchar(1) binary NOT NULL DEFAULT ' ', +c varchar(4) binary NOT NULL DEFAULT '0000', +d tinyblob NULL, +e tinyblob NULL, +f tinyblob NULL, +g tinyblob NULL, +h tinyblob NULL, +i tinyblob NULL, +j tinyblob NULL, +k tinyblob NULL, +l tinyblob NULL, +m tinyblob NULL, +n tinyblob NULL, +o tinyblob NULL, +p tinyblob NULL, +q varchar(30) binary NOT NULL DEFAULT ' ', +r varchar(30) binary NOT NULL DEFAULT ' ', +s tinyblob NULL, +t varchar(4) binary NOT NULL DEFAULT ' ', +u varchar(1) binary NOT NULL DEFAULT ' ', +v varchar(30) binary NOT NULL DEFAULT ' ', +w varchar(30) binary NOT NULL DEFAULT ' ', +x tinyblob NULL, +y varchar(5) binary NOT NULL DEFAULT ' ', +z varchar(20) binary NOT NULL DEFAULT ' ', +a1 varchar(30) binary NOT NULL DEFAULT ' ', +b1 tinyblob NULL) +ENGINE=InnoDB DEFAULT CHARACTER SET = latin1 COLLATE latin1_bin; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(30) collate latin1_bin NOT NULL default ' ', + `b` varchar(1) collate latin1_bin NOT NULL default ' ', + `c` varchar(4) collate latin1_bin NOT NULL default '0000', + `d` tinyblob, + `e` tinyblob, + `f` tinyblob, + `g` tinyblob, + `h` tinyblob, + `i` tinyblob, + `j` tinyblob, + `k` tinyblob, + `l` tinyblob, + `m` tinyblob, + `n` tinyblob, + `o` tinyblob, + `p` tinyblob, + `q` varchar(30) collate latin1_bin NOT NULL default ' ', + `r` varchar(30) collate latin1_bin NOT NULL default ' ', + `s` tinyblob, + `t` varchar(4) collate latin1_bin NOT NULL default ' ', + `u` varchar(1) collate latin1_bin NOT NULL default ' ', + `v` varchar(30) collate latin1_bin NOT NULL default ' ', + `w` varchar(30) collate latin1_bin NOT NULL default ' ', + `x` tinyblob, + `y` varchar(5) collate latin1_bin NOT NULL default ' ', + `z` varchar(20) collate latin1_bin NOT NULL default ' ', + `a1` varchar(30) collate latin1_bin NOT NULL default ' ', + `b1` tinyblob +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin +INSERT into t1 (b) values ('1'); +SHOW WARNINGS; +Level Code Message +SELECT * from t1; +a b c d e f g h i j k l m n o p q r s t u v w x y z a1 b1 + 1 0000 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +CREATE TABLE t2 (a varchar(30) binary NOT NULL DEFAULT ' ', +b varchar(1) binary NOT NULL DEFAULT ' ', +c varchar(4) binary NOT NULL DEFAULT '0000', +d tinyblob NULL, +e tinyblob NULL, +f tinyblob NULL, +g tinyblob NULL, +h tinyblob NULL, +i tinyblob NULL, +j tinyblob NULL, +k tinyblob NULL, +l tinyblob NULL, +m tinyblob NULL, +n tinyblob NULL, +o tinyblob NULL, +p tinyblob NULL, +q varchar(30) binary NOT NULL DEFAULT ' ', +r varchar(30) binary NOT NULL DEFAULT ' ', +s tinyblob NULL, +t varchar(4) binary NOT NULL DEFAULT ' ', +u varchar(1) binary NOT NULL DEFAULT ' ', +v varchar(30) binary NOT NULL DEFAULT ' ', +w varchar(30) binary NOT NULL DEFAULT ' ', +x tinyblob NULL, +y varchar(5) binary NOT NULL DEFAULT ' ', +z varchar(20) binary NOT NULL DEFAULT ' ', +a1 varchar(30) binary NOT NULL DEFAULT ' ', +b1 tinyblob NULL) +ENGINE=MyISAM DEFAULT CHARACTER SET = latin1 COLLATE latin1_bin; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` varchar(30) collate latin1_bin NOT NULL default ' ', + `b` varchar(1) collate latin1_bin NOT NULL default ' ', + `c` varchar(4) collate latin1_bin NOT NULL default '0000', + `d` tinyblob, + `e` tinyblob, + `f` tinyblob, + `g` tinyblob, + `h` tinyblob, + `i` tinyblob, + `j` tinyblob, + `k` tinyblob, + `l` tinyblob, + `m` tinyblob, + `n` tinyblob, + `o` tinyblob, + `p` tinyblob, + `q` varchar(30) collate latin1_bin NOT NULL default ' ', + `r` varchar(30) collate latin1_bin NOT NULL default ' ', + `s` tinyblob, + `t` varchar(4) collate latin1_bin NOT NULL default ' ', + `u` varchar(1) collate latin1_bin NOT NULL default ' ', + `v` varchar(30) collate latin1_bin NOT NULL default ' ', + `w` varchar(30) collate latin1_bin NOT NULL default ' ', + `x` tinyblob, + `y` varchar(5) collate latin1_bin NOT NULL default ' ', + `z` varchar(20) collate latin1_bin NOT NULL default ' ', + `a1` varchar(30) collate latin1_bin NOT NULL default ' ', + `b1` tinyblob +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_bin +INSERT into t2 (b) values ('1'); +SHOW WARNINGS; +Level Code Message +SELECT * from t2; +a b c d e f g h i j k l m n o p q r s t u v w x y z a1 b1 + 1 0000 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +drop table t1; +drop table t2; diff --git a/mysql-test/r/federated.result b/mysql-test/r/federated.result index 6c815e94b7c..d9c86a89c75 100644 --- a/mysql-test/r/federated.result +++ b/mysql-test/r/federated.result @@ -906,9 +906,100 @@ INSERT INTO federated.t1 (name, country_id, other) VALUES ('Lenz', 2, 22222); INSERT INTO federated.t1 (name, country_id, other) VALUES ('Marizio', 3, 33333); INSERT INTO federated.t1 (name, country_id, other) VALUES ('Monty', 4, 33333); INSERT INTO federated.t1 (name, country_id, other) VALUES ('Sanja', 5, 33333); +EXPLAIN SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, +federated.t1.other AS other, federated.countries.country AS country +FROM federated.t1, federated.countries WHERE +federated.t1.country_id = federated.countries.id; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE countries ALL PRIMARY NULL NULL NULL 5 +1 SIMPLE t1 ref country_id country_id 4 federated.countries.id 120 +SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, +federated.t1.other AS other, federated.countries.country AS country +FROM federated.t1, federated.countries WHERE +federated.t1.country_id = federated.countries.id; +name country_id other country +Kumar 1 11111 India +Lenz 2 22222 Germany +Marizio 3 33333 Italy +Monty 4 33333 Finland +Sanja 5 33333 Ukraine +EXPLAIN SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, +federated.t1.other AS other, federated.countries.country AS country +FROM federated.t1 INNER JOIN federated.countries ON +federated.t1.country_id = federated.countries.id; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE countries ALL PRIMARY NULL NULL NULL 5 +1 SIMPLE t1 ref country_id country_id 4 federated.countries.id 120 +SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, +federated.t1.other AS other, federated.countries.country AS country +FROM federated.t1 INNER JOIN federated.countries ON +federated.t1.country_id = federated.countries.id; +name country_id other country +Kumar 1 11111 India +Lenz 2 22222 Germany +Marizio 3 33333 Italy +Monty 4 33333 Finland +Sanja 5 33333 Ukraine +EXPLAIN SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, +federated.t1.other AS other, federated.countries.country AS country +FROM federated.t1 INNER JOIN federated.countries ON +federated.t1.country_id = federated.countries.id +WHERE federated.t1.name = 'Monty'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE countries ALL PRIMARY NULL NULL NULL 5 +1 SIMPLE t1 ref country_id country_id 4 federated.countries.id 120 Using where +SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, +federated.t1.other AS other, federated.countries.country AS country +FROM federated.t1 INNER JOIN federated.countries ON +federated.t1.country_id = federated.countries.id +WHERE federated.t1.name = 'Monty'; +name country_id other country +Monty 4 33333 Finland +EXPLAIN SELECT federated.t1.*, federated.countries.country +FROM federated.t1 LEFT JOIN federated.countries +ON federated.t1.country_id = federated.countries.id +ORDER BY federated.countries.id; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 10000 Using temporary; Using filesort +1 SIMPLE countries eq_ref PRIMARY PRIMARY 4 federated.t1.country_id 1 SELECT federated.t1.*, federated.countries.country -FROM federated.t1 left join federated.countries -ON federated.t1.country_id = federated.countries.id; +FROM federated.t1 LEFT JOIN federated.countries +ON federated.t1.country_id = federated.countries.id +ORDER BY federated.countries.id; +id country_id name other country +1 1 Kumar 11111 India +2 2 Lenz 22222 Germany +3 3 Marizio 33333 Italy +4 4 Monty 33333 Finland +5 5 Sanja 33333 Ukraine +EXPLAIN SELECT federated.t1.*, federated.countries.country +FROM federated.t1 LEFT JOIN federated.countries +ON federated.t1.country_id = federated.countries.id +ORDER BY federated.countries.country; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 10000 Using temporary; Using filesort +1 SIMPLE countries eq_ref PRIMARY PRIMARY 4 federated.t1.country_id 1 +SELECT federated.t1.*, federated.countries.country +FROM federated.t1 LEFT JOIN federated.countries +ON federated.t1.country_id = federated.countries.id +ORDER BY federated.countries.country; +id country_id name other country +4 4 Monty 33333 Finland +2 2 Lenz 22222 Germany +1 1 Kumar 11111 India +3 3 Marizio 33333 Italy +5 5 Sanja 33333 Ukraine +EXPLAIN SELECT federated.t1.*, federated.countries.country +FROM federated.t1 RIGHT JOIN federated.countries +ON federated.t1.country_id = federated.countries.id +ORDER BY federated.t1.country_id; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE countries ALL NULL NULL NULL NULL 5 Using temporary; Using filesort +1 SIMPLE t1 ref country_id country_id 4 federated.countries.id 120 +SELECT federated.t1.*, federated.countries.country +FROM federated.t1 RIGHT JOIN federated.countries +ON federated.t1.country_id = federated.countries.id +ORDER BY federated.t1.country_id; id country_id name other country 1 1 Kumar 11111 India 2 2 Lenz 22222 Germany diff --git a/mysql-test/r/func_if.result b/mysql-test/r/func_if.result index 4db31121756..3e72fb45a14 100644 --- a/mysql-test/r/func_if.result +++ b/mysql-test/r/func_if.result @@ -91,3 +91,20 @@ drop table t1; SELECT NULLIF(5,5) IS NULL, NULLIF(5,5) IS NOT NULL; NULLIF(5,5) IS NULL NULLIF(5,5) IS NOT NULL 1 0 +CREATE TABLE `t1` ( +`id` int(11) NOT NULL , +`date` int(10) default NULL, +`text` varchar(32) NOT NULL +); +INSERT INTO t1 VALUES (1,1110000000,'Day 1'),(2,1111000000,'Day 2'),(3,1112000000,'Day 3'); +SELECT id, IF(date IS NULL, '-', FROM_UNIXTIME(date, '%d-%m-%Y')) AS date_ord, text FROM t1 ORDER BY date_ord ASC; +id date_ord text +1 05-03-2005 Day 1 +2 16-03-2005 Day 2 +3 28-03-2005 Day 3 +SELECT id, IF(date IS NULL, '-', FROM_UNIXTIME(date, '%d-%m-%Y')) AS date_ord, text FROM t1 ORDER BY date_ord DESC; +id date_ord text +3 28-03-2005 Day 3 +2 16-03-2005 Day 2 +1 05-03-2005 Day 1 +DROP TABLE t1; diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result index bbb5a94606e..1c6a4393dfc 100644 --- a/mysql-test/r/func_str.result +++ b/mysql-test/r/func_str.result @@ -794,3 +794,9 @@ id aes_decrypt(str, 'bar') 1 foo 2 NULL DROP TABLE t1, t2; +select field(0,NULL,1,0), field("",NULL,"bar",""), field(0.0,NULL,1.0,0.0); +field(0,NULL,1,0) field("",NULL,"bar","") field(0.0,NULL,1.0,0.0) +3 3 3 +select field(NULL,1,2,NULL), field(NULL,1,2,0); +field(NULL,1,2,NULL) field(NULL,1,2,0) +0 0 diff --git a/mysql-test/r/group_min_max.result b/mysql-test/r/group_min_max.result index dea6bca2cdd..a43f1ee88a6 100644 --- a/mysql-test/r/group_min_max.result +++ b/mysql-test/r/group_min_max.result @@ -133,13 +133,13 @@ Table Op Msg_type Msg_text test.t3 analyze status Table is already up to date explain select a1, min(a2) from t1 group by a1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range NULL idx_t1_1 65 NULL 5 Using index for group-by +1 SIMPLE t1 range NULL idx_t1_1 130 NULL 5 Using index for group-by explain select a1, max(a2) from t1 group by a1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range NULL idx_t1_1 65 NULL 5 Using index for group-by explain select a1, min(a2), max(a2) from t1 group by a1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range NULL idx_t1_1 65 NULL 5 Using index for group-by +1 SIMPLE t1 range NULL idx_t1_1 130 NULL 5 Using index for group-by explain select a1, a2, b, min(c), max(c) from t1 group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using index for group-by @@ -151,13 +151,13 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 range NULL idx_t2_1 # NULL # Using index for group-by explain select min(a2), a1, max(a2), min(a2), a1 from t1 group by a1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range NULL idx_t1_1 65 NULL 5 Using index for group-by +1 SIMPLE t1 range NULL idx_t1_1 130 NULL 5 Using index for group-by explain select a1, b, min(c), a1, max(c), b, a2, max(c), max(c) from t1 group by a1, a2, b; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using index for group-by explain select min(a2) from t1 group by a1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range NULL idx_t1_1 65 NULL 5 Using index for group-by +1 SIMPLE t1 range NULL idx_t1_1 130 NULL 5 Using index for group-by explain select a2, min(c), max(c) from t1 group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using index for group-by @@ -1404,7 +1404,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # Using where; Using index for group-by explain select a1,a2,b,min(c) from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # Using where; Using index for group-by +1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # Using where; Using index for group-by select a1,a2,b,min(c),max(c) from t1 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b; a1 a2 b min(c) max(c) a a b e112 h112 @@ -1838,7 +1838,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 Using where; Using index for group-by explain select concat(ord(min(b)),ord(max(b))),min(b),max(b) from t1 group by a1,a2; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range NULL idx_t1_1 130 NULL 9 Using index for group-by +1 SIMPLE t1 range NULL idx_t1_1 147 NULL 9 Using index for group-by select a1,a2,b, concat(min(c), max(c)) from t1 where a1 < 'd' group by a1,a2,b; a1 a2 b concat(min(c), max(c)) a a a a111d111 diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index ab57a918e98..872d1f6ea7f 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -470,7 +470,7 @@ s1 drop table t1; SHOW CREATE TABLE INFORMATION_SCHEMA.character_sets; Table Create Table -character_sets CREATE TEMPORARY TABLE `character_sets` ( +CHARACTER_SETS CREATE TEMPORARY TABLE `CHARACTER_SETS` ( `CHARACTER_SET_NAME` varchar(64) NOT NULL default '', `DEFAULT_COLLATE_NAME` varchar(64) NOT NULL default '', `DESCRIPTION` varchar(60) NOT NULL default '', @@ -479,7 +479,7 @@ character_sets CREATE TEMPORARY TABLE `character_sets` ( set names latin2; SHOW CREATE TABLE INFORMATION_SCHEMA.character_sets; Table Create Table -character_sets CREATE TEMPORARY TABLE `character_sets` ( +CHARACTER_SETS CREATE TEMPORARY TABLE `CHARACTER_SETS` ( `CHARACTER_SET_NAME` varchar(64) NOT NULL default '', `DEFAULT_COLLATE_NAME` varchar(64) NOT NULL default '', `DESCRIPTION` varchar(60) NOT NULL default '', diff --git a/mysql-test/r/lock.result b/mysql-test/r/lock.result index 16c92fa201f..a1efb1a8e69 100644 --- a/mysql-test/r/lock.result +++ b/mysql-test/r/lock.result @@ -47,3 +47,13 @@ unlock tables; lock tables t1 write, t1 as t1_alias read; insert into t1 select index1,nr from t1 as t1_alias; drop table t1,t2; +create table t1 ( a int(11) not null auto_increment, primary key(a)); +create table t2 ( a int(11) not null auto_increment, primary key(a)); +lock tables t1 write, t2 read; +delete from t1 using t1,t2 where t1.a=t2.a; +delete t1 from t1,t2 where t1.a=t2.a; +delete from t2 using t1,t2 where t1.a=t2.a; +ERROR HY000: Table 't2' was locked with a READ lock and can't be updated +delete t2 from t1,t2 where t1.a=t2.a; +ERROR HY000: Table 't2' was locked with a READ lock and can't be updated +drop table t1,t2; diff --git a/mysql-test/r/lowercase_table2.result b/mysql-test/r/lowercase_table2.result index 8361b66817a..1015990df9a 100644 --- a/mysql-test/r/lowercase_table2.result +++ b/mysql-test/r/lowercase_table2.result @@ -72,7 +72,7 @@ T1 CREATE TABLE `T1` ( RENAME TABLE T1 TO T2; SHOW TABLES LIKE "T2"; Tables_in_test (T2) -t2 +T2 SELECT * FROM t2; a 1 @@ -83,25 +83,25 @@ t3 RENAME TABLE T3 TO T1; SHOW TABLES LIKE "T1"; Tables_in_test (T1) -t1 +T1 ALTER TABLE T1 add b int; SHOW TABLES LIKE "T1"; Tables_in_test (T1) -t1 +T1 ALTER TABLE T1 RENAME T2; SHOW TABLES LIKE "T2"; Tables_in_test (T2) -t2 +T2 LOCK TABLE T2 WRITE; ALTER TABLE T2 drop b; SHOW TABLES LIKE "T2"; Tables_in_test (T2) -t2 +T2 UNLOCK TABLES; RENAME TABLE T2 TO T1; SHOW TABLES LIKE "T1"; Tables_in_test (T1) -t1 +T1 SELECT * from T1; a 1 diff --git a/mysql-test/r/mysql.result b/mysql-test/r/mysql.result new file mode 100644 index 00000000000..feb0b2348cd --- /dev/null +++ b/mysql-test/r/mysql.result @@ -0,0 +1,50 @@ +drop table if exists t1; +create table t1(a int); +insert into t1 values(1); + +Test default delimiter ; +a +1 + +Test delimiter without arg + +Test delimiter : +a +1 + +Test delimiter : +a +1 + +Test delimiter :; +a +1 + +Test delimiter // +a +1 + +Test delimiter MySQL +a +1 + +Test delimiter delimiter +a +1 + +Test delimiter : from command line +a +1 + +Test delimiter :; from command line +a +1 + +Test 'go' command(vertical output) G +*************************** 1. row *************************** +a: 1 + +Test 'go' command g +a +1 +drop table t1; diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index 35d0df0c888..f73c9b223fd 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -1384,3 +1384,41 @@ UNLOCK TABLES; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; drop table t1; +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (1),(2),(3); + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +/*!40000 DROP DATABASE IF EXISTS `test`*/; + +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET latin1 */; + +USE `test`; +DROP TABLE IF EXISTS `t1`; +CREATE TABLE `t1` ( + `a` int(11) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + + +/*!40000 ALTER TABLE `t1` DISABLE KEYS */; +LOCK TABLES `t1` WRITE; +INSERT INTO `t1` VALUES (1),(2),(3); +UNLOCK TABLES; +/*!40000 ALTER TABLE `t1` ENABLE KEYS */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +DROP TABLE t1; diff --git a/mysql-test/r/olap.result b/mysql-test/r/olap.result index 9411edcdc00..5ba2bc80484 100644 --- a/mysql-test/r/olap.result +++ b/mysql-test/r/olap.result @@ -253,7 +253,7 @@ concat(':',product,':') sum(profit) avg(profit) :Computer: 6900 1380.00000 :Phone: 10 10.00000 :TV: 600 120.00000 -:TV: 7785 519.00000 +NULL 7785 519.00000 select product, country_id , year, sum(profit) from t1 group by product, country_id, year with cube; ERROR 42000: This version of MySQL doesn't yet support 'CUBE' explain select product, country_id , year, sum(profit) from t1 group by product, country_id, year with cube; @@ -489,3 +489,69 @@ a SUM(a) SUM(a)+1 CONCAT(SUM(a),'x') SUM(a)+SUM(a) SUM(a) 5 5 6 5x 10 5 NULL 8 9 8x 16 8 DROP TABLE t1; +CREATE TABLE t1 (a int(11)); +INSERT INTO t1 VALUES (1),(2); +SELECT a, a+1, SUM(a) FROM t1 GROUP BY a WITH ROLLUP; +a a+1 SUM(a) +1 2 1 +2 3 2 +NULL NULL 3 +SELECT a+1 FROM t1 GROUP BY a WITH ROLLUP; +a+1 +2 +3 +NULL +SELECT a+SUM(a) FROM t1 GROUP BY a WITH ROLLUP; +a+SUM(a) +2 +4 +NULL +SELECT a, a+1 as b FROM t1 GROUP BY a WITH ROLLUP HAVING b > 2; +a b +2 3 +SELECT a, a+1 as b FROM t1 GROUP BY a WITH ROLLUP HAVING a IS NULL; +a b +NULL NULL +SELECT a, a+1 as b FROM t1 GROUP BY a WITH ROLLUP HAVING b IS NULL; +a b +NULL NULL +SELECT IFNULL(a, 'TEST') FROM t1 GROUP BY a WITH ROLLUP; +IFNULL(a, 'TEST') +1 +2 +TEST +CREATE TABLE t2 (a int, b int); +INSERT INTO t2 VALUES +(1,4), +(2,2), (2,2), +(4,1), (4,1), (4,1), (4,1), +(2,1), (2,1); +SELECT a,b,SUM(b) FROM t2 GROUP BY a,b WITH ROLLUP; +a b SUM(b) +1 4 4 +1 NULL 4 +2 1 2 +2 2 4 +2 NULL 6 +4 1 4 +4 NULL 4 +NULL NULL 14 +SELECT a,b,SUM(b), a+b as c FROM t2 +GROUP BY a,b WITH ROLLUP HAVING c IS NULL; +a b SUM(b) c +1 NULL 4 NULL +2 NULL 6 NULL +4 NULL 4 NULL +NULL NULL 14 NULL +SELECT IFNULL(a, 'TEST'), COALESCE(b, 'TEST') FROM t2 +GROUP BY a, b WITH ROLLUP; +IFNULL(a, 'TEST') COALESCE(b, 'TEST') +1 4 +1 TEST +2 1 +2 2 +2 TEST +4 1 +4 TEST +TEST TEST +DROP TABLE t1,t2; diff --git a/mysql-test/r/reserved_win_names.require b/mysql-test/r/reserved_win_names.require deleted file mode 100644 index 7f803aca482..00000000000 --- a/mysql-test/r/reserved_win_names.require +++ /dev/null @@ -1,2 +0,0 @@ -Variable_name Value -lower_case_table_names 1 diff --git a/mysql-test/r/reserved_win_names.result b/mysql-test/r/reserved_win_names.result deleted file mode 100644 index eaa0f71513f..00000000000 --- a/mysql-test/r/reserved_win_names.result +++ /dev/null @@ -1,7 +0,0 @@ -use COM1; -ERROR 42000: Unknown database 'com1' -use LPT1; -ERROR 42000: Unknown database 'lpt1' -use PRN; -ERROR 42000: Unknown database 'prn' - diff --git a/mysql-test/r/rpl_failed_optimize.result b/mysql-test/r/rpl_failed_optimize.result index c7199e56ec8..fd711f89222 100644 --- a/mysql-test/r/rpl_failed_optimize.result +++ b/mysql-test/r/rpl_failed_optimize.result @@ -9,6 +9,7 @@ BEGIN; INSERT INTO t1 VALUES (1); OPTIMIZE TABLE t1; Table Op Msg_type Msg_text +test.t1 optimize error Lock wait timeout exceeded; try restarting transaction test.t1 optimize status Operation failed Warnings: Error 1205 Lock wait timeout exceeded; try restarting transaction diff --git a/mysql-test/r/rpl_log.result b/mysql-test/r/rpl_log.result index 5d61746b984..5e0eec6305d 100644 --- a/mysql-test/r/rpl_log.result +++ b/mysql-test/r/rpl_log.result @@ -68,14 +68,14 @@ master-bin.000002 260 Query 1 346 use `test`; create table t1 (n int) master-bin.000002 346 Query 1 434 use `test`; insert into t1 values (1) master-bin.000002 434 Query 1 510 use `test`; drop table t1 show binary logs; -Log_name -master-bin.000001 -master-bin.000002 +Log_name File_size +master-bin.000001 0 +master-bin.000002 510 start slave; show binary logs; -Log_name -slave-bin.000001 -slave-bin.000002 +Log_name File_size +slave-bin.000001 0 +slave-bin.000002 348 show binlog events in 'slave-bin.000001' from 4; Log_name Pos Event_type Server_id End_log_pos Info slave-bin.000001 4 Format_desc 2 98 Server ver: VERSION, Binlog ver: 4 diff --git a/mysql-test/r/rpl_rotate_logs.result b/mysql-test/r/rpl_rotate_logs.result index de177d12196..a6d3697987a 100644 --- a/mysql-test/r/rpl_rotate_logs.result +++ b/mysql-test/r/rpl_rotate_logs.result @@ -26,10 +26,10 @@ create table t2(m int not null auto_increment primary key); insert into t2 values (34),(67),(123); flush logs; show binary logs; -Log_name -master-bin.000001 -master-bin.000002 -master-bin.000003 +Log_name File_size +master-bin.000001 0 +master-bin.000002 0 +master-bin.000003 98 create table t3 select * from temp_table; select * from t3; a @@ -42,18 +42,18 @@ set global sql_slave_skip_counter=1; start slave; purge master logs to 'master-bin.000002'; show master logs; -Log_name -master-bin.000002 -master-bin.000003 +Log_name File_size +master-bin.000002 0 +master-bin.000003 407 purge binary logs to 'master-bin.000002'; show binary logs; -Log_name -master-bin.000002 -master-bin.000003 +Log_name File_size +master-bin.000002 0 +master-bin.000003 407 purge master logs before now(); show binary logs; -Log_name -master-bin.000003 +Log_name File_size +master-bin.000003 407 insert into t2 values (65); show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master @@ -73,10 +73,10 @@ count(*) 100 create table t4 select * from temp_table; show binary logs; -Log_name -master-bin.000003 -master-bin.000004 -master-bin.000005 +Log_name File_size +master-bin.000003 0 +master-bin.000004 0 +master-bin.000005 2032 show master status; File Position Binlog_Do_DB Binlog_Ignore_DB master-bin.000005 2032 diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index 8932d2c78ae..eaed7719673 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -2423,6 +2423,12 @@ ERROR HY000: Incorrect usage of ALL and DISTINCT select distinct all * from t1; ERROR HY000: Incorrect usage of ALL and DISTINCT drop table t1; +CREATE TABLE t1 (b BIGINT(20) UNSIGNED NOT NULL, PRIMARY KEY (b)); +INSERT INTO t1 VALUES (0x8000000000000000); +SELECT b FROM t1 WHERE b=0x8000000000000000; +b +9223372036854775808 +DROP TABLE t1; CREATE TABLE t1 ( K2C4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '', K4N4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '0000', diff --git a/mysql-test/r/view_skip_grants.result b/mysql-test/r/skip_grants.result similarity index 61% rename from mysql-test/r/view_skip_grants.result rename to mysql-test/r/skip_grants.result index 48cb9f2aa25..c0c20eb25be 100644 --- a/mysql-test/r/view_skip_grants.result +++ b/mysql-test/r/skip_grants.result @@ -1,6 +1,10 @@ drop table if exists t1,v1; drop view if exists t1,v1; +drop procedure if exists f1; use test; create table t1 (field1 INT); CREATE VIEW v1 AS SELECT field1 FROM t1; drop view v1; +drop table t1; +create procedure f1() select 1; +drop procedure f1; diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result index 7c19f60471a..1dc97124a07 100644 --- a/mysql-test/r/sp-error.result +++ b/mysql-test/r/sp-error.result @@ -646,4 +646,29 @@ drop procedure if exists bug10537| create procedure bug10537() load data local infile '/tmp/somefile' into table t1| ERROR 0A000: LOAD DATA is not allowed in stored procedures +drop function if exists bug8409| +create function bug8409() +returns int +begin +flush tables; +return 5; +end| +ERROR 0A000: FLUSH is not allowed in stored procedures +create procedure bug9529_90123456789012345678901234567890123456789012345678901234567890() +begin +end| +ERROR 42000: Identifier name 'bug9529_90123456789012345678901234567890123456789012345678901234567890' is too long +drop procedure if exists bug10969| +create procedure bug10969() +begin +declare s1 int default 0; +select default(s1) from t30; +end| +ERROR 42000: Incorrect column name 's1' +create procedure bug10969() +begin +declare s1 int default 0; +select default(t30.s1) from t30; +end| +drop procedure bug10969| drop table t1| diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index c1164380f09..3c6fa84882f 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -3098,4 +3098,44 @@ call bug5963_2(1)| call bug5963_2(1)| drop procedure bug5963_2| drop table t3| +drop function if exists bug9559| +create function bug9559() +returns int +begin +set @y = -6/2; +return @y; +end| +select bug9559()| +bug9559() +-3 +drop function bug9559| +drop procedure if exists bug10961| +create procedure bug10961() +begin +declare v char; +declare x int; +declare c cursor for select * from dual; +declare continue handler for sqlexception select x; +set x = 1; +open c; +set x = 2; +fetch c into v; +set x = 3; +close c; +end| +call bug10961()| +x +1 +x +2 +x +3 +call bug10961()| +x +1 +x +2 +x +3 +drop procedure bug10961| drop table t1,t2; diff --git a/mysql-test/r/trigger.result b/mysql-test/r/trigger.result index cf0e0e8f564..996a692d531 100644 --- a/mysql-test/r/trigger.result +++ b/mysql-test/r/trigger.result @@ -140,6 +140,48 @@ drop trigger t1.trg1; drop trigger t1.trg2; drop trigger t1.trg3; drop table t1; +create table t1 (id int not null primary key, data int); +create trigger t1_bi before insert on t1 for each row +set @log:= concat(@log, "(BEFORE_INSERT: new=(id=", new.id, ", data=", new.data,"))"); +create trigger t1_ai after insert on t1 for each row +set @log:= concat(@log, "(AFTER_INSERT: new=(id=", new.id, ", data=", new.data,"))"); +create trigger t1_bu before update on t1 for each row +set @log:= concat(@log, "(BEFORE_UPDATE: old=(id=", old.id, ", data=", old.data, +") new=(id=", new.id, ", data=", new.data,"))"); +create trigger t1_au after update on t1 for each row +set @log:= concat(@log, "(AFTER_UPDATE: old=(id=", old.id, ", data=", old.data, +") new=(id=", new.id, ", data=", new.data,"))"); +create trigger t1_bd before delete on t1 for each row +set @log:= concat(@log, "(BEFORE_DELETE: old=(id=", old.id, ", data=", old.data,"))"); +create trigger t1_ad after delete on t1 for each row +set @log:= concat(@log, "(AFTER_DELETE: old=(id=", old.id, ", data=", old.data,"))"); +set @log:= ""; +insert into t1 values (1, 1); +select @log; +@log +(BEFORE_INSERT: new=(id=1, data=1))(AFTER_INSERT: new=(id=1, data=1)) +set @log:= ""; +insert ignore t1 values (1, 2); +select @log; +@log +(BEFORE_INSERT: new=(id=1, data=2)) +set @log:= ""; +replace t1 values (1, 3), (2, 2); +select @log; +@log +(BEFORE_INSERT: new=(id=1, data=3))(BEFORE_UPDATE: old=(id=1, data=1) new=(id=1, data=3))(AFTER_UPDATE: old=(id=1, data=1) new=(id=1, data=3))(BEFORE_INSERT: new=(id=2, data=2))(AFTER_INSERT: new=(id=2, data=2)) +alter table t1 add ts timestamp default now(); +set @log:= ""; +replace t1 (id, data) values (1, 4); +select @log; +@log +(BEFORE_INSERT: new=(id=1, data=4))(BEFORE_DELETE: old=(id=1, data=3))(AFTER_DELETE: old=(id=1, data=3))(AFTER_INSERT: new=(id=1, data=4)) +set @log:= ""; +insert into t1 (id, data) values (1, 5), (3, 3) on duplicate key update data= data + 2; +select @log; +@log +(BEFORE_INSERT: new=(id=1, data=5))(BEFORE_UPDATE: old=(id=1, data=4) new=(id=1, data=6))(AFTER_UPDATE: old=(id=1, data=4) new=(id=1, data=6))(BEFORE_INSERT: new=(id=3, data=3))(AFTER_INSERT: new=(id=3, data=3)) +drop table t1; create table t1 (i int); create trigger trg before insert on t1 for each row set @a:= old.i; ERROR HY000: There is no OLD row in on INSERT trigger @@ -206,3 +248,237 @@ create table t1 (i int); create trigger trg1 before insert on t1 for each row set @a:= 1; drop database mysqltest; use test; +create table t1 (i int, j int default 10, k int not null, key (k)); +create table t2 (i int); +insert into t1 (i, k) values (1, 1); +insert into t2 values (1); +create trigger trg1 before update on t1 for each row set @a:= @a + new.j - old.j; +create trigger trg2 after update on t1 for each row set @b:= "Fired"; +set @a:= 0, @b:= ""; +update t1, t2 set j = j + 10 where t1.i = t2.i; +select @a, @b; +@a @b +10 Fired +insert into t1 values (2, 13, 2); +insert into t2 values (2); +set @a:= 0, @b:= ""; +update t1, t2 set j = j + 15 where t1.i = t2.i and t1.k >= 2; +select @a, @b; +@a @b +15 Fired +create trigger trg3 before delete on t1 for each row set @c:= @c + old.j; +create trigger trg4 before delete on t2 for each row set @d:= @d + old.i; +create trigger trg5 after delete on t1 for each row set @e:= "After delete t1 fired"; +create trigger trg6 after delete on t2 for each row set @f:= "After delete t2 fired"; +set @c:= 0, @d:= 0, @e:= "", @f:= ""; +delete t1, t2 from t1, t2 where t1.i = t2.i; +select @c, @d, @e, @f; +@c @d @e @f +48 3 After delete t1 fired After delete t2 fired +drop table t1, t2; +create table t1 (i int, j int default 10)| +create table t2 (i int)| +insert into t2 values (1), (2)| +create trigger trg1 before insert on t1 for each row +begin +if new.i = 1 then +set new.j := 1; +end if; +end| +create trigger trg2 after insert on t1 for each row set @a:= 1| +set @a:= 0| +insert into t1 (i) select * from t2| +select * from t1| +i j +1 1 +2 10 +select @a| +@a +1 +drop table t1, t2| +create table t1 (i int, j int, k int); +create trigger trg1 before insert on t1 for each row set new.k = new.i; +create trigger trg2 after insert on t1 for each row set @b:= "Fired"; +set @b:=""; +load data infile '../../std_data/rpl_loaddata.dat' into table t1 (@a, i); +select *, @b from t1; +i j k @b +10 NULL 10 Fired +15 NULL 15 Fired +set @b:=""; +load data infile '../../std_data/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (i, j); +select *, @b from t1; +i j k @b +10 NULL 10 Fired +15 NULL 15 Fired +1 2 1 Fired +3 4 3 Fired +5 6 5 Fired +drop table t1; +create table t1 (i int, at int, k int, key(k)) engine=myisam; +create table t2 (i int); +insert into t1 values (1, 1, 1); +insert into t2 values (1), (2), (3); +create trigger ai after insert on t1 for each row set @a:= new.at; +create trigger au after update on t1 for each row set @a:= new.at; +create trigger ad after delete on t1 for each row set @a:= old.at; +alter table t1 drop column at; +select * from t1; +i k +1 1 +insert into t1 values (2, 1); +ERROR 42S22: Unknown column 'at' in 'NEW' +select * from t1; +i k +1 1 +2 1 +update t1 set k = 2 where i = 2; +ERROR 42S22: Unknown column 'at' in 'NEW' +select * from t1; +i k +1 1 +2 2 +delete from t1 where i = 2; +ERROR 42S22: Unknown column 'at' in 'OLD' +select * from t1; +i k +1 1 +load data infile '../../std_data/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (i, k); +ERROR 42S22: Unknown column 'at' in 'NEW' +select * from t1; +i k +1 1 +1 2 +insert into t1 select 3, 3; +ERROR 42S22: Unknown column 'at' in 'NEW' +select * from t1; +i k +1 1 +1 2 +3 3 +update t1, t2 set k = k + 10 where t1.i = t2.i; +ERROR 42S22: Unknown column 'at' in 'NEW' +select * from t1; +i k +1 11 +1 2 +3 3 +update t1, t2 set k = k + 10 where t1.i = t2.i and k < 3; +ERROR 42S22: Unknown column 'at' in 'NEW' +select * from t1; +i k +1 11 +1 12 +3 3 +delete t1, t2 from t1 straight_join t2 where t1.i = t2.i; +ERROR 42S22: Unknown column 'at' in 'OLD' +select * from t1; +i k +1 12 +3 3 +delete t2, t1 from t2 straight_join t1 where t1.i = t2.i; +ERROR 42S22: Unknown column 'at' in 'OLD' +select * from t1; +i k +3 3 +alter table t1 add primary key (i); +insert into t1 values (3, 4) on duplicate key update k= k + 10; +ERROR 42S22: Unknown column 'at' in 'NEW' +select * from t1; +i k +3 13 +replace into t1 values (3, 3); +ERROR 42S22: Unknown column 'at' in 'NEW' +select * from t1; +i k +3 3 +alter table t1 add ts timestamp default now(); +replace into t1 (i, k) values (3, 13); +ERROR 42S22: Unknown column 'at' in 'OLD' +select * from t1; +i k ts +drop table t1, t2; +create table t1 (i int, bt int, k int, key(k)) engine=myisam; +create table t2 (i int); +insert into t1 values (1, 1, 1), (2, 2, 2); +insert into t2 values (1), (2), (3); +create trigger bi before insert on t1 for each row set @a:= new.bt; +create trigger bu before update on t1 for each row set @a:= new.bt; +create trigger bd before delete on t1 for each row set @a:= old.bt; +alter table t1 drop column bt; +insert into t1 values (3, 3); +ERROR 42S22: Unknown column 'bt' in 'NEW' +select * from t1; +i k +1 1 +2 2 +update t1 set i = 2; +ERROR 42S22: Unknown column 'bt' in 'NEW' +select * from t1; +i k +1 1 +2 2 +delete from t1; +ERROR 42S22: Unknown column 'bt' in 'OLD' +select * from t1; +i k +1 1 +2 2 +load data infile '../../std_data/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (i, k); +ERROR 42S22: Unknown column 'bt' in 'NEW' +select * from t1; +i k +1 1 +2 2 +insert into t1 select 3, 3; +ERROR 42S22: Unknown column 'bt' in 'NEW' +select * from t1; +i k +1 1 +2 2 +update t1, t2 set k = k + 10 where t1.i = t2.i; +ERROR 42S22: Unknown column 'bt' in 'NEW' +select * from t1; +i k +1 1 +2 2 +update t1, t2 set k = k + 10 where t1.i = t2.i and k < 2; +ERROR 42S22: Unknown column 'bt' in 'NEW' +select * from t1; +i k +1 1 +2 2 +delete t1, t2 from t1 straight_join t2 where t1.i = t2.i; +ERROR 42S22: Unknown column 'bt' in 'OLD' +select * from t1; +i k +1 1 +2 2 +delete t2, t1 from t2 straight_join t1 where t1.i = t2.i; +ERROR 42S22: Unknown column 'bt' in 'OLD' +select * from t1; +i k +1 1 +2 2 +alter table t1 add primary key (i); +drop trigger t1.bi; +insert into t1 values (2, 4) on duplicate key update k= k + 10; +ERROR 42S22: Unknown column 'bt' in 'NEW' +select * from t1; +i k +1 1 +2 2 +replace into t1 values (2, 4); +ERROR 42S22: Unknown column 'bt' in 'NEW' +select * from t1; +i k +1 1 +2 2 +alter table t1 add ts timestamp default now(); +replace into t1 (i, k) values (2, 11); +ERROR 42S22: Unknown column 'bt' in 'OLD' +select * from t1; +i k ts +1 1 0000-00-00 00:00:00 +2 2 0000-00-00 00:00:00 +drop table t1, t2; diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result index aae3c414c5c..1f45d238ea5 100644 --- a/mysql-test/r/union.result +++ b/mysql-test/r/union.result @@ -1252,3 +1252,36 @@ t2 CREATE TABLE `t2` ( `a` varchar(12) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 ROW_FORMAT=FIXED drop table t1,t2; +CREATE TABLE t1 (a mediumtext); +CREATE TABLE t2 (b varchar(20)); +INSERT INTO t1 VALUES ('a'),('b'); +SELECT left(a,100000000) FROM t1 UNION SELECT b FROM t2; +left(a,100000000) +a +b +create table t3 SELECT left(a,100000000) FROM t1 UNION SELECT b FROM t2; +show create table t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `left(a,100000000)` longtext +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop tables t1,t2,t3; +create table t1 ( id int not null auto_increment, primary key (id), col1 int); +insert into t1 (col1) values (2),(3),(4),(5),(6); +select 99 union all select id from t1 order by 1; +99 +1 +2 +3 +4 +5 +99 +select id from t1 union all select 99 order by 1; +id +1 +2 +3 +4 +5 +99 +drop table t1; diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index c7f980df350..99b4f0529e6 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -236,6 +236,12 @@ query_prealloc_size 8192 range_alloc_block_size 2048 transaction_alloc_block_size 8192 transaction_prealloc_size 4096 +SELECT @@version LIKE 'non-existent'; +@@version LIKE 'non-existent' +0 +SELECT @@version_compile_os LIKE 'non-existent'; +@@version_compile_os LIKE 'non-existent' +0 set big_tables=OFFF; ERROR 42000: Variable 'big_tables' can't be set to the value of 'OFFF' set big_tables="OFFF"; diff --git a/mysql-test/t/count_distinct.test b/mysql-test/t/count_distinct.test index 73c6951e78f..be67026e268 100644 --- a/mysql-test/t/count_distinct.test +++ b/mysql-test/t/count_distinct.test @@ -63,3 +63,15 @@ create table t1 (a char(3), b char(20), primary key (a, b)); insert into t1 values ('ABW', 'Dutch'), ('ABW', 'English'); select count(distinct a) from t1 group by b; drop table t1; + +# +# Bug #9593 "The combination of COUNT, DISTINCT and CONCAT +# seems to lock the server" +# Bug appears only on Windows system +# + +create table t1 (f1 int, f2 int); +insert into t1 values (0,1),(1,2); +select count(distinct if(f1,3,f2)) from t1; +drop table t1; + diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test index d4733e6dc7e..d9712a28788 100644 --- a/mysql-test/t/create.test +++ b/mysql-test/t/create.test @@ -471,3 +471,33 @@ insert into t2 values (); select * from t1; select * from t2; drop table t1,t2; + +# +# Bug#10224 - ANALYZE TABLE crashing with simultaneous +# CREATE ... SELECT statement. +# This tests two additional possible errors and a hang if +# an improper fix is present. +# +connection default; +use test; +create table t1 (a int); +--error 1093 +create table t1 select * from t1; +--error 1093 +create table t2 union = (t1) select * from t1; +flush tables with read lock; +unlock tables; +drop table t1; + +# +# Bug#10413: Invalid column name is not rejected +# +--error 1103 +create table t1(column.name int); +--error 1103 +create table t1(test.column.name int); +--error 1102 +create table t1(xyz.t1.name int); +create table t1(t1.name int); +create table t2(test.t2.name int); +drop table t1,t2; diff --git a/mysql-test/t/default.test b/mysql-test/t/default.test new file mode 100644 index 00000000000..42620a27b66 --- /dev/null +++ b/mysql-test/t/default.test @@ -0,0 +1,85 @@ +# +# test of already fixed bugs +# +--disable_warnings +drop table if exists t1,t2,t3,t4,t5,t6; +drop database if exists mysqltest; + +# +# Bug 10838 +# Insert causes warnings for no default values and corrupts tables +# +CREATE TABLE t1 (a varchar(30) binary NOT NULL DEFAULT ' ', + b varchar(1) binary NOT NULL DEFAULT ' ', + c varchar(4) binary NOT NULL DEFAULT '0000', + d tinyblob NULL, + e tinyblob NULL, + f tinyblob NULL, + g tinyblob NULL, + h tinyblob NULL, + i tinyblob NULL, + j tinyblob NULL, + k tinyblob NULL, + l tinyblob NULL, + m tinyblob NULL, + n tinyblob NULL, + o tinyblob NULL, + p tinyblob NULL, + q varchar(30) binary NOT NULL DEFAULT ' ', + r varchar(30) binary NOT NULL DEFAULT ' ', + s tinyblob NULL, + t varchar(4) binary NOT NULL DEFAULT ' ', + u varchar(1) binary NOT NULL DEFAULT ' ', + v varchar(30) binary NOT NULL DEFAULT ' ', + w varchar(30) binary NOT NULL DEFAULT ' ', + x tinyblob NULL, + y varchar(5) binary NOT NULL DEFAULT ' ', + z varchar(20) binary NOT NULL DEFAULT ' ', + a1 varchar(30) binary NOT NULL DEFAULT ' ', + b1 tinyblob NULL) +ENGINE=InnoDB DEFAULT CHARACTER SET = latin1 COLLATE latin1_bin; +--enable_warnings + +SHOW CREATE TABLE t1; +INSERT into t1 (b) values ('1'); +SHOW WARNINGS; +SELECT * from t1; + +CREATE TABLE t2 (a varchar(30) binary NOT NULL DEFAULT ' ', + b varchar(1) binary NOT NULL DEFAULT ' ', + c varchar(4) binary NOT NULL DEFAULT '0000', + d tinyblob NULL, + e tinyblob NULL, + f tinyblob NULL, + g tinyblob NULL, + h tinyblob NULL, + i tinyblob NULL, + j tinyblob NULL, + k tinyblob NULL, + l tinyblob NULL, + m tinyblob NULL, + n tinyblob NULL, + o tinyblob NULL, + p tinyblob NULL, + q varchar(30) binary NOT NULL DEFAULT ' ', + r varchar(30) binary NOT NULL DEFAULT ' ', + s tinyblob NULL, + t varchar(4) binary NOT NULL DEFAULT ' ', + u varchar(1) binary NOT NULL DEFAULT ' ', + v varchar(30) binary NOT NULL DEFAULT ' ', + w varchar(30) binary NOT NULL DEFAULT ' ', + x tinyblob NULL, + y varchar(5) binary NOT NULL DEFAULT ' ', + z varchar(20) binary NOT NULL DEFAULT ' ', + a1 varchar(30) binary NOT NULL DEFAULT ' ', + b1 tinyblob NULL) +ENGINE=MyISAM DEFAULT CHARACTER SET = latin1 COLLATE latin1_bin; + +SHOW CREATE TABLE t2; +INSERT into t2 (b) values ('1'); +SHOW WARNINGS; +SELECT * from t2; + +drop table t1; +drop table t2; + diff --git a/mysql-test/t/federated.test b/mysql-test/t/federated.test index 6a0e0bdac79..1e33efe1c0e 100644 --- a/mysql-test/t/federated.test +++ b/mysql-test/t/federated.test @@ -861,9 +861,70 @@ INSERT INTO federated.t1 (name, country_id, other) VALUES ('Marizio', 3, 33333); INSERT INTO federated.t1 (name, country_id, other) VALUES ('Monty', 4, 33333); INSERT INTO federated.t1 (name, country_id, other) VALUES ('Sanja', 5, 33333); +#inner join +EXPLAIN SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, +federated.t1.other AS other, federated.countries.country AS country +FROM federated.t1, federated.countries WHERE +federated.t1.country_id = federated.countries.id; + +SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, +federated.t1.other AS other, federated.countries.country AS country +FROM federated.t1, federated.countries WHERE +federated.t1.country_id = federated.countries.id; + +EXPLAIN SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, +federated.t1.other AS other, federated.countries.country AS country +FROM federated.t1 INNER JOIN federated.countries ON +federated.t1.country_id = federated.countries.id; + +SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, +federated.t1.other AS other, federated.countries.country AS country +FROM federated.t1 INNER JOIN federated.countries ON +federated.t1.country_id = federated.countries.id; + +EXPLAIN SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, +federated.t1.other AS other, federated.countries.country AS country +FROM federated.t1 INNER JOIN federated.countries ON +federated.t1.country_id = federated.countries.id +WHERE federated.t1.name = 'Monty'; + +SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, +federated.t1.other AS other, federated.countries.country AS country +FROM federated.t1 INNER JOIN federated.countries ON +federated.t1.country_id = federated.countries.id +WHERE federated.t1.name = 'Monty'; + +#left join +EXPLAIN SELECT federated.t1.*, federated.countries.country +FROM federated.t1 LEFT JOIN federated.countries +ON federated.t1.country_id = federated.countries.id +ORDER BY federated.countries.id; + SELECT federated.t1.*, federated.countries.country -FROM federated.t1 left join federated.countries -ON federated.t1.country_id = federated.countries.id; +FROM federated.t1 LEFT JOIN federated.countries +ON federated.t1.country_id = federated.countries.id +ORDER BY federated.countries.id; + +EXPLAIN SELECT federated.t1.*, federated.countries.country +FROM federated.t1 LEFT JOIN federated.countries +ON federated.t1.country_id = federated.countries.id +ORDER BY federated.countries.country; + +SELECT federated.t1.*, federated.countries.country +FROM federated.t1 LEFT JOIN federated.countries +ON federated.t1.country_id = federated.countries.id +ORDER BY federated.countries.country; + +#right join +EXPLAIN SELECT federated.t1.*, federated.countries.country +FROM federated.t1 RIGHT JOIN federated.countries +ON federated.t1.country_id = federated.countries.id +ORDER BY federated.t1.country_id; + +SELECT federated.t1.*, federated.countries.country +FROM federated.t1 RIGHT JOIN federated.countries +ON federated.t1.country_id = federated.countries.id +ORDER BY federated.t1.country_id; DROP TABLE federated.countries; diff --git a/mysql-test/t/func_if.test b/mysql-test/t/func_if.test index a2ea26390ca..37556984f68 100644 --- a/mysql-test/t/func_if.test +++ b/mysql-test/t/func_if.test @@ -61,3 +61,17 @@ drop table t1; # Bug #5595 NULLIF() IS NULL returns false if NULLIF() returns NULL # SELECT NULLIF(5,5) IS NULL, NULLIF(5,5) IS NOT NULL; + +# +# Bug #9669 Ordering on IF function with FROM_UNIXTIME function fails +# +CREATE TABLE `t1` ( + `id` int(11) NOT NULL , + `date` int(10) default NULL, + `text` varchar(32) NOT NULL +); +INSERT INTO t1 VALUES (1,1110000000,'Day 1'),(2,1111000000,'Day 2'),(3,1112000000,'Day 3'); +SELECT id, IF(date IS NULL, '-', FROM_UNIXTIME(date, '%d-%m-%Y')) AS date_ord, text FROM t1 ORDER BY date_ord ASC; +SELECT id, IF(date IS NULL, '-', FROM_UNIXTIME(date, '%d-%m-%Y')) AS date_ord, text FROM t1 ORDER BY date_ord DESC; +DROP TABLE t1; + diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test index b3c875f7bf5..728f0e2c084 100644 --- a/mysql-test/t/func_str.test +++ b/mysql-test/t/func_str.test @@ -523,3 +523,9 @@ SELECT t1.id, aes_decrypt(str, 'bar') FROM t1, t2 WHERE t1.id = t2.id ORDER BY t1.id; DROP TABLE t1, t2; + +# +# Bug #10944: Mishandling of NULL arguments in FIELD() +# +select field(0,NULL,1,0), field("",NULL,"bar",""), field(0.0,NULL,1.0,0.0); +select field(NULL,1,2,NULL), field(NULL,1,2,0); diff --git a/mysql-test/t/lock.test b/mysql-test/t/lock.test index faa1fa3ac25..127cbb54a88 100644 --- a/mysql-test/t/lock.test +++ b/mysql-test/t/lock.test @@ -59,3 +59,17 @@ unlock tables; lock tables t1 write, t1 as t1_alias read; insert into t1 select index1,nr from t1 as t1_alias; drop table t1,t2; + +# +# Bug7241 - Invalid response when DELETE .. USING and LOCK TABLES used. +# +create table t1 ( a int(11) not null auto_increment, primary key(a)); +create table t2 ( a int(11) not null auto_increment, primary key(a)); +lock tables t1 write, t2 read; +delete from t1 using t1,t2 where t1.a=t2.a; +delete t1 from t1,t2 where t1.a=t2.a; +--error 1099 +delete from t2 using t1,t2 where t1.a=t2.a; +--error 1099 +delete t2 from t1,t2 where t1.a=t2.a; +drop table t1,t2; diff --git a/mysql-test/t/mysql.test b/mysql-test/t/mysql.test new file mode 100644 index 00000000000..d30e5b65d8e --- /dev/null +++ b/mysql-test/t/mysql.test @@ -0,0 +1,34 @@ +# +# Testing the MySQL command line client(mysql) +# + +--disable_warnings +drop table if exists t1; +--enable_warnings + +# +# Test the "delimiter" functionality +# Bug#9879 +# +create table t1(a int); +insert into t1 values(1); + +# Test delimiters +--exec $MYSQL test < "./t/mysql_delimiter.sql" + +--disable_query_log +# Test delimiter : supplied on the command line +select "Test delimiter : from command line" as " "; +--exec $MYSQL test --delimiter=':' -e 'select * from t1:' +# Test delimiter :; supplied on the command line +select "Test delimiter :; from command line" as " "; +--exec $MYSQL test --delimiter=':;' -e 'select * from t1:;' +# Test 'go' command (vertical output) \G +select "Test 'go' command(vertical output) \G" as " "; +--exec $MYSQL test -e 'select * from t1\G' +# Test 'go' command \g +select "Test 'go' command \g" as " "; +--exec $MYSQL test -e 'select * from t1\g' +--enable_query_log + +drop table t1; diff --git a/mysql-test/t/mysql_delimiter.sql b/mysql-test/t/mysql_delimiter.sql new file mode 100644 index 00000000000..4ea481a84e2 --- /dev/null +++ b/mysql-test/t/mysql_delimiter.sql @@ -0,0 +1,48 @@ + +# Test default delimiter ; +select "Test default delimiter ;" as " "; +select * from t1; + +# Test delimiter without argument +select "Test delimiter without arg" as " "; +# Nothing should be displayed, error is returned +delimiter +delimiter ; # Reset delimiter + +# Test delimiter : +select "Test delimiter :" as " "; +delimiter : +select * from t1: +delimiter ; # Reset delimiter + +# Test delimiter ':' +select "Test delimiter :" as " "; +delimiter ':' +select * from t1: +delimiter ; # Reset delimiter + +# Test delimiter :; +select "Test delimiter :;" as " "; +delimiter :; +select * from t1 :; +delimiter ; # Reset delimiter + +## Test delimiter // +select "Test delimiter //" as " "; +delimiter // +select * from t1// +delimiter ; # Reset delimiter + +# Test delimiter 'MySQL' +select "Test delimiter MySQL" as " "; +delimiter 'MySQL' +select * from t1MySQL +delimiter ; # Reset delimiter + +# Test delimiter 'delimiter'(should be allowed according to the code) +select "Test delimiter delimiter" as " "; +delimiter delimiter +select * from t1 delimiter +delimiter ; # Reset delimiter + + diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index 4af62fe3b01..7a39fbdf5f6 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -554,3 +554,12 @@ create table t1 ( insert into t1 (F_8d3bba7425e7c98c50f52ca1b52d3735) values (1); --exec $MYSQL_DUMP --skip-comments -c test drop table t1; + +# +# Test for --add-drop-database +# + +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (1),(2),(3); +--exec $MYSQL_DUMP --add-drop-database --skip-comments --databases test +DROP TABLE t1; diff --git a/mysql-test/t/olap.test b/mysql-test/t/olap.test index 88f778be4d5..c75cad0b051 100644 --- a/mysql-test/t/olap.test +++ b/mysql-test/t/olap.test @@ -220,3 +220,33 @@ SELECT a, SUM(a), SUM(a)+1, CONCAT(SUM(a),'x'), SUM(a)+SUM(a), SUM(a) DROP TABLE t1; +# +# Tests for bug #7894: ROLLUP over expressions on group by attributes +# + +CREATE TABLE t1 (a int(11)); +INSERT INTO t1 VALUES (1),(2); + +SELECT a, a+1, SUM(a) FROM t1 GROUP BY a WITH ROLLUP; +SELECT a+1 FROM t1 GROUP BY a WITH ROLLUP; +SELECT a+SUM(a) FROM t1 GROUP BY a WITH ROLLUP; +SELECT a, a+1 as b FROM t1 GROUP BY a WITH ROLLUP HAVING b > 2; +SELECT a, a+1 as b FROM t1 GROUP BY a WITH ROLLUP HAVING a IS NULL; +SELECT a, a+1 as b FROM t1 GROUP BY a WITH ROLLUP HAVING b IS NULL; +SELECT IFNULL(a, 'TEST') FROM t1 GROUP BY a WITH ROLLUP; + +CREATE TABLE t2 (a int, b int); +INSERT INTO t2 VALUES + (1,4), + (2,2), (2,2), + (4,1), (4,1), (4,1), (4,1), + (2,1), (2,1); + +SELECT a,b,SUM(b) FROM t2 GROUP BY a,b WITH ROLLUP; +SELECT a,b,SUM(b), a+b as c FROM t2 + GROUP BY a,b WITH ROLLUP HAVING c IS NULL; +SELECT IFNULL(a, 'TEST'), COALESCE(b, 'TEST') FROM t2 + GROUP BY a, b WITH ROLLUP; + +DROP TABLE t1,t2; + diff --git a/mysql-test/t/reserved_win_names.test b/mysql-test/t/reserved_win_names.test deleted file mode 100644 index d9b23935ddf..00000000000 --- a/mysql-test/t/reserved_win_names.test +++ /dev/null @@ -1,12 +0,0 @@ -# -# Test of reserved Windows names -# ---require r/reserved_win_names.require - ---error 1049 -use COM1; ---error 1049 -use LPT1; ---error 1049 -use PRN; - diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index 84ac8a67b04..b6132d23d02 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -1998,6 +1998,15 @@ select distinct all * from t1; drop table t1; # + +# +# Test for Bug#8009, SELECT failed on bigint unsigned when using HEX +# + +CREATE TABLE t1 (b BIGINT(20) UNSIGNED NOT NULL, PRIMARY KEY (b)); +INSERT INTO t1 VALUES (0x8000000000000000); +SELECT b FROM t1 WHERE b=0x8000000000000000; +DROP TABLE t1; # Test for bug #6474 # diff --git a/mysql-test/t/view_skip_grants-master.opt b/mysql-test/t/skip_grants-master.opt similarity index 100% rename from mysql-test/t/view_skip_grants-master.opt rename to mysql-test/t/skip_grants-master.opt diff --git a/mysql-test/t/view_skip_grants.test b/mysql-test/t/skip_grants.test similarity index 59% rename from mysql-test/t/view_skip_grants.test rename to mysql-test/t/skip_grants.test index bfbaec44eb1..99223fa4756 100644 --- a/mysql-test/t/view_skip_grants.test +++ b/mysql-test/t/skip_grants.test @@ -1,6 +1,7 @@ --disable_warnings drop table if exists t1,v1; drop view if exists t1,v1; +drop procedure if exists f1; --enable_warnings use test; @@ -11,4 +12,11 @@ create table t1 (field1 INT); CREATE VIEW v1 AS SELECT field1 FROM t1; drop view v1; -drop table t1 +drop table t1; + +# +# Test that we can create and drop procedure without warnings +# see bug#9993 +# +create procedure f1() select 1; +drop procedure f1; diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test index 67e9be5dd5d..891e282e335 100644 --- a/mysql-test/t/sp-error.test +++ b/mysql-test/t/sp-error.test @@ -905,6 +905,54 @@ create procedure bug10537() load data local infile '/tmp/somefile' into table t1| +# +# BUG#8409: Stored procedure crash if function contains FLUSH +# +--disable_warnings +drop function if exists bug8409| +--enable_warnings +--error ER_SP_BADSTATEMENT +create function bug8409() + returns int +begin + flush tables; + return 5; +end| + + +# +# BUG#9529: Stored Procedures: No Warning on truncation of procedure name +# during creation. +# +--error ER_TOO_LONG_IDENT +create procedure bug9529_90123456789012345678901234567890123456789012345678901234567890() +begin +end| + + +# +# BUG#10969: Stored procedures: crash if default() function +# +--disable_warnings +drop procedure if exists bug10969| +--enable_warnings +--error ER_WRONG_COLUMN_NAME +create procedure bug10969() +begin + declare s1 int default 0; + select default(s1) from t30; +end| + +# This should work +create procedure bug10969() +begin + declare s1 int default 0; + select default(t30.s1) from t30; +end| + +drop procedure bug10969| + + # # BUG#NNNN: New bug synopsis # diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index 80acaacfdb3..7acd4d81081 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -3801,6 +3801,54 @@ call bug5963_2(1)| drop procedure bug5963_2| drop table t3| + +# +# BUG#9559: Functions: Numeric Operations using -ve value gives incorrect +# results. +# +--disable_warnings +drop function if exists bug9559| +--enable_warnings +create function bug9559() + returns int +begin + set @y = -6/2; + return @y; +end| + +select bug9559()| + +drop function bug9559| + + +# +# BUG#10961: Stored procedures: crash if select * from dual +# +--disable_warnings +drop procedure if exists bug10961| +--enable_warnings +# "select * from dual" results in an error, so the cursor will not open +create procedure bug10961() +begin + declare v char; + declare x int; + declare c cursor for select * from dual; + declare continue handler for sqlexception select x; + + set x = 1; + open c; + set x = 2; + fetch c into v; + set x = 3; + close c; +end| + +call bug10961()| +call bug10961()| + +drop procedure bug10961| + + # # BUG#NNNN: New bug synopsis # diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test index 53144cf3591..0c5ef077159 100644 --- a/mysql-test/t/trigger.test +++ b/mysql-test/t/trigger.test @@ -150,6 +150,55 @@ drop trigger t1.trg3; drop table t1; +# Let us test how triggers work for special forms of INSERT such as +# REPLACE and INSERT ... ON DUPLICATE KEY UPDATE +create table t1 (id int not null primary key, data int); +create trigger t1_bi before insert on t1 for each row + set @log:= concat(@log, "(BEFORE_INSERT: new=(id=", new.id, ", data=", new.data,"))"); +create trigger t1_ai after insert on t1 for each row + set @log:= concat(@log, "(AFTER_INSERT: new=(id=", new.id, ", data=", new.data,"))"); +create trigger t1_bu before update on t1 for each row + set @log:= concat(@log, "(BEFORE_UPDATE: old=(id=", old.id, ", data=", old.data, + ") new=(id=", new.id, ", data=", new.data,"))"); +create trigger t1_au after update on t1 for each row + set @log:= concat(@log, "(AFTER_UPDATE: old=(id=", old.id, ", data=", old.data, + ") new=(id=", new.id, ", data=", new.data,"))"); +create trigger t1_bd before delete on t1 for each row + set @log:= concat(@log, "(BEFORE_DELETE: old=(id=", old.id, ", data=", old.data,"))"); +create trigger t1_ad after delete on t1 for each row + set @log:= concat(@log, "(AFTER_DELETE: old=(id=", old.id, ", data=", old.data,"))"); +# Simple INSERT - both triggers should be called +set @log:= ""; +insert into t1 values (1, 1); +select @log; +# INSERT IGNORE for already existing key - only before trigger should fire +set @log:= ""; +insert ignore t1 values (1, 2); +select @log; +# REPLACE: before insert trigger should be called for both records, +# but then for first one update will be executed (and both update +# triggers should fire). For second after insert trigger will be +# called as for usual insert +set @log:= ""; +replace t1 values (1, 3), (2, 2); +select @log; +# Now let us change table in such way that REPLACE on won't be executed +# using update. +alter table t1 add ts timestamp default now(); +set @log:= ""; +# This REPLACE should be executed via DELETE and INSERT so proper +# triggers should be invoked. +replace t1 (id, data) values (1, 4); +select @log; +# Finally let us test INSERT ... ON DUPLICATE KEY UPDATE ... +set @log:= ""; +insert into t1 (id, data) values (1, 5), (3, 3) on duplicate key update data= data + 2; +select @log; + +# This also drops associated triggers +drop table t1; + + # # Test of wrong column specifiers in triggers # @@ -249,3 +298,199 @@ create trigger trg1 before insert on t1 for each row set @a:= 1; # This should succeed drop database mysqltest; use test; + +# Test for bug #5860 "Multi-table UPDATE does not activate update triggers" +# We will also test how delete triggers wor for multi-table DELETE. +create table t1 (i int, j int default 10, k int not null, key (k)); +create table t2 (i int); +insert into t1 (i, k) values (1, 1); +insert into t2 values (1); +create trigger trg1 before update on t1 for each row set @a:= @a + new.j - old.j; +create trigger trg2 after update on t1 for each row set @b:= "Fired"; +set @a:= 0, @b:= ""; +# Check that trigger works in case of update on the fly +update t1, t2 set j = j + 10 where t1.i = t2.i; +select @a, @b; +insert into t1 values (2, 13, 2); +insert into t2 values (2); +set @a:= 0, @b:= ""; +# And now let us check that triggers work in case of multi-update which +# is done through temporary tables... +update t1, t2 set j = j + 15 where t1.i = t2.i and t1.k >= 2; +select @a, @b; +# Let us test delete triggers for multi-delete now. +# We create triggers for both tables because we want test how they +# work in both on-the-fly and via-temp-tables cases. +create trigger trg3 before delete on t1 for each row set @c:= @c + old.j; +create trigger trg4 before delete on t2 for each row set @d:= @d + old.i; +create trigger trg5 after delete on t1 for each row set @e:= "After delete t1 fired"; +create trigger trg6 after delete on t2 for each row set @f:= "After delete t2 fired"; +set @c:= 0, @d:= 0, @e:= "", @f:= ""; +delete t1, t2 from t1, t2 where t1.i = t2.i; +select @c, @d, @e, @f; +# This also will drop triggers +drop table t1, t2; + +# Test for bug #6812 "Triggers are not activated for INSERT ... SELECT". +# (We also check the fact that trigger modifies some field does not affect +# value of next record inserted). +delimiter |; +create table t1 (i int, j int default 10)| +create table t2 (i int)| +insert into t2 values (1), (2)| +create trigger trg1 before insert on t1 for each row +begin + if new.i = 1 then + set new.j := 1; + end if; +end| +create trigger trg2 after insert on t1 for each row set @a:= 1| +set @a:= 0| +insert into t1 (i) select * from t2| +select * from t1| +select @a| +# This also will drop triggers +drop table t1, t2| +delimiter ;| + +# Test for bug #8755 "Trigger is not activated by LOAD DATA" +create table t1 (i int, j int, k int); +create trigger trg1 before insert on t1 for each row set new.k = new.i; +create trigger trg2 after insert on t1 for each row set @b:= "Fired"; +set @b:=""; +# Test triggers with file with separators +load data infile '../../std_data/rpl_loaddata.dat' into table t1 (@a, i); +select *, @b from t1; +set @b:=""; +# Test triggers with fixed size row file +load data infile '../../std_data/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (i, j); +select *, @b from t1; +# This also will drop triggers +drop table t1; + +# Test for bug #5894 "Triggers with altered tables cause corrupt databases" +# Also tests basic error handling for various kinds of triggers. +create table t1 (i int, at int, k int, key(k)) engine=myisam; +create table t2 (i int); +insert into t1 values (1, 1, 1); +# We need at least 3 elements in t2 to test multi-update properly +insert into t2 values (1), (2), (3); +# Create and then break "after" triggers +create trigger ai after insert on t1 for each row set @a:= new.at; +create trigger au after update on t1 for each row set @a:= new.at; +create trigger ad after delete on t1 for each row set @a:= old.at; +alter table t1 drop column at; +# We still should be able select data from tables. +select * from t1; +# The following statements changing t1 should fail, but still cause +# their main effect. This is because operation on the table row is +# executed before "after" trigger and its effect cannot be rolled back +# when whole statement fails, because t1 is MyISAM table. +--error 1054 +insert into t1 values (2, 1); +select * from t1; +--error 1054 +update t1 set k = 2 where i = 2; +select * from t1; +--error 1054 +delete from t1 where i = 2; +select * from t1; +# Should fail and insert only 1 row +--error 1054 +load data infile '../../std_data/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (i, k); +select * from t1; +--error 1054 +insert into t1 select 3, 3; +select * from t1; +# Multi-update working on the fly, again it will update only +# one row even if more matches +--error 1054 +update t1, t2 set k = k + 10 where t1.i = t2.i; +select * from t1; +# The same for multi-update via temp table +--error 1054 +update t1, t2 set k = k + 10 where t1.i = t2.i and k < 3; +select * from t1; +# Multi-delete on the fly +--error 1054 +delete t1, t2 from t1 straight_join t2 where t1.i = t2.i; +select * from t1; +# And via temporary storage +--error 1054 +delete t2, t1 from t2 straight_join t1 where t1.i = t2.i; +select * from t1; +# Prepare table for testing of REPLACE and INSERT ... ON DUPLICATE KEY UPDATE +alter table t1 add primary key (i); +--error 1054 +insert into t1 values (3, 4) on duplicate key update k= k + 10; +select * from t1; +--error 1054 +replace into t1 values (3, 3); +select * from t1; +# Change table in such way that REPLACE will delete row +alter table t1 add ts timestamp default now(); +--error 1054 +replace into t1 (i, k) values (3, 13); +select * from t1; +# Also drops all triggers +drop table t1, t2; + +create table t1 (i int, bt int, k int, key(k)) engine=myisam; +create table t2 (i int); +insert into t1 values (1, 1, 1), (2, 2, 2); +insert into t2 values (1), (2), (3); +# Create and then break "before" triggers +create trigger bi before insert on t1 for each row set @a:= new.bt; +create trigger bu before update on t1 for each row set @a:= new.bt; +create trigger bd before delete on t1 for each row set @a:= old.bt; +alter table t1 drop column bt; +# The following statements changing t1 should fail and should not +# cause any effect on table, since "before" trigger is executed +# before operation on the table row. +--error 1054 +insert into t1 values (3, 3); +select * from t1; +--error 1054 +update t1 set i = 2; +select * from t1; +--error 1054 +delete from t1; +select * from t1; +--error 1054 +load data infile '../../std_data/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (i, k); +select * from t1; +--error 1054 +insert into t1 select 3, 3; +select * from t1; +# Both types of multi-update (on the fly and via temp table) +--error 1054 +update t1, t2 set k = k + 10 where t1.i = t2.i; +select * from t1; +--error 1054 +update t1, t2 set k = k + 10 where t1.i = t2.i and k < 2; +select * from t1; +# Both types of multi-delete +--error 1054 +delete t1, t2 from t1 straight_join t2 where t1.i = t2.i; +select * from t1; +--error 1054 +delete t2, t1 from t2 straight_join t1 where t1.i = t2.i; +select * from t1; +# Let us test REPLACE/INSERT ... ON DUPLICATE KEY UPDATE. +# To test properly code-paths different from those that are used +# in ordinary INSERT we need to drop "before insert" trigger. +alter table t1 add primary key (i); +drop trigger t1.bi; +--error 1054 +insert into t1 values (2, 4) on duplicate key update k= k + 10; +select * from t1; +--error 1054 +replace into t1 values (2, 4); +select * from t1; +# Change table in such way that REPLACE will delete row +alter table t1 add ts timestamp default now(); +--error 1054 +replace into t1 (i, k) values (2, 11); +select * from t1; +# Also drops all triggers +drop table t1, t2; diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index 239a7aaad4b..4da19622dcb 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -772,3 +772,24 @@ select row_format from information_schema.TABLES where table_schema="test" and t alter table t2 ROW_FORMAT=fixed; show create table t2; drop table t1,t2; + +# +# correct conversion long string to TEXT (BUG#10025) +# +CREATE TABLE t1 (a mediumtext); +CREATE TABLE t2 (b varchar(20)); +INSERT INTO t1 VALUES ('a'),('b'); +SELECT left(a,100000000) FROM t1 UNION SELECT b FROM t2; +create table t3 SELECT left(a,100000000) FROM t1 UNION SELECT b FROM t2; +show create table t3; +drop tables t1,t2,t3; + +# +# Bug #10032 Bug in parsing UNION with ORDER BY when one node does not use FROM +# + +create table t1 ( id int not null auto_increment, primary key (id), col1 int); +insert into t1 (col1) values (2),(3),(4),(5),(6); +select 99 union all select id from t1 order by 1; +select id from t1 union all select 99 order by 1; +drop table t1; diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index 9e8a7a1b56f..f8d833b6b73 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -130,6 +130,13 @@ set @@query_alloc_block_size=default, @@query_prealloc_size=default; set transaction_alloc_block_size=default, @@transaction_prealloc_size=default; show variables like '%alloc%'; +# +# Bug #10904 Illegal mix of collations between +# a system variable and a constant +# +SELECT @@version LIKE 'non-existent'; +SELECT @@version_compile_os LIKE 'non-existent'; + # The following should give errors --error 1231 diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c index 2308536cd37..feb9c77a5b9 100644 --- a/mysys/mf_keycache.c +++ b/mysys/mf_keycache.c @@ -184,10 +184,18 @@ static void test_key_cache(KEY_CACHE *keycache, static FILE *keycache_debug_log=NULL; static void keycache_debug_print _VARARGS((const char *fmt,...)); #define KEYCACHE_DEBUG_OPEN \ - if (!keycache_debug_log) keycache_debug_log=fopen(KEYCACHE_DEBUG_LOG, "w") + if (!keycache_debug_log) \ + { \ + keycache_debug_log= fopen(KEYCACHE_DEBUG_LOG, "w"); \ + (void) setvbuf(keycache_debug_log, NULL, _IOLBF, BUFSIZ); \ + } #define KEYCACHE_DEBUG_CLOSE \ - if (keycache_debug_log) { fclose(keycache_debug_log); keycache_debug_log=0; } + if (keycache_debug_log) \ + { \ + fclose(keycache_debug_log); \ + keycache_debug_log= 0; \ + } #else #define KEYCACHE_DEBUG_OPEN #define KEYCACHE_DEBUG_CLOSE @@ -213,7 +221,7 @@ static long keycache_thread_id; #define KEYCACHE_THREAD_TRACE_BEGIN(l) \ { struct st_my_thread_var *thread_var= my_thread_var; \ - keycache_thread_id= my_thread_var->id; \ + keycache_thread_id= thread_var->id; \ KEYCACHE_DBUG_PRINT(l,("[thread %ld",keycache_thread_id)) } #define KEYCACHE_THREAD_TRACE_END(l) \ @@ -240,12 +248,10 @@ static int keycache_pthread_cond_wait(pthread_cond_t *cond, static int keycache_pthread_mutex_lock(pthread_mutex_t *mutex); static void keycache_pthread_mutex_unlock(pthread_mutex_t *mutex); static int keycache_pthread_cond_signal(pthread_cond_t *cond); -static int keycache_pthread_cond_broadcast(pthread_cond_t *cond); #else #define keycache_pthread_mutex_lock pthread_mutex_lock #define keycache_pthread_mutex_unlock pthread_mutex_unlock #define keycache_pthread_cond_signal pthread_cond_signal -#define keycache_pthread_cond_broadcast pthread_cond_broadcast #endif /* defined(KEYCACHE_DEBUG) */ static uint next_power(uint value) @@ -508,6 +514,8 @@ int resize_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, keycache->can_be_used= 0; while (keycache->cnt_for_resize_op) { + KEYCACHE_DBUG_PRINT("resize_key_cache: wait", + ("suspend thread %ld", thread->id)); keycache_pthread_cond_wait(&thread->suspend, &keycache->cache_lock); } @@ -520,7 +528,11 @@ finish: unlink_from_queue(wqueue, thread); /* Signal for the next resize request to proceeed if any */ if (wqueue->last_thread) + { + KEYCACHE_DBUG_PRINT("resize_key_cache: signal", + ("thread %ld", wqueue->last_thread->next->id)); keycache_pthread_cond_signal(&wqueue->last_thread->next->suspend); + } keycache_pthread_mutex_unlock(&keycache->cache_lock); return blocks; } @@ -544,7 +556,11 @@ static inline void dec_counter_for_resize_op(KEY_CACHE *keycache) struct st_my_thread_var *last_thread; if (!--keycache->cnt_for_resize_op && (last_thread= keycache->resize_queue.last_thread)) + { + KEYCACHE_DBUG_PRINT("dec_counter_for_resize_op: signal", + ("thread %ld", last_thread->next->id)); keycache_pthread_cond_signal(&last_thread->next->suspend); + } } /* @@ -761,8 +777,8 @@ static void release_queue(KEYCACHE_WQUEUE *wqueue) do { thread=next; - keycache_pthread_cond_signal(&thread->suspend); KEYCACHE_DBUG_PRINT("release_queue: signal", ("thread %ld", thread->id)); + keycache_pthread_cond_signal(&thread->suspend); next=thread->next; thread->next= NULL; } @@ -876,7 +892,8 @@ static void link_block(KEY_CACHE *keycache, BLOCK_LINK *block, my_bool hot, BLOCK_LINK **pins; KEYCACHE_DBUG_ASSERT(! (block->hash_link && block->hash_link->requests)); - if (!hot && keycache->waiting_for_block.last_thread) { + if (!hot && keycache->waiting_for_block.last_thread) + { /* Signal that in the LRU warm sub-chain an available block has appeared */ struct st_my_thread_var *last_thread= keycache->waiting_for_block.last_thread; @@ -894,6 +911,7 @@ static void link_block(KEY_CACHE *keycache, BLOCK_LINK *block, my_bool hot, */ if ((HASH_LINK *) thread->opt_info == hash_link) { + KEYCACHE_DBUG_PRINT("link_block: signal", ("thread %ld", thread->id)); keycache_pthread_cond_signal(&thread->suspend); unlink_from_queue(&keycache->waiting_for_block, thread); block->requests++; @@ -1000,11 +1018,10 @@ static void reg_requests(KEY_CACHE *keycache, BLOCK_LINK *block, int count) linking it to the LRU chain if it's the last request SYNOPSIS - - unreg_block() - keycache pointer to a key cache data structure - block pointer to the block to link to the LRU chain - at_end <-> to link the block at the end of the LRU chain + unreg_request() + keycache pointer to a key cache data structure + block pointer to the block to link to the LRU chain + at_end <-> to link the block at the end of the LRU chain RETURN VALUE none @@ -1086,6 +1103,9 @@ static inline void wait_for_readers(KEY_CACHE *keycache, BLOCK_LINK *block) struct st_my_thread_var *thread= my_thread_var; while (block->hash_link->requests) { + KEYCACHE_DBUG_PRINT("wait_for_readers: wait", + ("suspend thread %ld block %u", + thread->id, BLOCK_NUMBER(block))); block->condvar= &thread->suspend; keycache_pthread_cond_wait(&thread->suspend, &keycache->cache_lock); block->condvar= NULL; @@ -1143,6 +1163,7 @@ static void unlink_hash(KEY_CACHE *keycache, HASH_LINK *hash_link) */ if (page->file == hash_link->file && page->filepos == hash_link->diskpos) { + KEYCACHE_DBUG_PRINT("unlink_hash: signal", ("thread %ld", thread->id)); keycache_pthread_cond_signal(&thread->suspend); unlink_from_queue(&keycache->waiting_for_hash_link, thread); } @@ -1225,6 +1246,8 @@ restart: page.filepos= filepos; thread->opt_info= (void *) &page; link_into_queue(&keycache->waiting_for_hash_link, thread); + KEYCACHE_DBUG_PRINT("get_hash_link: wait", + ("suspend thread %ld", thread->id)); keycache_pthread_cond_wait(&thread->suspend, &keycache->cache_lock); thread->opt_info= NULL; @@ -1343,6 +1366,8 @@ restart: add_to_queue(&block->wqueue[COND_FOR_SAVED], thread); do { + KEYCACHE_DBUG_PRINT("find_key_block: wait", + ("suspend thread %ld", thread->id)); keycache_pthread_cond_wait(&thread->suspend, &keycache->cache_lock); } @@ -1360,7 +1385,9 @@ restart: /* This is a request for a page to be removed from cache */ KEYCACHE_DBUG_PRINT("find_key_block", - ("request for old page in block %u",BLOCK_NUMBER(block))); + ("request for old page in block %u " + "wrmode: %d block->status: %d", + BLOCK_NUMBER(block), wrmode, block->status)); /* Only reading requests can proceed until the old dirty page is flushed, all others are to be suspended, then resubmitted @@ -1379,6 +1406,8 @@ restart: /* Wait until the request can be resubmitted */ do { + KEYCACHE_DBUG_PRINT("find_key_block: wait", + ("suspend thread %ld", thread->id)); keycache_pthread_cond_wait(&thread->suspend, &keycache->cache_lock); } @@ -1448,6 +1477,8 @@ restart: link_into_queue(&keycache->waiting_for_block, thread); do { + KEYCACHE_DBUG_PRINT("find_key_block: wait", + ("suspend thread %ld", thread->id)); keycache_pthread_cond_wait(&thread->suspend, &keycache->cache_lock); } @@ -1528,9 +1559,13 @@ restart: else { /* This is for secondary requests for a new page only */ - page_status= block->hash_link == hash_link && - (block->status & BLOCK_READ) ? - PAGE_READ : PAGE_WAIT_TO_BE_READ; + KEYCACHE_DBUG_PRINT("find_key_block", + ("block->hash_link: %p hash_link: %p " + "block->status: %u", block->hash_link, + hash_link, block->status )); + page_status= (((block->hash_link == hash_link) && + (block->status & BLOCK_READ)) ? + PAGE_READ : PAGE_WAIT_TO_BE_READ); } } keycache->global_cache_read++; @@ -1538,17 +1573,22 @@ restart: else { reg_requests(keycache, block, 1); - page_status = block->hash_link == hash_link && - (block->status & BLOCK_READ) ? - PAGE_READ : PAGE_WAIT_TO_BE_READ; + KEYCACHE_DBUG_PRINT("find_key_block", + ("block->hash_link: %p hash_link: %p " + "block->status: %u", block->hash_link, + hash_link, block->status )); + page_status= (((block->hash_link == hash_link) && + (block->status & BLOCK_READ)) ? + PAGE_READ : PAGE_WAIT_TO_BE_READ); } } KEYCACHE_DBUG_ASSERT(page_status != -1); *page_st=page_status; KEYCACHE_DBUG_PRINT("find_key_block", - ("fd: %u pos %lu page_status %lu", - (uint) file,(ulong) filepos,(uint) page_status)); + ("fd: %u pos %lu block->status %u page_status %lu", + (uint) file, (ulong) filepos, block->status, + (uint) page_status)); #if !defined(DBUG_OFF) && defined(EXTRA_DEBUG) DBUG_EXECUTE("check_keycache2", @@ -1604,6 +1644,10 @@ static void read_block(KEY_CACHE *keycache, /* Page is not in buffer yet, is to be read from disk */ keycache_pthread_mutex_unlock(&keycache->cache_lock); + /* + Here other threads may step in and register as secondary readers. + They will register in block->wqueue[COND_FOR_REQUESTED]. + */ got_length= my_pread(block->hash_link->file, block->buffer, read_length, block->hash_link->diskpos, MYF(0)); keycache_pthread_mutex_lock(&keycache->cache_lock); @@ -1634,6 +1678,8 @@ static void read_block(KEY_CACHE *keycache, add_to_queue(&block->wqueue[COND_FOR_REQUESTED], thread); do { + KEYCACHE_DBUG_PRINT("read_block: wait", + ("suspend thread %ld", thread->id)); keycache_pthread_cond_wait(&thread->suspend, &keycache->cache_lock); } @@ -1855,6 +1901,10 @@ int key_cache_insert(KEY_CACHE *keycache, /* The requested page is to be read into the block buffer */ #if !defined(SERIALIZED_READ_FROM_CACHE) keycache_pthread_mutex_unlock(&keycache->cache_lock); + /* + Here other threads may step in and register as secondary readers. + They will register in block->wqueue[COND_FOR_REQUESTED]. + */ #endif /* Copy data from buff */ @@ -1865,9 +1915,15 @@ int key_cache_insert(KEY_CACHE *keycache, #if !defined(SERIALIZED_READ_FROM_CACHE) keycache_pthread_mutex_lock(&keycache->cache_lock); + /* Here we are alone again. */ #endif block->status= BLOCK_READ; block->length= read_length+offset; + KEYCACHE_DBUG_PRINT("key_cache_insert", + ("primary request: new page in cache")); + /* Signal that all pending requests for this now can be processed. */ + if (block->wqueue[COND_FOR_REQUESTED].last_thread) + release_queue(&block->wqueue[COND_FOR_REQUESTED]); } remove_reader(block); @@ -2074,9 +2130,16 @@ static void free_block(KEY_CACHE *keycache, BLOCK_LINK *block) { KEYCACHE_THREAD_TRACE("free block"); KEYCACHE_DBUG_PRINT("free_block", - ("block %u to be freed",BLOCK_NUMBER(block))); + ("block %u to be freed, hash_link %p", + BLOCK_NUMBER(block), block->hash_link)); if (block->hash_link) { + /* + While waiting for readers to finish, new readers might request the + block. But since we set block->status|= BLOCK_REASSIGNED, they + will wait on block->wqueue[COND_FOR_SAVED]. They must be signalled + later. + */ block->status|= BLOCK_REASSIGNED; wait_for_readers(keycache, block); unlink_hash(keycache, block->hash_link); @@ -2102,6 +2165,10 @@ static void free_block(KEY_CACHE *keycache, BLOCK_LINK *block) keycache->free_block_list= block; /* Keep track of the number of currently unused blocks. */ keycache->blocks_unused++; + + /* All pending requests for this page must be resubmitted. */ + if (block->wqueue[COND_FOR_SAVED].last_thread) + release_queue(&block->wqueue[COND_FOR_SAVED]); } @@ -2334,6 +2401,8 @@ restart: add_to_queue(&block->wqueue[COND_FOR_SAVED], thread); do { + KEYCACHE_DBUG_PRINT("flush_key_blocks_int: wait", + ("suspend thread %ld", thread->id)); keycache_pthread_cond_wait(&thread->suspend, &keycache->cache_lock); } @@ -2685,14 +2754,6 @@ static int keycache_pthread_cond_signal(pthread_cond_t *cond) } -static int keycache_pthread_cond_broadcast(pthread_cond_t *cond) -{ - int rc; - KEYCACHE_THREAD_TRACE("signal"); - rc= pthread_cond_broadcast(cond); - return rc; -} - #if defined(KEYCACHE_DEBUG_LOG) diff --git a/mysys/my_access.c b/mysys/my_access.c index 6a8887e42a6..28210bdfc7d 100644 --- a/mysys/my_access.c +++ b/mysys/my_access.c @@ -15,39 +15,107 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "mysys_priv.h" +#include #ifdef __WIN__ /* - * Check a file or path for accessability. - * - * SYNOPSIS - * file_access() - * pathpath to check - * amodemode to check - * - * DESCRIPTION - * This function wraps the normal access method because the access - * available in MSVCRT> +reports that filenames such as LPT1 and - * COM1 are valid (they are but should not be so for us). - * - * RETURN VALUES - * 0 ok - * -1 error - */ + Check a file or path for accessability. + + SYNOPSIS + file_access() + path Path to file + amode Access method + + DESCRIPTION + This function wraps the normal access method because the access + available in MSVCRT> +reports that filenames such as LPT1 and + COM1 are valid (they are but should not be so for us). + + RETURN VALUES + 0 ok + -1 error (We use -1 as my_access is mapped to access on other platforms) +*/ + int my_access(const char *path, int amode) { - WIN32_FILE_ATTRIBUTE_DATA fileinfo; - BOOL result; + WIN32_FILE_ATTRIBUTE_DATA fileinfo; + BOOL result; - result = GetFileAttributesEx(path, GetFileExInfoStandard, - &fileinfo); - if (! result) - return -1; - if ((fileinfo.dwFileAttributes & FILE_ATTRIBUTE_READONLY) && - (amode & 2)) - return -1; - return 0; + result= GetFileAttributesEx(path, GetFileExInfoStandard, &fileinfo); + if (! result || + (fileinfo.dwFileAttributes & FILE_ATTRIBUTE_READONLY) && (amode & W_OK)) + { + my_errno= errno= EACCES; + return -1; + } + return 0; } +#endif /* __WIN__ */ + +#if defined(MSDOS) || defined(__WIN__) || defined(__EMX__) + +/* + List of file names that causes problem on windows + + NOTE that one can also not have file names of type CON.TXT +*/ + +static const char *reserved_names[]= +{ + "CON", "PRN", "AUX", "NUL", "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", + "COM7", "COM8", "COM9", "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", + "LPT7", "LPT8", "LPT9", "CLOCK$", + NullS +}; + +#define MAX_RESERVED_NAME_LENGTH 6 + +/* + Check if a path will access a reserverd file name that may cause problems + + SYNOPSIS + check_if_legal_filename + path Path to file + + RETURN + 0 ok + 1 reserved file name +*/ + +int check_if_legal_filename(const char *path) +{ + const char *end; + const char **reserved_name; + DBUG_ENTER("check_if_legal_filename"); + + path+= dirname_length(path); /* To start of filename */ + if (!(end= strchr(path, FN_EXTCHAR))) + end= strend(path); + if (path == end || (uint) (path - end) > MAX_RESERVED_NAME_LENGTH) + DBUG_RETURN(0); /* Simplify inner loop */ + + for (reserved_name= reserved_names; *reserved_name; reserved_name++) + { + const char *name= path; + while (name != end) + { + if (my_toupper(&my_charset_latin1, *path) != + my_toupper(&my_charset_latin1, *name)) + break; + if (name++ == end) + DBUG_RETURN(1); /* Found wrong path */ + } + } + DBUG_RETURN(0); +} #endif + + +#ifdef OS2 +int check_if_legal_filename(const char *path) +{ + return 0; +} +#endif /* OS2 */ diff --git a/mysys/my_fopen.c b/mysys/my_fopen.c index 4310250bd0d..3c6f1b15384 100644 --- a/mysys/my_fopen.c +++ b/mysys/my_fopen.c @@ -39,13 +39,16 @@ FILE *my_fopen(const char *FileName, int Flags, myf MyFlags) very well */ #ifdef __WIN__ - if (! (Flags & O_CREAT) && my_access(FileName, F_OK)) - fd=0; + if (check_if_legal_filename(FileName)) + { + errno= EACCES; + fd= 0; + } else #endif { - make_ftype(type,Flags); - fd = fopen(FileName, type); + make_ftype(type,Flags); + fd = fopen(FileName, type); } if (fd != 0) diff --git a/mysys/my_open.c b/mysys/my_open.c index 7fc5282838f..69d63c49554 100644 --- a/mysys/my_open.c +++ b/mysys/my_open.c @@ -47,12 +47,15 @@ File my_open(const char *FileName, int Flags, myf MyFlags) FileName, Flags, MyFlags)); #if defined(MSDOS) || defined(__WIN__) || defined(__EMX__) || defined(OS2) /* - if we are not creating, then we need to use my_access to make - sure the file exists since Windows doesn't handle files like - "com1.sym" very well + Check that we don't try to open or create a file name that may + cause problems for us in the future (like PRN) */ - if (! (Flags & O_CREAT) && my_access(FileName, F_OK)) - return -1; + if (check_if_legal_filename(FileName)) + { + errno= EACCES; + DBUG_RETURN(my_register_filename(-1, FileName, FILE_BY_OPEN, + EE_FILENOTFOUND, MyFlags)); + } if (Flags & O_SHARE) fd = sopen((my_string) FileName, (Flags & ~O_SHARE) | O_BINARY, SH_DENYNO, MY_S_IREAD | MY_S_IWRITE); diff --git a/mysys/raid.cc b/mysys/raid.cc index 1d2e0cb01f0..a645c0109db 100644 --- a/mysys/raid.cc +++ b/mysys/raid.cc @@ -70,7 +70,9 @@ tonu@mysql.com & monty@mysql.com */ -#ifdef __GNUC__ +#include + +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/ndb/include/mgmapi/mgmapi.h b/ndb/include/mgmapi/mgmapi.h index dca88e4950e..018e554de7c 100644 --- a/ndb/include/mgmapi/mgmapi.h +++ b/ndb/include/mgmapi/mgmapi.h @@ -915,6 +915,8 @@ extern "C" { * @param backup_id Backup ID is returned from function. * @param reply Reply message. * @return -1 on error. + * @note backup_id will not be returned if + * wait_completed == 0 */ int ndb_mgm_start_backup(NdbMgmHandle handle, int wait_completed, unsigned int* backup_id, diff --git a/ndb/src/common/debugger/SignalLoggerManager.cpp b/ndb/src/common/debugger/SignalLoggerManager.cpp index 1f0bd8974e7..d8710d2058f 100644 --- a/ndb/src/common/debugger/SignalLoggerManager.cpp +++ b/ndb/src/common/debugger/SignalLoggerManager.cpp @@ -395,7 +395,7 @@ SignalLoggerManager::log(BlockNumber bno, const char * msg, ...) va_start(ap, msg); fprintf(outputStream, "%s: ", getBlockName(bno, "API")); vfprintf(outputStream, msg, ap); - fprintf(outputStream, "\n", msg); + fprintf(outputStream, "\n"); va_end(ap); } } diff --git a/ndb/src/common/util/File.cpp b/ndb/src/common/util/File.cpp index 937b8c0fa59..e514ad8e122 100644 --- a/ndb/src/common/util/File.cpp +++ b/ndb/src/common/util/File.cpp @@ -28,29 +28,9 @@ bool File_class::exists(const char* aFileName) { - bool rc = true; -#ifdef USE_MY_STAT_STRUCT - struct my_stat stmp; -#else - struct stat stmp; -#endif - if (my_stat(aFileName, &stmp, MYF(0)) != 0) - { - rc = false; - } - - /* - File f; - if (!f.open(aFileName, "r")) - { - rc = (errno == ENOENT ? false : true); - } - else - { - f.close(); - } - */ - return rc; + MY_STAT stmp; + + return (my_stat(aFileName, &stmp, MYF(0))!=NULL); } long diff --git a/ndb/src/kernel/blocks/dbtux/Dbtux.hpp b/ndb/src/kernel/blocks/dbtux/Dbtux.hpp index 5c12472a0f7..d4a44b9e641 100644 --- a/ndb/src/kernel/blocks/dbtux/Dbtux.hpp +++ b/ndb/src/kernel/blocks/dbtux/Dbtux.hpp @@ -342,7 +342,6 @@ private: * Complete metadata for one index. The array of attributes has * variable size. */ - struct DescEnt; friend struct DescEnt; struct DescEnt { DescHead m_descHead; diff --git a/ndb/src/mgmsrv/Services.cpp b/ndb/src/mgmsrv/Services.cpp index bbd3db1e734..1a5101702a0 100644 --- a/ndb/src/mgmsrv/Services.cpp +++ b/ndb/src/mgmsrv/Services.cpp @@ -671,7 +671,8 @@ MgmApiSession::startBackup(Parser::Context &, } else{ m_output->println("result: Ok"); - m_output->println("id: %d", backupId); + if (completed) + m_output->println("id: %d", backupId); } m_output->println(""); DBUG_VOID_RETURN; diff --git a/scripts/make_binary_distribution.sh b/scripts/make_binary_distribution.sh index ecfe9e8be88..064c5e63f40 100644 --- a/scripts/make_binary_distribution.sh +++ b/scripts/make_binary_distribution.sh @@ -80,9 +80,6 @@ if [ $BASE_SYSTEM != "netware" ] ; then fi for i in ChangeLog \ - Docs/manual.html \ - Docs/manual.txt \ - Docs/manual_toc.html \ Docs/mysql.info do if [ -f $i ] diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh index 9ec573737bd..3a06c4d1fb5 100644 --- a/scripts/mysqld_safe.sh +++ b/scripts/mysqld_safe.sh @@ -114,7 +114,7 @@ then MY_BASEDIR_VERSION=$MY_PWD # Where bin, share and data are ledir=$MY_BASEDIR_VERSION/bin # Where mysqld is DATADIR=$MY_BASEDIR_VERSION/data - if test -z "$defaults" + if test -z "$defaults" -a -r "$DATADIR/my.cnf" then defaults="--defaults-extra-file=$DATADIR/my.cnf" fi diff --git a/sql/examples/ha_archive.cc b/sql/examples/ha_archive.cc index 231031c9834..4f0cfb91d20 100644 --- a/sql/examples/ha_archive.cc +++ b/sql/examples/ha_archive.cc @@ -14,11 +14,13 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef __GNUC__ +#include + +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif -#include +#include "../mysql_priv.h" #ifdef HAVE_ARCHIVE_DB #include "ha_archive.h" @@ -600,7 +602,7 @@ int ha_archive::write_row(byte * buf) if (!delayed_insert || !bulk_insert) share->dirty= TRUE; - if (written != table->s->reclength) + if (written != (z_off_t)table->s->reclength) goto error; /* We should probably mark the table as damagaged if the record is written @@ -617,7 +619,7 @@ int ha_archive::write_row(byte * buf) { ((Field_blob*) table->field[*ptr])->get_ptr(&data_ptr); written= gzwrite(share->archive_write, data_ptr, (unsigned)size); - if (written != size) + if (written != (z_off_t)size) goto error; } } @@ -788,7 +790,7 @@ int ha_archive::rnd_pos(byte * buf, byte *pos) statistic_increment(table->in_use->status_var.ha_read_rnd_next_count, &LOCK_status); current_position= my_get_ptr(pos, ref_length); - z_off_t seek= gzseek(archive, current_position, SEEK_SET); + (void)gzseek(archive, current_position, SEEK_SET); DBUG_RETURN(get_row(archive, buf)); } diff --git a/sql/examples/ha_archive.h b/sql/examples/ha_archive.h index c68462be1ab..2f310d8c69b 100644 --- a/sql/examples/ha_archive.h +++ b/sql/examples/ha_archive.h @@ -61,7 +61,7 @@ public: ha_archive(TABLE *table): handler(table), delayed_insert(0), bulk_insert(0) { /* Set our original buffer from pre-allocated memory */ - buffer.set(byte_buffer, IO_SIZE, system_charset_info); + buffer.set((char *)byte_buffer, IO_SIZE, system_charset_info); /* The size of the offset value we will use for position() */ ref_length = sizeof(z_off_t); diff --git a/sql/examples/ha_example.cc b/sql/examples/ha_example.cc index 562b51878bf..66d1a801333 100644 --- a/sql/examples/ha_example.cc +++ b/sql/examples/ha_example.cc @@ -63,7 +63,9 @@ -Brian */ -#ifdef __GNUC__ +#include + +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif @@ -150,10 +152,8 @@ static EXAMPLE_SHARE *get_share(const char *table_name, TABLE *table) return share; -error2: - thr_lock_delete(&share->lock); - pthread_mutex_destroy(&share->mutex); error: + pthread_mutex_destroy(&share->mutex); pthread_mutex_unlock(&example_mutex); my_free((gptr) share, MYF(0)); diff --git a/sql/examples/ha_tina.cc b/sql/examples/ha_tina.cc index 9ac446587ec..6ca7f67ef66 100644 --- a/sql/examples/ha_tina.cc +++ b/sql/examples/ha_tina.cc @@ -20,10 +20,10 @@ First off, this is a play thing for me, there are a number of things wrong with it: *) It was designed for csv and therefor its performance is highly questionable. *) Indexes have not been implemented. This is because the files can be traded in - and out of the table directory without having to worry about rebuilding anything. + and out of the table directory without having to worry about rebuilding anything. *) NULLs and "" are treated equally (like a spreadsheet). *) There was in the beginning no point to anyone seeing this other then me, so there - is a good chance that I haven't quite documented it well. + is a good chance that I haven't quite documented it well. *) Less design, more "make it work" Now there are a few cool things with it: @@ -38,7 +38,9 @@ TODO: -Brian */ -#ifdef __GNUC__ +#include + +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif @@ -89,12 +91,12 @@ int get_mmap(TINA_SHARE *share, int write) { if (write) share->mapped_file= (byte *)mmap(NULL, share->file_stat.st_size, - PROT_READ|PROT_WRITE, MAP_SHARED, - share->data_file, 0); + PROT_READ|PROT_WRITE, MAP_SHARED, + share->data_file, 0); else share->mapped_file= (byte *)mmap(NULL, share->file_stat.st_size, - PROT_READ, MAP_PRIVATE, - share->data_file, 0); + PROT_READ, MAP_PRIVATE, + share->data_file, 0); if ((share->mapped_file ==(caddr_t)-1)) { /* @@ -144,9 +146,9 @@ static TINA_SHARE *get_share(const char *table_name, TABLE *table) { char data_file_name[FN_REFLEN]; if (!my_multi_malloc(MYF(MY_WME | MY_ZEROFILL), - &share, sizeof(*share), - &tmp_name, length+1, - NullS)) + &share, sizeof(*share), + &tmp_name, length+1, + NullS)) { pthread_mutex_unlock(&tina_mutex); return NULL; @@ -341,7 +343,6 @@ int ha_tina::find_current_row(byte *buf) for (Field **field=table->field ; *field ; field++) { - int x; buffer.length(0); mapped_ptr++; // Increment past the first quote for(;mapped_ptr != end_ptr; mapped_ptr++) @@ -745,29 +746,17 @@ int ha_tina::rnd_end() beginning so that we move the smallest amount of data possible. */ qsort(chain, (size_t)(chain_ptr - chain), sizeof(tina_set), (qsort_cmp)sort_set); - for (ptr= chain; ptr < chain_ptr; ptr++) - printf("Chain %d, %d\n", (int)ptr->begin, (int)ptr->end); for (ptr= chain; ptr < chain_ptr; ptr++) { - //memmove(share->mapped_file + ptr->begin, share->mapped_file - //+ ptr->end, length - (size_t)ptr->end); /* We peek a head to see if this is the last chain */ - printf("Delete %d, %d, %d\n", (int)ptr->begin, (int)ptr->end, (int)length); if (ptr+1 == chain_ptr) - { - printf("Shiftina(end) %d(%d) to %d\n", (int)ptr->end, (int)(length - (size_t)ptr->end), (int)ptr->begin); memmove(share->mapped_file + ptr->begin, share->mapped_file + ptr->end, length - (size_t)ptr->end); - } else - { - printf("Shifting %d(%d) to %d\n", (int)ptr->end, (int)((ptr++)->begin - (size_t)ptr->end), (int)ptr->begin); - memmove(share->mapped_file + ptr->begin, share->mapped_file + ptr->end, - (size_t)(ptr++)->begin - (size_t)ptr->end); - } + memmove((caddr_t)share->mapped_file + ptr->begin, (caddr_t)share->mapped_file + ptr->end, + (size_t)((ptr++)->begin - ptr->end)); length= length - (size_t)(ptr->end - ptr->begin); } - printf("Buffer %s\n",share->mapped_file); /* Truncate the file to the new size */ if (my_chsize(share->data_file, length, 0, MYF(MY_WME))) @@ -850,7 +839,7 @@ int ha_tina::create(const char *name, TABLE *table_arg, HA_CREATE_INFO *create_i DBUG_ENTER("ha_tina::create"); if ((create_file= my_create(fn_format(name_buff,name,"",".CSV",MY_REPLACE_EXT|MY_UNPACK_FILENAME),0, - O_RDWR | O_TRUNC,MYF(MY_WME))) < 0) + O_RDWR | O_TRUNC,MYF(MY_WME))) < 0) DBUG_RETURN(-1); my_close(create_file,MYF(0)); diff --git a/sql/field.cc b/sql/field.cc index 54ed4044de5..720aca13ad4 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -19,7 +19,9 @@ ** This file implements classes defined in field.h *****************************************************************************/ -#ifdef __GNUC__ +#include + +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/field.h b/sql/field.h index f68a2327dff..d58746b6068 100644 --- a/sql/field.h +++ b/sql/field.h @@ -439,10 +439,12 @@ public: /* The maximum number of decimal digits can be stored */ uint precision; uint bin_size; - /* Constructors take max_length of the field as a parameter - not the */ - /* precision as the number of decimal digits allowed */ - /* So for example we need to count length from precision handling */ - /* CREATE TABLE ( DECIMAL(x,y)) */ + /* + Constructors take max_length of the field as a parameter - not the + precision as the number of decimal digits allowed. + So for example we need to count length from precision handling + CREATE TABLE ( DECIMAL(x,y)) + */ Field_new_decimal(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, uchar null_bit_arg, enum utype unireg_check_arg, const char *field_name_arg, diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc index 725674946ee..46f510bb905 100644 --- a/sql/ha_berkeley.cc +++ b/sql/ha_berkeley.cc @@ -47,7 +47,9 @@ */ -#ifdef __GNUC__ +#include + +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/ha_blackhole.cc b/sql/ha_blackhole.cc index dcc542a7247..00128d3d3b6 100644 --- a/sql/ha_blackhole.cc +++ b/sql/ha_blackhole.cc @@ -15,7 +15,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef __GNUC__ +#include + +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/ha_federated.cc b/sql/ha_federated.cc index 8cb6dcb7285..c76034c7986 100644 --- a/sql/ha_federated.cc +++ b/sql/ha_federated.cc @@ -1526,6 +1526,12 @@ int ha_federated::index_read_idx(byte *buf, uint index, const byte *key, table->status= STATUS_NOT_FOUND; DBUG_RETURN(mysql_errno(mysql)); } + /* + This basically says that the record in table->record[0] is legal, and that it is + ok to use this record, for whatever reason, such as with a join (without it, joins + will not work) + */ + table->status=0; DBUG_RETURN(rnd_next(buf)); } diff --git a/sql/ha_heap.cc b/sql/ha_heap.cc index e3212b095cf..3581b26a585 100644 --- a/sql/ha_heap.cc +++ b/sql/ha_heap.cc @@ -15,7 +15,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef __GNUC__ +#include + +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 381c9c28a79..1703a405035 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -27,7 +27,9 @@ have disables the InnoDB inlining in this file. */ in Windows? */ -#ifdef __GNUC__ +#include + +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif @@ -5764,7 +5766,12 @@ MySQL calls this function at the start of each SQL statement inside LOCK TABLES. Inside LOCK TABLES the ::external_lock method does not work to mark SQL statement borders. Note also a special case: if a temporary table is created inside LOCK TABLES, MySQL has not called external_lock() at all -on that table. */ +on that table. +MySQL-5.0 also calls this before each statement in an execution of a stored +procedure. To make the execution more deterministic for binlogging, MySQL-5.0 +locks all tables involved in a stored procedure with full explicit table +locks (thd->in_lock_tables is true in ::store_lock()) before executing the +procedure. */ int ha_innobase::start_stmt( @@ -6443,10 +6450,8 @@ ha_innobase::store_lock( if (srv_locks_unsafe_for_binlog && prebuilt->trx->isolation_level != TRX_ISO_SERIALIZABLE && (lock_type == TL_READ || lock_type == TL_READ_NO_INSERT) && - thd->lex->sql_command != SQLCOM_SELECT && - thd->lex->sql_command != SQLCOM_UPDATE_MULTI && - thd->lex->sql_command != SQLCOM_DELETE_MULTI && - thd->lex->sql_command != SQLCOM_LOCK_TABLES) { + (thd->lex->sql_command == SQLCOM_INSERT_SELECT || + thd->lex->sql_command == SQLCOM_UPDATE)) { /* In case we have innobase_locks_unsafe_for_binlog option set and isolation level of the transaction @@ -6479,7 +6484,8 @@ ha_innobase::store_lock( if ((lock_type >= TL_WRITE_CONCURRENT_INSERT && lock_type <= TL_WRITE) && !thd->in_lock_tables && !thd->tablespace_op - && thd->lex->sql_command != SQLCOM_TRUNCATE) { + && thd->lex->sql_command != SQLCOM_TRUNCATE + && thd->lex->sql_command != SQLCOM_CREATE_TABLE) { lock_type = TL_WRITE_ALLOW_WRITE; } diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc index 2049efb73db..3b17512c6c2 100644 --- a/sql/ha_myisam.cc +++ b/sql/ha_myisam.cc @@ -15,7 +15,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef __GNUC__ +#include + +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/ha_myisammrg.cc b/sql/ha_myisammrg.cc index f7c0abf9810..d4dc365a163 100644 --- a/sql/ha_myisammrg.cc +++ b/sql/ha_myisammrg.cc @@ -15,7 +15,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef __GNUC__ +#include + +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 65e16dcb539..4785bf7bd49 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -20,7 +20,9 @@ NDB Cluster */ -#ifdef __GNUC__ +#include + +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/handler.cc b/sql/handler.cc index b2ab2003165..ffd6fbc5916 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -17,7 +17,9 @@ /* Handler-calling-functions */ -#ifdef __GNUC__ +#include + +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/hash_filo.cc b/sql/hash_filo.cc index b85f8054f10..34f3cd6b035 100644 --- a/sql/hash_filo.cc +++ b/sql/hash_filo.cc @@ -20,7 +20,9 @@ ** to usage. */ -#ifdef __GNUC__ +#include + +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/hash_filo.h b/sql/hash_filo.h index d1672e1a60c..fc48c3b1540 100644 --- a/sql/hash_filo.h +++ b/sql/hash_filo.h @@ -23,7 +23,7 @@ #ifndef HASH_FILO_H #define HASH_FILO_H -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class interface */ #endif diff --git a/sql/item.cc b/sql/item.cc index a28cc261b3c..0db9a56055f 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -15,7 +15,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef __GNUC__ +#include + +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif @@ -297,6 +299,22 @@ longlong Item::val_int_from_decimal() } +void *Item::operator new(size_t size, Item *reuse, uint *rsize) +{ + if (reuse && size <= reuse->rsize) + { + if (rsize) + (*rsize)= reuse->rsize; + reuse->cleanup(); + TRASH((void *)reuse, size); + return (void *)reuse; + } + if (rsize) + (*rsize)= size; + return (void *)sql_alloc((uint)size); +} + + Item::Item(): rsize(0), name(0), orig_name(0), name_length(0), fixed(0), collation(&my_charset_bin, DERIVATION_COERCIBLE) @@ -3684,6 +3702,7 @@ Item_hex_string::Item_hex_string(const char *str, uint str_length) *ptr=0; // Keep purify happy collation.set(&my_charset_bin, DERIVATION_COERCIBLE); fixed= 1; + unsigned_flag= 1; } longlong Item_hex_string::val_int() @@ -4341,7 +4360,7 @@ bool Item_ref::get_date(TIME *ltime,uint fuzzydate) my_decimal *Item_ref::val_decimal(my_decimal *decimal_value) { - my_decimal *val= (*ref)->val_decimal(decimal_value); + my_decimal *val= (*ref)->val_decimal_result(decimal_value); null_value= (*ref)->null_value; return val; } @@ -4554,40 +4573,40 @@ void Item_insert_value::print(String *str) /* - Bind item representing field of row being changed in trigger - to appropriate Field object. + Find index of Field object which will be appropriate for item + representing field of row being changed in trigger. SYNOPSIS setup_field() thd - current thread context table - table of trigger (and where we looking for fields) - event - type of trigger event NOTE This function does almost the same as fix_fields() for Item_field - but is invoked during trigger definition parsing and takes TABLE - object as its argument. If proper field was not found in table - error will be reported at fix_fields() time. + but is invoked right after trigger definition parsing. Since at + this stage we can't say exactly what Field object (corresponding + to TABLE::record[0] or TABLE::record[1]) should be bound to this + Item, we only find out index of the Field and then select concrete + Field object in fix_fields() (by that time Table_trigger_list::old_field/ + new_field should point to proper array of Fields). + It also binds Item_trigger_field to Table_triggers_list object for + table of trigger which uses this item. */ -void Item_trigger_field::setup_field(THD *thd, TABLE *table, - enum trg_event_type event) + +void Item_trigger_field::setup_field(THD *thd, TABLE *table) { - uint field_idx= (uint)-1; bool save_set_query_id= thd->set_query_id; /* TODO: Think more about consequences of this step. */ thd->set_query_id= 0; - - if (find_field_in_real_table(thd, table, field_name, - strlen(field_name), 0, 0, - &field_idx)) - { - field= (row_version == OLD_ROW && event == TRG_EVENT_UPDATE) ? - table->triggers->old_field[field_idx] : - table->field[field_idx]; - } - + /* + Try to find field by its name and if it will be found + set field_idx properly. + */ + (void)find_field_in_real_table(thd, table, field_name, strlen(field_name), + 0, 0, &field_idx); thd->set_query_id= save_set_query_id; + triggers= table->triggers; } @@ -4612,9 +4631,10 @@ bool Item_trigger_field::fix_fields(THD *thd, */ DBUG_ASSERT(fixed == 0); - if (field) + if (field_idx != (uint)-1) { - // QQ: May be this should be moved to setup_field? + field= (row_version == OLD_ROW) ? triggers->old_field[field_idx] : + triggers->new_field[field_idx]; set_field(field); fixed= 1; return 0; diff --git a/sql/item.h b/sql/item.h index 18a81dcaa03..f2e8e582780 100644 --- a/sql/item.h +++ b/sql/item.h @@ -233,20 +233,7 @@ public: static void *operator new(size_t size, MEM_ROOT *mem_root) { return (void*) alloc_root(mem_root, (uint) size); } /* Special for SP local variable assignment - reusing slots */ - static void *operator new(size_t size, Item *reuse, uint *rsize) - { - if (reuse && size <= reuse->rsize) - { - reuse->cleanup(); - TRASH((void *)reuse, size); - if (rsize) - (*rsize)= reuse->rsize; - return (void *)reuse; - } - if (rsize) - (*rsize)= size; - return (void *)sql_alloc((uint)size); - } + static void *operator new(size_t size, Item *reuse, uint *rsize); static void operator delete(void *ptr,size_t size) { TRASH(ptr, size); } static void operator delete(void *ptr, MEM_ROOT *mem_root) {} @@ -597,6 +584,13 @@ public: Item::maybe_null= TRUE; } + /* For error printing */ + inline void my_name(char **strp, uint *lengthp) + { + *strp= m_name.str; + *lengthp= m_name.length; + } + bool is_splocal() { return 1; } /* Needed for error checking */ Item *this_item(); @@ -1632,13 +1626,18 @@ enum trg_event_type TRG_EVENT_INSERT= 0 , TRG_EVENT_UPDATE= 1, TRG_EVENT_DELETE= 2 }; +class Table_triggers_list; + /* Represents NEW/OLD version of field of row which is changed/read in trigger. - Note: For this item actual binding to Field object happens not during - fix_fields() (like for Item_field) but during parsing of trigger - definition, when table is opened, with special setup_field() call. + Note: For this item main part of actual binding to Field object happens + not during fix_fields() call (like for Item_field) but right after + parsing of trigger definition, when table is opened, with special + setup_field() call. On fix_fields() stage we simply choose one of + two Field instances representing either OLD or NEW version of this + field. */ class Item_trigger_field : public Item_field { @@ -1648,13 +1647,17 @@ public: row_version_type row_version; /* Next in list of all Item_trigger_field's in trigger */ Item_trigger_field *next_trg_field; + /* Index of the field in the TABLE::field array */ + uint field_idx; + /* Pointer to Table_trigger_list object for table of this trigger */ + Table_triggers_list *triggers; Item_trigger_field(row_version_type row_ver_par, const char *field_name_par): Item_field((const char *)NULL, (const char *)NULL, field_name_par), - row_version(row_ver_par) + row_version(row_ver_par), field_idx((uint)-1) {} - void setup_field(THD *thd, TABLE *table, enum trg_event_type event); + void setup_field(THD *thd, TABLE *table); enum Type type() const { return TRIGGER_FIELD_ITEM; } bool eq(const Item *item, bool binary_cmp) const; bool fix_fields(THD *, struct st_table_list *, Item **); diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 89897a9d74f..eb0dddd3e28 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -17,7 +17,9 @@ /* This file defines all compare functions */ -#ifdef __GNUC__ +#include + +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif @@ -1225,9 +1227,16 @@ Item_func_if::fix_length_and_dec() { maybe_null=args[1]->maybe_null || args[2]->maybe_null; decimals= max(args[1]->decimals, args[2]->decimals); - max_length= (max(args[1]->max_length - args[1]->decimals, + if (decimals == NOT_FIXED_DEC) + { + max_length= max(args[1]->max_length, args[2]->max_length); + } + else + { + max_length= (max(args[1]->max_length - args[1]->decimals, args[2]->max_length - args[2]->decimals) + decimals); + } enum Item_result arg1_type=args[1]->result_type(); enum Item_result arg2_type=args[2]->result_type(); bool null1=args[1]->const_item() && args[1]->null_value; @@ -2321,7 +2330,7 @@ Item_cond::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) */ and_tables_cache= ~(table_map) 0; - if (check_stack_overrun(thd, buff)) + if (check_stack_overrun(thd, STACK_MIN_SIZE, buff)) return TRUE; // Fatal error flag is set! /* The following optimization reduces the depth of an AND-OR tree. diff --git a/sql/item_func.cc b/sql/item_func.cc index db2aa735b0e..92c51553644 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -17,7 +17,9 @@ /* This file defines all numerical functions */ -#ifdef __GNUC__ +#include + +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif @@ -300,7 +302,7 @@ Item_func::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) used_tables_cache= not_null_tables_cache= 0; const_item_cache=1; - if (check_stack_overrun(thd, buff)) + if (check_stack_overrun(thd, STACK_MIN_SIZE, buff)) return TRUE; // Fatal error if flag is set! if (arg_count) { // Print purify happy @@ -2322,11 +2324,15 @@ void Item_func_locate::print(String *str) longlong Item_func_field::val_int() { DBUG_ASSERT(fixed == 1); + + if (args[0]->is_null()) + return 0; + if (cmp_type == STRING_RESULT) { String *field; - if (!(field=args[0]->val_str(&value))) - return 0; // -1 if null ? + if (!(field= args[0]->val_str(&value))) + return 0; for (uint i=1 ; i < arg_count ; i++) { String *tmp_value=args[i]->val_str(&tmp); @@ -2337,20 +2343,16 @@ longlong Item_func_field::val_int() else if (cmp_type == INT_RESULT) { longlong val= args[0]->val_int(); - if (args[0]->is_null()) - return 0; for (uint i=1; i < arg_count ; i++) { - if (val == args[i]->val_int() && ! args[i]->is_null()) - return (longlong) (i); + if (!args[i]->is_null() && val == args[i]->val_int()) + return (longlong) (i); } } else if (cmp_type == DECIMAL_RESULT) { my_decimal dec_arg_buf, *dec_arg, dec_buf, *dec= args[0]->val_decimal(&dec_buf); - if (args[0]->is_null()) - return 0; for (uint i=1; i < arg_count; i++) { dec_arg= args[i]->val_decimal(&dec_arg_buf); @@ -2361,12 +2363,10 @@ longlong Item_func_field::val_int() else { double val= args[0]->val_real(); - if (args[0]->is_null()) - return 0; for (uint i=1; i < arg_count ; i++) { - if (val == args[i]->val_real() && ! args[i]->is_null()) - return (longlong) (i); + if (!args[i]->is_null() && val == args[i]->val_real()) + return (longlong) (i); } } return 0; @@ -2572,7 +2572,7 @@ udf_handler::fix_fields(THD *thd, TABLE_LIST *tables, Item_result_field *func, #endif DBUG_ENTER("Item_udf_func::fix_fields"); - if (check_stack_overrun(thd, buff)) + if (check_stack_overrun(thd, STACK_MIN_SIZE, buff)) DBUG_RETURN(TRUE); // Fatal error flag is set! udf_func *tmp_udf=find_udf(u_d->name.str,(uint) u_d->name.length,1); @@ -3603,7 +3603,7 @@ longlong user_var_entry::val_int(my_bool *null_value) case DECIMAL_RESULT: { longlong result; - my_decimal2int(E_DEC_FATAL_ERROR, (my_decimal *)value, 1, &result); + my_decimal2int(E_DEC_FATAL_ERROR, (my_decimal *)value, 0, &result); return result; } case STRING_RESULT: @@ -4509,7 +4509,7 @@ Item *get_system_var(THD *thd, enum_var_type var_type, LEX_STRING name, !my_strcasecmp(system_charset_info, name.str, "VERSION")) return new Item_string("@@VERSION", server_version, (uint) strlen(server_version), - system_charset_info); + system_charset_info, DERIVATION_SYSCONST); Item *item; sys_var *var; diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc index b9f2ec8a6ca..3173994f90f 100644 --- a/sql/item_geofunc.cc +++ b/sql/item_geofunc.cc @@ -17,7 +17,9 @@ /* This file defines all spatial functions */ -#ifdef __GNUC__ +#include + +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 857140dba8f..4808159fe98 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -20,7 +20,9 @@ ** (This shouldn't be needed) */ -#ifdef __GNUC__ +#include + +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 0fbcf32a83c..b7aefdd6f2e 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -22,7 +22,9 @@ SUBSELECT TODO: (sql_select.h/sql_select.cc) */ -#ifdef __GNUC__ +#include + +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif @@ -138,7 +140,7 @@ bool Item_subselect::fix_fields(THD *thd_param, TABLE_LIST *tables, Item **ref) DBUG_ASSERT(fixed == 0); engine->set_thd((thd= thd_param)); - if (check_stack_overrun(thd, (gptr)&res)) + if (check_stack_overrun(thd, STACK_MIN_SIZE, (gptr)&res)) return TRUE; res= engine->prepare(); @@ -384,9 +386,6 @@ Item_singlerow_subselect::select_transformer(JOIN *join) return RES_REDUCE; } return RES_OK; - -err: - return RES_ERROR; } @@ -537,8 +536,6 @@ Item_exists_subselect::Item_exists_subselect(st_select_lex *select_lex): null_value= 0; //can't be NULL maybe_null= 0; //can't be NULL value= 0; - // We need only 1 row to determinate existence - select_lex->master_unit()->global_parameters->select_limit= 1; DBUG_VOID_RETURN; } @@ -605,6 +602,8 @@ void Item_exists_subselect::fix_length_and_dec() decimals= 0; max_length= 1; max_columns= engine->cols(); + /* We need only 1 row to determinate existence */ + unit->global_parameters->select_limit= 1; } double Item_exists_subselect::val_real() @@ -854,9 +853,6 @@ Item_in_subselect::single_value_transformer(JOIN *join, else { Item_maxmin_subselect *item; - // remove LIMIT placed by ALL/ANY subquery - select_lex->master_unit()->global_parameters->select_limit= - HA_POS_ERROR; subs= item= new Item_maxmin_subselect(thd, this, select_lex, func->l_op()); if (upper_item) upper_item->set_sub_test(item); @@ -1286,13 +1282,10 @@ subselect_single_select_engine(st_select_lex *select, select_subselect *result, Item_subselect *item) :subselect_engine(item, result), - prepared(0), optimized(0), executed(0), join(0) + prepared(0), optimized(0), executed(0), + select_lex(select), join(0) { - select_lex= select; - SELECT_LEX_UNIT *unit= select_lex->master_unit(); - unit->set_limit(unit->global_parameters, select_lex); - unit->item= item; - this->select_lex= select_lex; + select_lex->master_unit()->item= item; } @@ -1440,7 +1433,10 @@ int subselect_single_select_engine::exec() thd->lex->current_select= select_lex; if (!optimized) { - optimized=1; + SELECT_LEX_UNIT *unit= select_lex->master_unit(); + + optimized= 1; + unit->set_limit(unit->global_parameters); if (join->optimize()) { thd->where= save_where; diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 85abb09531b..af3828ab2c6 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -17,7 +17,9 @@ /* Sum functions (COUNT, MIN...) */ -#ifdef __GNUC__ +#include + +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 7a9c7898856..0f2c9a2907d 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -17,7 +17,9 @@ /* This file defines all time functions */ -#ifdef __GNUC__ +#include + +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/item_uniq.cc b/sql/item_uniq.cc index c1a19d71d04..f6cf83ebb10 100644 --- a/sql/item_uniq.cc +++ b/sql/item_uniq.cc @@ -15,7 +15,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* Compability file */ -#ifdef __GNUC__ + +#include + +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation #endif diff --git a/sql/item_uniq.h b/sql/item_uniq.h index 602474f7581..14b2e8d53bb 100644 --- a/sql/item_uniq.h +++ b/sql/item_uniq.h @@ -16,7 +16,7 @@ /* Compability file ; This file only contains dummy functions */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface #endif diff --git a/sql/lock.cc b/sql/lock.cc index 83a39005cd8..e0a75a42661 100644 --- a/sql/lock.cc +++ b/sql/lock.cc @@ -82,8 +82,24 @@ static int unlock_external(THD *thd, TABLE **table,uint count); static void print_lock_error(int error, const char *); -MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count, - bool ignore_global_read_lock) +/* + Lock tables. + + SYNOPSIS + mysql_lock_tables() + thd The current thread. + tables An array of pointers to the tables to lock. + count The number of tables to lock. + flags Options: + MYSQL_LOCK_IGNORE_GLOBAL_READ_LOCK Ignore a global read lock + MYSQL_LOCK_IGNORE_FLUSH Ignore a flush tables. + + RETURN + A lock structure pointer on success. + NULL on error. +*/ + +MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count, uint flags) { MYSQL_LOCK *sql_lock; TABLE *write_lock_used; @@ -94,7 +110,8 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count, if (!(sql_lock = get_lock_data(thd,tables,count, 0,&write_lock_used))) break; - if (global_read_lock && write_lock_used && ! ignore_global_read_lock) + if (global_read_lock && write_lock_used && + ! (flags & MYSQL_LOCK_IGNORE_GLOBAL_READ_LOCK)) { /* Someone has issued LOCK ALL TABLES FOR READ and we want a write lock @@ -128,7 +145,7 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count, thd->some_tables_deleted=1; // Try again sql_lock->lock_count=0; // Locks are alread freed } - else if (!thd->some_tables_deleted) + else if (!thd->some_tables_deleted || (flags & MYSQL_LOCK_IGNORE_FLUSH)) { thd->locked=0; break; @@ -951,48 +968,3 @@ bool make_global_read_lock_block_commit(THD *thd) } - -/* - Set protection against global read lock. - - SYNOPSIS - set_protect_against_global_read_lock() - void - - RETURN - FALSE OK, no global read lock exists. - TRUE Error, global read lock exists already. -*/ - -bool set_protect_against_global_read_lock(void) -{ - bool global_read_lock_exists; - - pthread_mutex_lock(&LOCK_open); - if (! (global_read_lock_exists= test(global_read_lock))) - protect_against_global_read_lock++; - pthread_mutex_unlock(&LOCK_open); - return global_read_lock_exists; -} - - -/* - Unset protection against global read lock. - - SYNOPSIS - unset_protect_against_global_read_lock() - void - - RETURN - void -*/ - -void unset_protect_against_global_read_lock(void) -{ - pthread_mutex_lock(&LOCK_open); - protect_against_global_read_lock--; - pthread_mutex_unlock(&LOCK_open); - pthread_cond_broadcast(&COND_refresh); -} - - diff --git a/sql/log.cc b/sql/log.cc index 91428cf41be..db592649d13 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -232,7 +232,8 @@ File open_binlog(IO_CACHE *log, const char *log_file_name, const char **errmsg) File file; DBUG_ENTER("open_binlog"); - if ((file = my_open(log_file_name, O_RDONLY | O_BINARY, MYF(MY_WME))) < 0) + if ((file = my_open(log_file_name, O_RDONLY | O_BINARY | O_SHARE, + MYF(MY_WME))) < 0) { sql_print_error("Failed to open log (file '%s', errno %d)", log_file_name, my_errno); diff --git a/sql/log_event.cc b/sql/log_event.cc index 42134d2b990..d4225b39704 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -16,7 +16,10 @@ #ifndef MYSQL_CLIENT -#ifdef __GNUC__ + +#include + +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif #include "mysql_priv.h" diff --git a/sql/log_event.h b/sql/log_event.h index f8989c4994a..b163a37e7cc 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -22,7 +22,7 @@ #undef write // remove pthread.h macro definition, conflict with write() class member #endif -#if defined(__GNUC__) && !defined(MYSQL_CLIENT) +#if defined(USE_PRAGMA_INTERFACE) && !defined(MYSQL_CLIENT) #pragma interface /* gcc class implementation */ #endif diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 645e835d9ca..7adb175ed1b 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -884,8 +884,7 @@ bool insert_fields(THD *thd,TABLE_LIST *tables, List_iterator *it, bool any_privileges, bool allocate_view_names); bool setup_tables(THD *thd, TABLE_LIST *tables, Item **conds, - TABLE_LIST **leaves, bool refresh_only, - bool select_insert); + TABLE_LIST **leaves, bool select_insert); int setup_wild(THD *thd, TABLE_LIST *tables, List &fields, List *sum_func_list, uint wild_num); bool setup_fields(THD *thd, Item** ref_pointer_array, TABLE_LIST *tables, @@ -924,10 +923,18 @@ bool remove_table_from_cache(THD *thd, const char *db, const char *table, bool return_if_owned_by_thd); bool close_cached_tables(THD *thd, bool wait_for_refresh, TABLE_LIST *tables); void copy_field_from_tmp_record(Field *field,int offset); -bool fill_record(THD *thd, List &fields, List &values, - bool ignore_errors); bool fill_record(THD *thd, Field **field, List &values, bool ignore_errors); +bool fill_record_n_invoke_before_triggers(THD *thd, List &fields, + List &values, + bool ignore_errors, + Table_triggers_list *triggers, + enum trg_event_type event); +bool fill_record_n_invoke_before_triggers(THD *thd, Field **field, + List &values, + bool ignore_errors, + Table_triggers_list *triggers, + enum trg_event_type event); OPEN_TABLE_LIST *list_open_tables(THD *thd, const char *wild); inline TABLE_LIST *find_table_in_global_list(TABLE_LIST *table, @@ -1051,7 +1058,6 @@ extern char language[FN_REFLEN], reg_ext[FN_EXTLEN]; extern char glob_hostname[FN_REFLEN], mysql_home[FN_REFLEN]; extern char pidfile_name[FN_REFLEN], system_time_zone[30], *opt_init_file; extern char log_error_file[FN_REFLEN], *opt_tc_log_file; -extern double last_query_cost; extern double log_10[32]; extern ulonglong log_10_int[20]; extern ulonglong keybuff_size; @@ -1070,7 +1076,7 @@ extern ulong max_connections,max_connect_errors, connect_timeout; extern ulong slave_net_timeout, slave_trans_retries; extern uint max_user_connections; extern ulong what_to_log,flush_time; -extern ulong query_buff_size, thread_stack,thread_stack_min; +extern ulong query_buff_size, thread_stack; extern ulong binlog_cache_size, max_binlog_cache_size, open_files_limit; extern ulong max_binlog_size, max_relay_log_size; extern ulong rpl_recovery_rank, thread_cache_size; @@ -1095,7 +1101,7 @@ extern my_bool opt_slave_compressed_protocol, use_temp_pool; extern my_bool opt_readonly, lower_case_file_system; extern my_bool opt_enable_named_pipe, opt_sync_frm, opt_allow_suspicious_udfs; extern my_bool opt_secure_auth; -extern my_bool sp_automatic_privileges; +extern my_bool sp_automatic_privileges, opt_noacl; extern my_bool opt_old_style_user_limits, trust_routine_creators; extern uint opt_crash_binlog_innodb; extern char *shared_memory_base_name, *mysqld_unix_port; @@ -1160,8 +1166,11 @@ extern pthread_t signal_thread; extern struct st_VioSSLAcceptorFd * ssl_acceptor_fd; #endif /* HAVE_OPENSSL */ -MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **table, uint count, - bool ignore_global_read_lock= FALSE); +MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **table, uint count, uint flags); +/* mysql_lock_tables() flags bits */ +#define MYSQL_LOCK_IGNORE_GLOBAL_READ_LOCK 0x0001 +#define MYSQL_LOCK_IGNORE_FLUSH 0x0002 + void mysql_unlock_tables(THD *thd, MYSQL_LOCK *sql_lock); void mysql_unlock_read_tables(THD *thd, MYSQL_LOCK *sql_lock); void mysql_unlock_some_tables(THD *thd, TABLE **table,uint count); @@ -1422,11 +1431,11 @@ inline int hexchar_to_int(char c) #ifndef EMBEDDED_LIBRARY extern "C" void unireg_abort(int exit_code); void kill_delayed_threads(void); -bool check_stack_overrun(THD *thd,char *dummy); +bool check_stack_overrun(THD *thd, long margin, char *dummy); #else #define unireg_abort(exit_code) DBUG_RETURN(exit_code) inline void kill_delayed_threads(void) {} -#define check_stack_overrun(A, B) 0 +#define check_stack_overrun(A, B, C) 0 #endif #endif /* MYSQL_CLIENT */ diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 8c5ce22f7a6..6625696c911 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -336,6 +336,7 @@ my_bool opt_old_style_user_limits= 0, trust_routine_creators= 0; changed). False otherwise. */ volatile bool mqh_used = 0; +my_bool opt_noacl; my_bool sp_automatic_privileges= 1; #ifdef HAVE_INITGROUPS @@ -348,7 +349,7 @@ uint tc_heuristic_recover= 0; uint volatile thread_count, thread_running; ulong back_log, connect_timeout, concurrency; ulong server_id, thd_startup_options; -ulong table_cache_size, thread_stack, thread_stack_min, what_to_log; +ulong table_cache_size, thread_stack, what_to_log; ulong query_buff_size, slow_launch_time, slave_open_temp_tables; ulong open_files_limit, max_binlog_size, max_relay_log_size; ulong slave_net_timeout, slave_trans_retries; @@ -368,7 +369,6 @@ ulong thread_id=1L,current_pid; ulong slow_launch_threads = 0, sync_binlog_period; ulong expire_logs_days = 0; ulong rpl_recovery_rank=0; -double last_query_cost= -1; /* -1 denotes that no query was compiled yet */ double log_10[32]; /* 10 potences */ time_t start_time; @@ -460,7 +460,7 @@ char *master_ssl_ca, *master_ssl_capath, *master_ssl_cipher; /* Static variables */ static bool kill_in_progress, segfaulted; -static my_bool opt_do_pstack, opt_noacl, opt_bootstrap, opt_myisam_log; +static my_bool opt_do_pstack, opt_bootstrap, opt_myisam_log; static int cleanup_done; static ulong opt_specialflag, opt_myisam_block_size; static char *opt_logname, *opt_update_logname, *opt_binlog_index_name; @@ -2090,7 +2090,15 @@ static void start_signal_handler(void) (void) pthread_attr_setdetachstate(&thr_attr,PTHREAD_CREATE_DETACHED); if (!(opt_specialflag & SPECIAL_NO_PRIOR)) my_pthread_attr_setprio(&thr_attr,INTERRUPT_PRIOR); +#if defined(__ia64__) || defined(__ia64) + /* + Peculiar things with ia64 platforms - it seems we only have half the + stack size in reality, so we have to double it here + */ + pthread_attr_setstacksize(&thr_attr,thread_stack*2); +#else pthread_attr_setstacksize(&thr_attr,thread_stack); +#endif #endif (void) pthread_mutex_lock(&LOCK_thread_count); @@ -3011,23 +3019,37 @@ int main(int argc, char **argv) init_signals(); if (!(opt_specialflag & SPECIAL_NO_PRIOR)) my_pthread_setprio(pthread_self(),CONNECT_PRIOR); +#if defined(__ia64__) || defined(__ia64) + /* + Peculiar things with ia64 platforms - it seems we only have half the + stack size in reality, so we have to double it here + */ + pthread_attr_setstacksize(&connection_attrib,thread_stack*2); +#else pthread_attr_setstacksize(&connection_attrib,thread_stack); +#endif #ifdef HAVE_PTHREAD_ATTR_GETSTACKSIZE { /* Retrieve used stack size; Needed for checking stack overflows */ size_t stack_size= 0; pthread_attr_getstacksize(&connection_attrib, &stack_size); +#if defined(__ia64__) || defined(__ia64) + stack_size/= 2; +#endif /* We must check if stack_size = 0 as Solaris 2.9 can return 0 here */ if (stack_size && stack_size < thread_stack) { if (global_system_variables.log_warnings) sql_print_warning("Asked for %ld thread stack, but got %ld", - thread_stack, stack_size); + thread_stack, stack_size); +#if defined(__ia64__) || defined(__ia64) + thread_stack= stack_size*2; +#else thread_stack= stack_size; +#endif } } #endif - thread_stack_min=thread_stack - STACK_MIN_SIZE; (void) thr_setconcurrency(concurrency); // 10 by default @@ -3456,7 +3478,7 @@ static void bootstrap(FILE *file) thd->client_capabilities=0; my_net_init(&thd->net,(st_vio*) 0); thd->max_client_packet_length= thd->net.max_packet; - thd->master_access= ~0; + thd->master_access= ~(ulong)0; thd->thread_id=thread_id++; thread_count++; @@ -5727,7 +5749,7 @@ struct show_var_st status_vars[]= { {"Key_reads", (char*) &dflt_key_cache_var.global_cache_read, SHOW_KEY_CACHE_LONG}, {"Key_write_requests", (char*) &dflt_key_cache_var.global_cache_w_requests, SHOW_KEY_CACHE_LONG}, {"Key_writes", (char*) &dflt_key_cache_var.global_cache_write, SHOW_KEY_CACHE_LONG}, - {"Last_query_cost", (char*) &last_query_cost, SHOW_DOUBLE}, + {"Last_query_cost", (char*) offsetof(STATUS_VAR, last_query_cost), SHOW_DOUBLE_STATUS}, {"Max_used_connections", (char*) &max_used_connections, SHOW_LONG}, #ifdef HAVE_NDBCLUSTER_DB {"Ndb_", (char*) &ndb_status_variables, SHOW_VARS}, @@ -5808,7 +5830,6 @@ static void print_version(void) server_version,SYSTEM_TYPE,MACHINE_TYPE, MYSQL_COMPILATION_COMMENT); } - static void usage(void) { if (!(default_charset_info= get_charset_by_csname(default_character_set_name, diff --git a/sql/opt_range.cc b/sql/opt_range.cc index ca3f5c5af87..95c9fc5035e 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -36,7 +36,9 @@ QUICK_RANGEs are also created in this step. */ -#ifdef __GNUC__ +#include + +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif @@ -3307,32 +3309,35 @@ QUICK_SELECT_I *TRP_ROR_UNION::make_quick(PARAM *param, /* - Build a SEL_TREE for <> predicate + Build a SEL_TREE for <> or NOT BETWEEN predicate SYNOPSIS get_ne_mm_tree() param PARAM from SQL_SELECT::test_quick_select cond_func item for the predicate field field in the predicate - value constant in the predicate + lt_value constant that field should be smaller + gt_value constant that field should be greaterr cmp_type compare type for the field RETURN - Pointer to tree built tree + # Pointer to tree built tree + 0 on error */ static SEL_TREE *get_ne_mm_tree(PARAM *param, Item_func *cond_func, - Field *field, Item *value, + Field *field, + Item *lt_value, Item *gt_value, Item_result cmp_type) { - SEL_TREE *tree= 0; + SEL_TREE *tree; tree= get_mm_parts(param, cond_func, field, Item_func::LT_FUNC, - value, cmp_type); + lt_value, cmp_type); if (tree) { tree= tree_or(param, tree, get_mm_parts(param, cond_func, field, Item_func::GT_FUNC, - value, cmp_type)); + gt_value, cmp_type)); } return tree; } @@ -3365,21 +3370,14 @@ static SEL_TREE *get_func_mm_tree(PARAM *param, Item_func *cond_func, switch (cond_func->functype()) { case Item_func::NE_FUNC: - tree= get_ne_mm_tree(param, cond_func, field, value, cmp_type); + tree= get_ne_mm_tree(param, cond_func, field, value, value, cmp_type); break; case Item_func::BETWEEN: if (inv) { - tree= get_mm_parts(param, cond_func, field, Item_func::LT_FUNC, - cond_func->arguments()[1],cmp_type); - if (tree) - { - tree= tree_or(param, tree, get_mm_parts(param, cond_func, field, - Item_func::GT_FUNC, - cond_func->arguments()[2], - cmp_type)); - } + tree= get_ne_mm_tree(param, cond_func, field, cond_func->arguments()[1], + cond_func->arguments()[2], cmp_type); } else { @@ -3402,7 +3400,8 @@ static SEL_TREE *get_func_mm_tree(PARAM *param, Item_func *cond_func, if (inv) { tree= get_ne_mm_tree(param, cond_func, field, - func->arguments()[1], cmp_type); + func->arguments()[1], func->arguments()[1], + cmp_type); if (tree) { Item **arg, **end; @@ -3410,7 +3409,7 @@ static SEL_TREE *get_func_mm_tree(PARAM *param, Item_func *cond_func, arg < end ; arg++) { tree= tree_and(param, tree, get_ne_mm_tree(param, cond_func, field, - *arg, cmp_type)); + *arg, *arg, cmp_type)); } } } @@ -3523,17 +3522,18 @@ static SEL_TREE *get_mm_tree(PARAM *param,COND *cond) Item_func *cond_func= (Item_func*) cond; if (cond_func->functype() == Item_func::NOT_FUNC) { + /* Optimize NOT BETWEEN and NOT IN */ Item *arg= cond_func->arguments()[0]; if (arg->type() == Item::FUNC_ITEM) { cond_func= (Item_func*) arg; if (cond_func->select_optimize() == Item_func::OPTIMIZE_NONE) DBUG_RETURN(0); - inv= TRUE; + inv= TRUE; } else DBUG_RETURN(0); - } + } else if (cond_func->select_optimize() == Item_func::OPTIMIZE_NONE) DBUG_RETURN(0); @@ -7982,8 +7982,17 @@ void QUICK_GROUP_MIN_MAX_SELECT::update_key_stat() } } } - else if (have_min && min_max_arg_part && min_max_arg_part->field->is_null()) + else if (have_min && min_max_arg_part && + min_max_arg_part->field->real_maybe_null()) { + /* + If a MIN/MAX argument value is NULL, we can quickly determine + that we're in the beginning of the next group, because NULLs + are always < any other value. This allows us to quickly + determine the end of the current group and jump to the next + group (see next_min()) and thus effectively increases the + usable key length. + */ max_used_key_length+= min_max_arg_len; ++used_key_parts; } diff --git a/sql/opt_range.h b/sql/opt_range.h index 8d365262334..b639ba6efa7 100644 --- a/sql/opt_range.h +++ b/sql/opt_range.h @@ -691,7 +691,7 @@ class SQL_SELECT :public Sql_alloc { ~SQL_SELECT(); void cleanup(); bool check_quick(THD *thd, bool force_quick_range, ha_rows limit) - { return test_quick_select(thd, key_map(~0), 0, limit, force_quick_range) < 0; } + { return test_quick_select(thd, key_map(~(uint)0), 0, limit, force_quick_range) < 0; } inline bool skip_record() { return cond ? cond->val_int() == 0 : 0; } int test_quick_select(THD *thd, key_map keys, table_map prev_tables, ha_rows limit, bool force_quick_range=0); diff --git a/sql/procedure.cc b/sql/procedure.cc index a31b93da358..38a043300bc 100644 --- a/sql/procedure.cc +++ b/sql/procedure.cc @@ -17,7 +17,9 @@ /* Procedures (functions with changes output of select) */ -#ifdef __GNUC__ +#include + +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/protocol.cc b/sql/protocol.cc index 9a96da004c5..8019f3a123b 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -19,7 +19,9 @@ The actual communction is handled by the net_xxx functions in net_serv.cc */ -#ifdef __GNUC__ +#include + +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/protocol.h b/sql/protocol.h index 01331ef64ba..5b402cb2669 100644 --- a/sql/protocol.h +++ b/sql/protocol.h @@ -159,8 +159,8 @@ public: MYSQL_ROWS **prev_record; ulong row_count; - Protocol_cursor() {} - Protocol_cursor(THD *thd_arg, MEM_ROOT *ini_alloc) :Protocol_simple(thd_arg), alloc(ini_alloc) {} + Protocol_cursor() :data(NULL) {} + Protocol_cursor(THD *thd_arg, MEM_ROOT *ini_alloc) :Protocol_simple(thd_arg), alloc(ini_alloc), data(NULL) {} bool prepare_for_send(List *item_list) { row_count= 0; diff --git a/sql/protocol_cursor.cc b/sql/protocol_cursor.cc index 5ac03c4d427..c38a7cdecae 100644 --- a/sql/protocol_cursor.cc +++ b/sql/protocol_cursor.cc @@ -19,7 +19,9 @@ The actual communction is handled by the net_xxx functions in net_serv.cc */ -#ifdef __GNUC__ +#include + +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc index de4ad83fdbb..0b6e44c0272 100644 --- a/sql/repl_failsafe.cc +++ b/sql/repl_failsafe.cc @@ -71,7 +71,7 @@ static int init_failsafe_rpl_thread(THD* thd) my_net_init(&thd->net, 0); thd->net.read_timeout = slave_net_timeout; thd->max_client_packet_length=thd->net.max_packet; - thd->master_access= ~0; + thd->master_access= ~(ulong)0; thd->priv_user = 0; pthread_mutex_lock(&LOCK_thread_count); thd->thread_id = thread_id++; diff --git a/sql/set_var.cc b/sql/set_var.cc index b8059779a2a..0d743f99b73 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -48,7 +48,9 @@ new attribute. */ -#ifdef __GNUC__ +#include + +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif @@ -1713,7 +1715,8 @@ Item *sys_var::item(THD *thd, enum_var_type var_type, LEX_STRING *base) Item_string *tmp; pthread_mutex_lock(&LOCK_global_system_variables); char *str= (char*) value_ptr(thd, var_type, base); - tmp= new Item_string(str, strlen(str), system_charset_info); + tmp= new Item_string(str, strlen(str), + system_charset_info, DERIVATION_SYSCONST); pthread_mutex_unlock(&LOCK_global_system_variables); return tmp; } diff --git a/sql/slave.cc b/sql/slave.cc index 70803c88c3a..60812469671 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -2818,7 +2818,7 @@ static int init_slave_thread(THD* thd, SLAVE_THD_TYPE thd_type) thd->client_capabilities = 0; my_net_init(&thd->net, 0); thd->net.read_timeout = slave_net_timeout; - thd->master_access= ~0; + thd->master_access= ~(ulong)0; thd->slave_thread = 1; set_slave_thread_options(thd); /* diff --git a/sql/sp.cc b/sql/sp.cc index 9a816f277ed..4f89d6ba6da 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -120,6 +120,10 @@ db_find_routine_aux(THD *thd, int type, sp_name *name, 'db', 'name' and 'type' and the first key is the primary key over the same fields. */ + if (name->m_name.length > table->field[1]->field_length) + { + DBUG_RETURN(SP_KEY_NOT_FOUND); + } table->field[0]->store(name->m_db.str, name->m_db.length, &my_charset_bin); table->field[1]->store(name->m_name.str, name->m_name.length, &my_charset_bin); @@ -389,6 +393,11 @@ db_create_routine(THD *thd, int type, sp_head *sp) ret= SP_GET_FIELD_FAILED; goto done; } + if (sp->m_name.length > table->field[MYSQL_PROC_FIELD_NAME]->field_length) + { + ret= SP_BAD_IDENTIFIER; + goto done; + } table->field[MYSQL_PROC_FIELD_DB]-> store(sp->m_db.str, sp->m_db.length, system_charset_info); table->field[MYSQL_PROC_FIELD_NAME]-> @@ -667,7 +676,7 @@ db_show_routine_status(THD *thd, int type, const char *wild) tables is not VIEW for sure => we can pass 0 as condition */ - setup_tables(thd, &tables, 0, &leaves, FALSE, FALSE); + setup_tables(thd, &tables, 0, &leaves, FALSE); for (used_field= &used_fields[0]; used_field->field_name; used_field++) diff --git a/sql/sp.h b/sql/sp.h index 00dd8416c1d..16d79026132 100644 --- a/sql/sp.h +++ b/sql/sp.h @@ -28,6 +28,7 @@ #define SP_PARSE_ERROR -6 #define SP_INTERNAL_ERROR -7 #define SP_NO_DB_ERROR -8 +#define SP_BAD_IDENTIFIER -9 /* Drop all routines in database 'db' */ int diff --git a/sql/sp_cache.cc b/sql/sp_cache.cc index 056ac6d7e96..83811e76f9b 100644 --- a/sql/sp_cache.cc +++ b/sql/sp_cache.cc @@ -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 */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation #endif diff --git a/sql/sp_cache.h b/sql/sp_cache.h index 754a987090e..e9efe5b2a8c 100644 --- a/sql/sp_cache.h +++ b/sql/sp_cache.h @@ -18,7 +18,7 @@ #ifndef _SP_CACHE_H_ #define _SP_CACHE_H_ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ #endif diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 988345694b2..c17c8b81cb2 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -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 */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation #endif @@ -564,13 +564,11 @@ sp_head::execute(THD *thd) Item_change_list old_change_list; String old_packet; - -#ifndef EMBEDDED_LIBRARY - if (check_stack_overrun(thd, olddb)) + /* Use some extra margin for possible SP recursion and functions */ + if (check_stack_overrun(thd, 4*STACK_MIN_SIZE, olddb)) { DBUG_RETURN(-1); } -#endif dbchanged= FALSE; if (m_db.length && @@ -1499,8 +1497,8 @@ sp_instr_set_trigger_field::execute(THD *thd, uint *nextp) DBUG_ENTER("sp_instr_set_trigger_field::execute"); /* QQ: Still unsure what should we return in case of error 1 or -1 ? */ if (!value->fixed && value->fix_fields(thd, 0, &value) || - trigger_field.fix_fields(thd, 0, 0) || - (value->save_in_field(trigger_field.field, 0) < 0)) + trigger_field->fix_fields(thd, 0, 0) || + (value->save_in_field(trigger_field->field, 0) < 0)) res= -1; *nextp= m_ip + 1; DBUG_RETURN(res); @@ -1510,7 +1508,7 @@ void sp_instr_set_trigger_field::print(String *str) { str->append("set ", 4); - trigger_field.print(str); + trigger_field->print(str); str->append(":=", 2); value->print(str); } @@ -1915,7 +1913,19 @@ sp_instr_copen::execute(THD *thd, uint *nextp) else res= lex_keeper->reset_lex_and_exec_core(thd, nextp, FALSE, this); - c->post_open(thd, (lex_keeper ? TRUE : FALSE)); + /* + Work around the fact that errors in selects are not returned properly + (but instead converted into a warning), so if a condition handler + caught, we have lost the result code. + */ + if (!res) + { + uint dummy1, dummy2; + + if (thd->spcont->found_handler(&dummy1, &dummy2)) + res= -1; + } + c->post_open(thd, (lex_keeper && !res ? TRUE : FALSE)); } DBUG_RETURN(res); diff --git a/sql/sp_head.h b/sql/sp_head.h index ee41b1efc83..49eabce246b 100644 --- a/sql/sp_head.h +++ b/sql/sp_head.h @@ -18,7 +18,7 @@ #ifndef _SP_HEAD_H_ #define _SP_HEAD_H_ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ #endif @@ -467,9 +467,9 @@ class sp_instr_set_trigger_field : public sp_instr public: sp_instr_set_trigger_field(uint ip, sp_pcontext *ctx, - LEX_STRING field_name, Item *val) + Item_trigger_field *trg_fld, Item *val) : sp_instr(ip, ctx), - trigger_field(Item_trigger_field::NEW_ROW, field_name.str), + trigger_field(trg_fld), value(val) {} @@ -480,9 +480,8 @@ public: virtual void print(String *str); - Item_trigger_field trigger_field; - private: + Item_trigger_field *trigger_field; Item *value; }; // class sp_instr_trigger_field : public sp_instr diff --git a/sql/sp_pcontext.cc b/sql/sp_pcontext.cc index 26f576233f3..f95a43eb903 100644 --- a/sql/sp_pcontext.cc +++ b/sql/sp_pcontext.cc @@ -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 */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation #endif diff --git a/sql/sp_pcontext.h b/sql/sp_pcontext.h index 749b99dcf14..0d218bc0538 100644 --- a/sql/sp_pcontext.h +++ b/sql/sp_pcontext.h @@ -18,7 +18,7 @@ #ifndef _SP_PCONTEXT_H_ #define _SP_PCONTEXT_H_ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ #endif diff --git a/sql/sp_rcontext.cc b/sql/sp_rcontext.cc index 49ead5d1585..2e79a1e2533 100644 --- a/sql/sp_rcontext.cc +++ b/sql/sp_rcontext.cc @@ -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 */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation #endif diff --git a/sql/sp_rcontext.h b/sql/sp_rcontext.h index 417c50d0f0f..ba5fa950dc3 100644 --- a/sql/sp_rcontext.h +++ b/sql/sp_rcontext.h @@ -18,7 +18,7 @@ #ifndef _SP_RCONTEXT_H_ #define _SP_RCONTEXT_H_ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ #endif diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 7caece67599..a11871c55dc 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -1104,7 +1104,7 @@ static void acl_insert_db(const char *user, const char *host, const char *db, ulong acl_get(const char *host, const char *ip, const char *user, const char *db, my_bool db_is_pattern) { - ulong host_access= ~0, db_access= 0; + ulong host_access= ~(ulong)0, db_access= 0; uint i,key_length; char key[ACL_KEY_LENGTH],*tmp_db,*end; acl_entry *entry; @@ -5064,7 +5064,7 @@ bool mysql_revoke_all(THD *thd, List &list) } if (replace_user_table(thd, tables[0].table, - *lex_user, ~0, 1, 0, 0)) + *lex_user, ~(ulong)0, 1, 0, 0)) { result= -1; continue; @@ -5091,7 +5091,7 @@ bool mysql_revoke_all(THD *thd, List &list) if (!strcmp(lex_user->user.str,user) && !my_strcasecmp(system_charset_info, lex_user->host.str, host)) { - if (!replace_db_table(tables[1].table, acl_db->db, *lex_user, ~0, 1)) + if (!replace_db_table(tables[1].table, acl_db->db, *lex_user, ~(ulong)0, 1)) { /* Don't increment counter as replace_db_table deleted the @@ -5125,7 +5125,7 @@ bool mysql_revoke_all(THD *thd, List &list) if (replace_table_table(thd,grant_table,tables[2].table,*lex_user, grant_table->db, grant_table->tname, - ~0, 0, 1)) + ~(ulong)0, 0, 1)) { result= -1; } @@ -5141,7 +5141,7 @@ bool mysql_revoke_all(THD *thd, List &list) columns, grant_table->db, grant_table->tname, - ~0, 1)) + ~(ulong)0, 1)) { revoked= 1; continue; diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc index 1056bff4315..55e6dfb3cbe 100644 --- a/sql/sql_analyse.cc +++ b/sql/sql_analyse.cc @@ -23,7 +23,9 @@ ** - type set is out of optimization yet */ -#ifdef __GNUC__ +#include + +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/sql_analyse.h b/sql/sql_analyse.h index a0f0df9b43b..9e5926fd9b1 100644 --- a/sql/sql_analyse.h +++ b/sql/sql_analyse.h @@ -17,7 +17,7 @@ /* Analyse database */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ #endif diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 29d9a7bf9c4..036a838b6fc 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -1384,7 +1384,7 @@ bool reopen_tables(THD *thd,bool get_locks,bool in_refresh) MYSQL_LOCK *lock; /* We should always get these locks */ thd->some_tables_deleted=0; - if ((lock=mysql_lock_tables(thd,tables,(uint) (tables_ptr-tables)))) + if ((lock= mysql_lock_tables(thd, tables, (uint) (tables_ptr - tables), 0))) { thd->locked_tables=mysql_lock_merge(thd->locked_tables,lock); } @@ -1607,9 +1607,9 @@ static int open_unireg_entry(THD *thd, TABLE *entry, const char *db, trying to discover the table at the same time. */ if (discover_retry_count++ != 0) - goto err; + goto err; if (ha_create_table_from_engine(thd, db, name, TRUE) != 0) - goto err; + goto err; mysql_reset_errors(thd, 1); // Clear warnings thd->clear_error(); // Clear error message @@ -2022,7 +2022,7 @@ TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type lock_type) { DBUG_ASSERT(thd->lock == 0); // You must lock everything at once if ((table->reginfo.lock_type= lock_type) != TL_UNLOCK) - if (!(thd->lock=mysql_lock_tables(thd,&table_list->table,1))) + if (! (thd->lock= mysql_lock_tables(thd, &table_list->table, 1, 0))) table= 0; } } @@ -2237,7 +2237,7 @@ int lock_tables(THD *thd, TABLE_LIST *tables, uint count) thd->options|= OPTION_TABLE_LOCK; } - if (!(thd->lock=mysql_lock_tables(thd,start, (uint) (ptr - start)))) + if (! (thd->lock= mysql_lock_tables(thd, start, (uint) (ptr - start), 0))) { if (thd->lex->requires_prelocking()) { @@ -3208,7 +3208,7 @@ TABLE_LIST **make_leaves_list(TABLE_LIST **list, TABLE_LIST *tables) */ bool setup_tables(THD *thd, TABLE_LIST *tables, Item **conds, - TABLE_LIST **leaves, bool refresh, bool select_insert) + TABLE_LIST **leaves, bool select_insert) { uint tablenr= 0; DBUG_ENTER("setup_tables"); @@ -3222,7 +3222,8 @@ bool setup_tables(THD *thd, TABLE_LIST *tables, Item **conds, if (!(*leaves)) make_leaves_list(leaves, tables); - for (TABLE_LIST *table_list= *leaves; + TABLE_LIST *table_list; + for (table_list= *leaves; table_list; table_list= table_list->next_leaf, tablenr++) { @@ -3261,17 +3262,14 @@ bool setup_tables(THD *thd, TABLE_LIST *tables, Item **conds, my_error(ER_TOO_MANY_TABLES,MYF(0),MAX_TABLES); DBUG_RETURN(1); } - if (!refresh) + for (table_list= tables; + table_list; + table_list= table_list->next_local) { - for (TABLE_LIST *table_list= tables; - table_list; - table_list= table_list->next_local) - { - if (table_list->ancestor && - table_list->setup_ancestor(thd, conds, - table_list->effective_with_check)) - DBUG_RETURN(1); - } + if (table_list->ancestor && + table_list->setup_ancestor(thd, conds, + table_list->effective_with_check)) + DBUG_RETURN(1); } DBUG_RETURN(0); } @@ -3813,7 +3811,7 @@ err_no_arena: TRUE error occured */ -bool +static bool fill_record(THD * thd, List &fields, List &values, bool ignore_errors) { @@ -3839,6 +3837,41 @@ fill_record(THD * thd, List &fields, List &values, } +/* + Fill fields in list with values from the list of items and invoke + before triggers. + + SYNOPSIS + fill_record_n_invoke_before_triggers() + thd thread context + fields Item_fields list to be filled + values values to fill with + ignore_errors TRUE if we should ignore errors + triggers object holding list of triggers to be invoked + event event type for triggers to be invoked + + NOTE + This function assumes that fields which values will be set and triggers + to be invoked belong to the same table, and that TABLE::record[0] and + record[1] buffers correspond to new and old versions of row respectively. + + RETURN + FALSE OK + TRUE error occured +*/ + +bool +fill_record_n_invoke_before_triggers(THD *thd, List &fields, + List &values, bool ignore_errors, + Table_triggers_list *triggers, + enum trg_event_type event) +{ + return (fill_record(thd, fields, values, ignore_errors) || + triggers && triggers->process_triggers(thd, event, + TRG_ACTION_BEFORE, TRUE)); +} + + /* Fill field buffer with values from Field list @@ -3875,6 +3908,41 @@ fill_record(THD *thd, Field **ptr, List &values, bool ignore_errors) } +/* + Fill fields in array with values from the list of items and invoke + before triggers. + + SYNOPSIS + fill_record_n_invoke_before_triggers() + thd thread context + ptr NULL-ended array of fields to be filled + values values to fill with + ignore_errors TRUE if we should ignore errors + triggers object holding list of triggers to be invoked + event event type for triggers to be invoked + + NOTE + This function assumes that fields which values will be set and triggers + to be invoked belong to the same table, and that TABLE::record[0] and + record[1] buffers correspond to new and old versions of row respectively. + + RETURN + FALSE OK + TRUE error occured +*/ + +bool +fill_record_n_invoke_before_triggers(THD *thd, Field **ptr, + List &values, bool ignore_errors, + Table_triggers_list *triggers, + enum trg_event_type event) +{ + return (fill_record(thd, ptr, values, ignore_errors) || + triggers && triggers->process_triggers(thd, event, + TRG_ACTION_BEFORE, TRUE)); +} + + static void mysql_rm_tmp_tables(void) { uint i, idx; diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 2a500610479..862cf940173 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -22,7 +22,9 @@ ** *****************************************************************************/ -#ifdef __GNUC__ +#include + +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif @@ -444,6 +446,7 @@ void add_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var) while (to != end) *(to++)+= *(from++); + /* it doesn't make sense to add last_query_cost values */ } diff --git a/sql/sql_class.h b/sql/sql_class.h index 211648e63f7..47987f3a0c6 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -635,6 +635,8 @@ typedef struct system_status_var ulong filesort_range_count; ulong filesort_rows; ulong filesort_scan_count; + + double last_query_cost; } STATUS_VAR; /* diff --git a/sql/sql_crypt.cc b/sql/sql_crypt.cc index b0b8050e311..eda7f0f6bbb 100644 --- a/sql/sql_crypt.cc +++ b/sql/sql_crypt.cc @@ -23,7 +23,9 @@ needs something like 'ssh'. */ -#ifdef __GNUC__ +#include + +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/sql_crypt.h b/sql/sql_crypt.h index 1b27f0a4d27..25bc2d29e1d 100644 --- a/sql/sql_crypt.h +++ b/sql/sql_crypt.h @@ -15,7 +15,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ #endif diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index ca7bf174abf..d4a3b6c684e 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -176,13 +176,24 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, if (!(select && select->skip_record())&& !thd->net.report_error ) { - if (table->triggers) - table->triggers->process_triggers(thd, TRG_EVENT_DELETE, - TRG_ACTION_BEFORE); + if (table->triggers && + table->triggers->process_triggers(thd, TRG_EVENT_DELETE, + TRG_ACTION_BEFORE, FALSE)) + { + error= 1; + break; + } if (!(error=table->file->delete_row(table->record[0]))) { deleted++; + if (table->triggers && + table->triggers->process_triggers(thd, TRG_EVENT_DELETE, + TRG_ACTION_AFTER, FALSE)) + { + error= 1; + break; + } if (!--limit && using_limit) { error= -1; @@ -203,10 +214,6 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, error= 1; break; } - - if (table->triggers) - table->triggers->process_triggers(thd, TRG_EVENT_DELETE, - TRG_ACTION_AFTER); } else table->file->unlock_row(); // Row failed selection, release lock on it @@ -293,8 +300,7 @@ bool mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds) SELECT_LEX *select_lex= &thd->lex->select_lex; DBUG_ENTER("mysql_prepare_delete"); - if (setup_tables(thd, table_list, conds, &select_lex->leaf_tables, - FALSE, FALSE) || + if (setup_tables(thd, table_list, conds, &select_lex->leaf_tables, FALSE) || setup_conds(thd, table_list, select_lex->leaf_tables, conds) || setup_ftfuncs(select_lex)) DBUG_RETURN(TRUE); @@ -351,7 +357,7 @@ bool mysql_multi_delete_prepare(THD *thd) lex->query_tables also point on local list of DELETE SELECT_LEX */ if (setup_tables(thd, lex->query_tables, &lex->select_lex.where, - &lex->select_lex.leaf_tables, FALSE, FALSE)) + &lex->select_lex.leaf_tables, FALSE)) DBUG_RETURN(TRUE); @@ -509,9 +515,19 @@ bool multi_delete::send_data(List &values) if (secure_counter < 0) { /* If this is the table we are scanning */ + if (table->triggers && + table->triggers->process_triggers(thd, TRG_EVENT_DELETE, + TRG_ACTION_BEFORE, FALSE)) + DBUG_RETURN(1); table->status|= STATUS_DELETED; if (!(error=table->file->delete_row(table->record[0]))) + { deleted++; + if (table->triggers && + table->triggers->process_triggers(thd, TRG_EVENT_DELETE, + TRG_ACTION_AFTER, FALSE)) + DBUG_RETURN(1); + } else if (!table_being_deleted->next_local || table_being_deleted->table->file->has_transactions()) { @@ -614,12 +630,26 @@ int multi_delete::do_deletes(bool from_send_error) info.ignore_not_found_rows= 1; while (!(local_error=info.read_record(&info)) && !thd->killed) { + if (table->triggers && + table->triggers->process_triggers(thd, TRG_EVENT_DELETE, + TRG_ACTION_BEFORE, FALSE)) + { + local_error= 1; + break; + } if ((local_error=table->file->delete_row(table->record[0]))) { table->file->print_error(local_error,MYF(0)); break; } deleted++; + if (table->triggers && + table->triggers->process_triggers(thd, TRG_EVENT_DELETE, + TRG_ACTION_AFTER, FALSE)) + { + local_error= 1; + break; + } } end_read_record(&info); if (thd->killed && !local_error) @@ -665,11 +695,11 @@ bool multi_delete::send_eof() Note that if we deleted nothing we don't write to the binlog (TODO: fix this). */ - if (deleted && (error <= 0 || normal_tables)) + if (deleted && ((error <= 0 && !local_error) || normal_tables)) { if (mysql_bin_log.is_open()) { - if (error <= 0) + if (error <= 0 && !local_error) thd->clear_error(); Query_log_event qinfo(thd, thd->query, thd->query_length, transactional_tables, FALSE); diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index bb48b7ada77..1aa034ce61c 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -433,7 +433,7 @@ bool mysql_ha_read(THD *thd, TABLE_LIST *tables, protocol->send_fields(&list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF); HANDLER_TABLES_HACK(thd); - lock= mysql_lock_tables(thd, &tables->table, 1); + lock= mysql_lock_tables(thd, &tables->table, 1, 0); HANDLER_TABLES_HACK(thd); if (!lock) diff --git a/sql/sql_help.cc b/sql/sql_help.cc index 3c8e8e55c1f..0cf8d1e93a7 100644 --- a/sql/sql_help.cc +++ b/sql/sql_help.cc @@ -651,7 +651,7 @@ bool mysqld_help(THD *thd, const char *mask) tables do not contain VIEWs => we can pass 0 as conds */ - setup_tables(thd, tables, 0, &leaves, FALSE, FALSE); + setup_tables(thd, tables, 0, &leaves, FALSE); memcpy((char*) used_fields, (char*) init_used_fields, sizeof(used_fields)); if (init_fields(thd, tables, used_fields, array_elements(used_fields))) goto error; diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 0bd9099ede1..8e4456a42a6 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -398,7 +398,9 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, if (fields.elements || !value_count) { restore_record(table,s->default_values); // Get empty record - if (fill_record(thd, fields, *values, 0)) + if (fill_record_n_invoke_before_triggers(thd, fields, *values, 0, + table->triggers, + TRG_EVENT_INSERT)) { if (values_list.elements != 1 && !thd->net.report_error) { @@ -419,8 +421,17 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, if (thd->used_tables) // Column used in values() restore_record(table,s->default_values); // Get empty record else - table->record[0][0]= table->s->default_values[0]; // Fix delete marker - if (fill_record(thd, table->field, *values, 0)) + { + /* + Fix delete marker. No need to restore rest of record since it will + be overwritten by fill_record() anyway (and fill_record() does not + use default values in this case). + */ + table->record[0][0]= table->s->default_values[0]; + } + if (fill_record_n_invoke_before_triggers(thd, table->field, *values, 0, + table->triggers, + TRG_EVENT_INSERT)) { if (values_list.elements != 1 && ! thd->net.report_error) { @@ -432,14 +443,6 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, } } - /* - FIXME: Actually we should do this before - check_that_all_fields_are_given_values Or even go into write_record ? - */ - if (table->triggers) - table->triggers->process_triggers(thd, TRG_EVENT_INSERT, - TRG_ACTION_BEFORE); - if ((res= table_list->view_check_option(thd, (values_list.elements == 1 ? 0 : @@ -473,9 +476,6 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, if (error) break; thd->row_count++; - - if (table->triggers) - table->triggers->process_triggers(thd, TRG_EVENT_INSERT, TRG_ACTION_AFTER); } /* @@ -699,7 +699,7 @@ static bool mysql_prepare_insert_check_table(THD *thd, TABLE_LIST *table_list, DBUG_ENTER("mysql_prepare_insert_check_table"); if (setup_tables(thd, table_list, where, &thd->lex->select_lex.leaf_tables, - FALSE, select_insert)) + select_insert)) DBUG_RETURN(TRUE); if (insert_into_view && !fields.elements) @@ -802,15 +802,35 @@ static int last_uniq_key(TABLE *table,uint keynr) /* - Write a record to table with optional deleting of conflicting records + Write a record to table with optional deleting of conflicting records, + invoke proper triggers if needed. - Sets thd->no_trans_update if table which is updated didn't have transactions + SYNOPSIS + write_record() + thd - thread context + table - table to which record should be written + info - COPY_INFO structure describing handling of duplicates + and which is used for counting number of records inserted + and deleted. + + NOTE + Once this record will be written to table after insert trigger will + be invoked. If instead of inserting new record we will update old one + then both on update triggers will work instead. Similarly both on + delete triggers will be invoked if we will delete conflicting records. + + Sets thd->no_trans_update if table which is updated didn't have + transactions. + + RETURN VALUE + 0 - success + non-0 - error */ int write_record(THD *thd, TABLE *table,COPY_INFO *info) { - int error; + int error, trg_error= 0; char *key=0; DBUG_ENTER("write_record"); @@ -872,34 +892,43 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info) if (info->handle_duplicates == DUP_UPDATE) { int res= 0; - /* we don't check for other UNIQUE keys - the first row - that matches, is updated. If update causes a conflict again, - an error is returned + /* + We don't check for other UNIQUE keys - the first row + that matches, is updated. If update causes a conflict again, + an error is returned */ DBUG_ASSERT(table->insert_values != NULL); store_record(table,insert_values); restore_record(table,record[1]); DBUG_ASSERT(info->update_fields->elements == info->update_values->elements); - if (fill_record(thd, *info->update_fields, *info->update_values, 0)) - goto err; + if (fill_record_n_invoke_before_triggers(thd, *info->update_fields, + *info->update_values, 0, + table->triggers, + TRG_EVENT_UPDATE)) + goto before_trg_err; /* CHECK OPTION for VIEW ... ON DUPLICATE KEY UPDATE ... */ if (info->view && (res= info->view->view_check_option(current_thd, info->ignore)) == VIEW_CHECK_SKIP) - break; + goto ok_or_after_trg_err; if (res == VIEW_CHECK_ERROR) - goto err; + goto before_trg_err; if ((error=table->file->update_row(table->record[1],table->record[0]))) { if ((error == HA_ERR_FOUND_DUPP_KEY) && info->ignore) - break; + goto ok_or_after_trg_err; goto err; } info->updated++; - break; + + trg_error= (table->triggers && + table->triggers->process_triggers(thd, TRG_EVENT_UPDATE, + TRG_ACTION_AFTER, TRUE)); + info->copied++; + goto ok_or_after_trg_err; } else /* DUP_REPLACE */ { @@ -916,20 +945,48 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info) (table->timestamp_field_type == TIMESTAMP_NO_AUTO_SET || table->timestamp_field_type == TIMESTAMP_AUTO_SET_ON_BOTH)) { + if (table->triggers && + table->triggers->process_triggers(thd, TRG_EVENT_UPDATE, + TRG_ACTION_BEFORE, TRUE)) + goto before_trg_err; if ((error=table->file->update_row(table->record[1], table->record[0]))) goto err; info->deleted++; - break; /* Update logfile and count */ + trg_error= (table->triggers && + table->triggers->process_triggers(thd, TRG_EVENT_UPDATE, + TRG_ACTION_AFTER, + TRUE)); + /* Update logfile and count */ + info->copied++; + goto ok_or_after_trg_err; + } + else + { + if (table->triggers && + table->triggers->process_triggers(thd, TRG_EVENT_DELETE, + TRG_ACTION_BEFORE, TRUE)) + goto before_trg_err; + if ((error=table->file->delete_row(table->record[1]))) + goto err; + info->deleted++; + if (!table->file->has_transactions()) + thd->no_trans_update= 1; + if (table->triggers && + table->triggers->process_triggers(thd, TRG_EVENT_DELETE, + TRG_ACTION_AFTER, TRUE)) + { + trg_error= 1; + goto ok_or_after_trg_err; + } + /* Let us attempt do write_row() once more */ } - else if ((error=table->file->delete_row(table->record[1]))) - goto err; - info->deleted++; - if (!table->file->has_transactions()) - thd->no_trans_update= 1; } } info->copied++; + trg_error= (table->triggers && + table->triggers->process_triggers(thd, TRG_EVENT_INSERT, + TRG_ACTION_AFTER, TRUE)); } else if ((error=table->file->write_row(table->record[0]))) { @@ -939,18 +996,27 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info) table->file->restore_auto_increment(); } else + { info->copied++; + trg_error= (table->triggers && + table->triggers->process_triggers(thd, TRG_EVENT_INSERT, + TRG_ACTION_AFTER, TRUE)); + } + +ok_or_after_trg_err: if (key) my_safe_afree(key,table->s->max_unique_length,MAX_KEY_LENGTH); if (!table->file->has_transactions()) thd->no_trans_update= 1; - DBUG_RETURN(0); + DBUG_RETURN(trg_error); err: - if (key) - my_safe_afree(key,table->s->max_unique_length,MAX_KEY_LENGTH); info->last_errno= error; table->file->print_error(error,MYF(0)); + +before_trg_err: + if (key) + my_safe_afree(key, table->s->max_unique_length, MAX_KEY_LENGTH); DBUG_RETURN(1); } @@ -1145,10 +1211,13 @@ static TABLE *delayed_get_table(THD *thd,TABLE_LIST *table_list) Avoid that a global read lock steps in while we are creating the new thread. It would block trying to open the table. Hence, the DI thread and this thread would wait until after the global - readlock is gone. If the read lock exists already, we leave with - no table and then switch to non-delayed insert. + readlock is gone. Since the insert thread needs to wait for a + global read lock anyway, we do it right now. Note that + wait_if_global_read_lock() sets a protection against a new + global read lock when it succeeds. This needs to be released by + start_waiting_global_read_lock(). */ - if (set_protect_against_global_read_lock()) + if (wait_if_global_read_lock(thd, 0, 1)) goto err; if (!(tmp=new delayed_insert())) { @@ -1190,7 +1259,11 @@ static TABLE *delayed_get_table(THD *thd,TABLE_LIST *table_list) pthread_cond_wait(&tmp->cond_client,&tmp->mutex); } pthread_mutex_unlock(&tmp->mutex); - unset_protect_against_global_read_lock(); + /* + Release the protection against the global read lock and wake + everyone, who might want to set a global read lock. + */ + start_waiting_global_read_lock(thd); thd->proc_info="got old table"; if (tmp->thd.killed) { @@ -1226,7 +1299,11 @@ static TABLE *delayed_get_table(THD *thd,TABLE_LIST *table_list) err1: thd->fatal_error(); - unset_protect_against_global_read_lock(); + /* + Release the protection against the global read lock and wake + everyone, who might want to set a global read lock. + */ + start_waiting_global_read_lock(thd); err: pthread_mutex_unlock(&LOCK_delayed_create); DBUG_RETURN(0); // Continue with normal insert @@ -1584,7 +1661,8 @@ extern "C" pthread_handler_decl(handle_delayed_insert,arg) handler will close the table and finish when the outstanding inserts are done. */ - if (! (thd->lock= mysql_lock_tables(thd, &di->table, 1, TRUE))) + if (! (thd->lock= mysql_lock_tables(thd, &di->table, 1, + MYSQL_LOCK_IGNORE_GLOBAL_READ_LOCK))) { /* Fatal error */ di->dead= 1; @@ -1698,7 +1776,7 @@ bool delayed_insert::handle_inserts(void) if (thd.killed || table->s->version != refresh_version) { thd.killed= THD::KILL_CONNECTION; - max_rows= ~0; // Do as much as possible + max_rows= ~(uint)0; // Do as much as possible } /* @@ -2014,12 +2092,27 @@ bool select_insert::send_data(List &values) DBUG_RETURN(1); } } - if (!(error= write_record(thd, table,&info)) && table->next_number_field) + if (!(error= write_record(thd, table, &info))) { - /* Clear for next record */ - table->next_number_field->reset(); - if (! last_insert_id && thd->insert_id_used) - last_insert_id=thd->insert_id(); + if (table->triggers) + { + /* + If triggers exist then whey can modify some fields which were not + originally touched by INSERT ... SELECT, so we have to restore + their original values for the next row. + */ + restore_record(table, s->default_values); + } + if (table->next_number_field) + { + /* + Clear auto-increment field for the next record, if triggers are used + we will clear it twice, but this should be cheap. + */ + table->next_number_field->reset(); + if (!last_insert_id && thd->insert_id_used) + last_insert_id= thd->insert_id(); + } } DBUG_RETURN(error); } @@ -2028,9 +2121,11 @@ bool select_insert::send_data(List &values) void select_insert::store_values(List &values) { if (fields->elements) - fill_record(thd, *fields, values, 1); + fill_record_n_invoke_before_triggers(thd, *fields, values, 1, + table->triggers, TRG_EVENT_INSERT); else - fill_record(thd, table->field, values, 1); + fill_record_n_invoke_before_triggers(thd, table->field, values, 1, + table->triggers, TRG_EVENT_INSERT); } void select_insert::send_error(uint errcode,const char *err) @@ -2173,7 +2268,8 @@ select_create::prepare(List &values, SELECT_LEX_UNIT *u) void select_create::store_values(List &values) { - fill_record(thd, field, values, 1); + fill_record_n_invoke_before_triggers(thd, field, values, 1, + table->triggers, TRG_EVENT_INSERT); } diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 7c7939eaf60..574c9966c63 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -423,7 +423,7 @@ static const uint signed_longlong_len=19; static const char *unsigned_longlong_str="18446744073709551615"; static const uint unsigned_longlong_len=20; -inline static uint int_token(const char *str,uint length) +static inline uint int_token(const char *str,uint length) { if (length < long_len) // quick normal case return NUM; @@ -1369,8 +1369,6 @@ bool st_select_lex::test_limit() "LIMIT & IN/ALL/ANY/SOME subquery"); return(1); } - // We need only 1 row to determinate existence - select_limit= 1; // no sense in ORDER BY without LIMIT order_list.empty(); return(0); @@ -1553,7 +1551,7 @@ void st_select_lex::print_limit(THD *thd, String *str) item->substype() == Item_subselect::IN_SUBS || item->substype() == Item_subselect::ALL_SUBS)) { - DBUG_ASSERT(select_limit == 1L && offset_limit == 0L); + DBUG_ASSERT(!item->fixed || select_limit == 1L && offset_limit == 0L); return; } @@ -1756,11 +1754,9 @@ bool st_lex::need_correct_ident() SYNOPSIS st_select_lex_unit::set_limit() values - SELECT_LEX with initial values for counters - sl - SELECT_LEX for options set */ -void st_select_lex_unit::set_limit(SELECT_LEX *values, - SELECT_LEX *sl) +void st_select_lex_unit::set_limit(SELECT_LEX *values) { offset_limit_cnt= values->offset_limit; select_limit_cnt= values->select_limit+values->offset_limit; diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 3e463cb35ce..e297d303f3d 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -445,10 +445,10 @@ public: void print(String *str); - ulong init_prepare_fake_select_lex(THD *thd); + void init_prepare_fake_select_lex(THD *thd); inline bool is_prepared() { return prepared; } bool change_result(select_subselect *result, select_subselect *old_result); - void set_limit(st_select_lex *values, st_select_lex *sl); + void set_limit(st_select_lex *values); friend void lex_start(THD *thd, uchar *buf, uint length); friend int subselect_union_engine::exec(); @@ -635,6 +635,7 @@ typedef class st_select_lex SELECT_LEX; #define ALTER_CHANGE_COLUMN_DEFAULT 256 #define ALTER_KEYS_ONOFF 512 #define ALTER_CONVERT 1024 +#define ALTER_FORCE 2048 typedef struct st_alter_info { diff --git a/sql/sql_list.cc b/sql/sql_list.cc index c99cfb8c918..485c569f49c 100644 --- a/sql/sql_list.cc +++ b/sql/sql_list.cc @@ -15,7 +15,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef __GNUC__ +#include + +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/sql_load.cc b/sql/sql_load.cc index c827bbace3e..cc25839bcc9 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -21,6 +21,8 @@ #include #include #include "sql_repl.h" +#include "sp_head.h" +#include "sql_trigger.h" class READ_INFO { File file; @@ -148,7 +150,7 @@ bool mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, if (open_and_lock_tables(thd, table_list)) DBUG_RETURN(TRUE); if (setup_tables(thd, table_list, &unused_conds, - &thd->lex->select_lex.leaf_tables, FALSE, FALSE)) + &thd->lex->select_lex.leaf_tables, FALSE)) DBUG_RETURN(-1); if (!table_list->table || // do not suport join view !table_list->updatable || // and derived tables @@ -568,7 +570,11 @@ read_fixed_length(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, ER(ER_WARN_TOO_MANY_RECORDS), thd->row_count); } - if (fill_record(thd, set_fields, set_values, ignore_check_option_errors)) + if (thd->killed || + fill_record_n_invoke_before_triggers(thd, set_fields, set_values, + ignore_check_option_errors, + table->triggers, + TRG_EVENT_INSERT)) DBUG_RETURN(1); switch (table_list->view_check_option(thd, @@ -580,7 +586,7 @@ read_fixed_length(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, DBUG_RETURN(-1); } - if (thd->killed || write_record(thd,table,&info)) + if (write_record(thd, table, &info)) DBUG_RETURN(1); thd->no_trans_update= no_trans_update; @@ -592,8 +598,10 @@ read_fixed_length(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, */ if (!id && thd->insert_id_used) id= thd->last_insert_id; - if (table->next_number_field) - table->next_number_field->reset(); // Clear for next record + /* + We don't need to reset auto-increment field since we are restoring + its default value at the beginning of each loop iteration. + */ if (read_info.next_line()) // Skip to next line break; if (read_info.line_cuted) @@ -725,7 +733,11 @@ read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, } } - if (fill_record(thd, set_fields, set_values, ignore_check_option_errors)) + if (thd->killed || + fill_record_n_invoke_before_triggers(thd, set_fields, set_values, + ignore_check_option_errors, + table->triggers, + TRG_EVENT_INSERT)) DBUG_RETURN(1); switch (table_list->view_check_option(thd, @@ -738,7 +750,7 @@ read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, } - if (thd->killed || write_record(thd, table, &info)) + if (write_record(thd, table, &info)) DBUG_RETURN(1); /* If auto_increment values are used, save the first one @@ -748,8 +760,10 @@ read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, */ if (!id && thd->insert_id_used) id= thd->last_insert_id; - if (table->next_number_field) - table->next_number_field->reset(); // Clear for next record + /* + We don't need to reset auto-increment field since we are restoring + its default value at the beginning of each loop iteration. + */ thd->no_trans_update= no_trans_update; if (read_info.next_line()) // Skip to next line break; diff --git a/sql/sql_map.cc b/sql/sql_map.cc index 4bb3482c7e6..556d37a405c 100644 --- a/sql/sql_map.cc +++ b/sql/sql_map.cc @@ -15,7 +15,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef __GNUC__ +#include + +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/sql_map.h b/sql/sql_map.h index 632eb6e4f64..bfa6011ac54 100644 --- a/sql/sql_map.h +++ b/sql/sql_map.h @@ -17,7 +17,7 @@ /* interface for memory mapped files */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ #endif diff --git a/sql/sql_olap.cc b/sql/sql_olap.cc index 07271d40492..b349eda0e2e 100644 --- a/sql/sql_olap.cc +++ b/sql/sql_olap.cc @@ -28,7 +28,9 @@ #ifdef DISABLED_UNTIL_REWRITTEN_IN_4_1 -#ifdef __GNUC__ +#include + +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif @@ -153,8 +155,7 @@ int handle_olaps(LEX *lex, SELECT_LEX *select_lex) if (setup_tables(lex->thd, (TABLE_LIST *)select_lex->table_list.first - &select_lex->where, &select_lex->leaf_tables, - FALSE, FALSE) || + &select_lex->where, &select_lex->leaf_tables, FALSE) || setup_fields(lex->thd, 0, (TABLE_LIST *)select_lex->table_list.first, select_lex->item_list, 1, &all_fields,1) || setup_fields(lex->thd, 0, (TABLE_LIST *)select_lex->table_list.first, diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 0e8f7746f0f..2af9191110c 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -651,7 +651,6 @@ static bool check_mqh(THD *thd, uint check_command) { #ifndef NO_EMBEDDED_ACCESS_CHECKS bool error= 0; - time_t check_time = thd->start_time ? thd->start_time : time(NULL); USER_CONN *uc=thd->user_connect; DBUG_ENTER("check_mqh"); DBUG_ASSERT(uc != 0); @@ -1655,6 +1654,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, while (!thd->killed && thd->lex->found_semicolon && !thd->net.report_error) { char *packet= thd->lex->found_semicolon; + net->no_send_error= 0; /* Multiple queries exits, execute them individually in embedded server - just store them to be executed later @@ -2326,6 +2326,10 @@ mysql_execute_command(THD *thd) } #endif /* !HAVE_REPLICATION */ + + + + /* When option readonly is set deny operations which change tables. Except for the replication thread and the 'super' users. @@ -2768,12 +2772,30 @@ mysql_execute_command(THD *thd) lex->create_info.default_table_charset= lex->create_info.table_charset; lex->create_info.table_charset= 0; } + /* + The create-select command will open and read-lock the select table + and then create, open and write-lock the new table. If a global + read lock steps in, we get a deadlock. The write lock waits for + the global read lock, while the global read lock waits for the + select table to be closed. So we wait until the global readlock is + gone before starting both steps. Note that + wait_if_global_read_lock() sets a protection against a new global + read lock when it succeeds. This needs to be released by + start_waiting_global_read_lock(). We protect the normal CREATE + TABLE in the same way. That way we avoid that a new table is + created during a gobal read lock. + */ + if (wait_if_global_read_lock(thd, 0, 1)) + { + res= -1; + goto unsent_create_error; + } if (select_lex->item_list.elements) // With select { select_result *result; select_lex->options|= SELECT_NO_UNLOCK; - unit->set_limit(select_lex, select_lex); + unit->set_limit(select_lex); if (!(res= open_and_lock_tables(thd, select_tables))) { @@ -2785,7 +2807,7 @@ mysql_execute_command(THD *thd) unique_table(create_table, select_tables)) { my_error(ER_UPDATE_TABLE_USED, MYF(0), create_table->table_name); - goto unsent_create_error; + goto unsent_create_error1; } /* If we create merge table, we have to test tables in merge, too */ if (lex->create_info.used_fields & HA_CREATE_USED_UNION) @@ -2798,7 +2820,7 @@ mysql_execute_command(THD *thd) if (unique_table(tab, select_tables)) { my_error(ER_UPDATE_TABLE_USED, MYF(0), tab->table_name); - goto unsent_create_error; + goto unsent_create_error1; } } } @@ -2841,9 +2863,21 @@ mysql_execute_command(THD *thd) if (!res) send_ok(thd); } + /* + Release the protection against the global read lock and wake + everyone, who might want to set a global read lock. + */ + start_waiting_global_read_lock(thd); lex->link_first_table_back(create_table, link_to_local); break; +unsent_create_error1: + /* + Release the protection against the global read lock and wake + everyone, who might want to set a global read lock. + */ + start_waiting_global_read_lock(thd); + /* put tables back for PS rexecuting */ unsent_create_error: lex->link_first_table_back(create_table, link_to_local); @@ -3171,12 +3205,12 @@ unsent_create_error: select_lex->options|= SELECT_NO_UNLOCK; select_result *result; - unit->set_limit(select_lex, select_lex); + unit->set_limit(select_lex); if (!(res= open_and_lock_tables(thd, all_tables))) { /* Skip first table, which is the table we are inserting in */ - lex->select_lex.table_list.first= (byte*)first_table->next_local; + select_lex->table_list.first= (byte*)first_table->next_local; res= mysql_insert_select_prepare(thd); if (!res && (result= new select_insert(first_table, first_table->table, @@ -3188,13 +3222,13 @@ unsent_create_error: insert/replace from SELECT give its SELECT_LEX for SELECT, and item_list belong to SELECT */ - lex->select_lex.resolve_mode= SELECT_LEX::SELECT_MODE; + select_lex->resolve_mode= SELECT_LEX::SELECT_MODE; res= handle_select(thd, lex, result, OPTION_SETUP_TABLES_DONE); - lex->select_lex.resolve_mode= SELECT_LEX::INSERT_MODE; + select_lex->resolve_mode= SELECT_LEX::INSERT_MODE; delete result; } /* revert changes for SP */ - lex->select_lex.table_list.first= (byte*) first_table; + select_lex->table_list.first= (byte*) first_table; } if (first_table->view && !first_table->contain_auto_increment) @@ -3987,7 +4021,7 @@ unsent_create_error: lex->sphead= 0; #ifndef NO_EMBEDDED_ACCESS_CHECKS /* only add privileges if really neccessary */ - if (sp_automatic_privileges && + if (sp_automatic_privileges && !opt_noacl && check_routine_access(thd, DEFAULT_CREATE_PROC_ACLS, db, name, lex->sql_command == SQLCOM_CREATE_PROCEDURE, 1)) @@ -4014,6 +4048,12 @@ unsent_create_error: delete lex->sphead; lex->sphead= 0; goto error; + case SP_BAD_IDENTIFIER: + my_error(ER_TOO_LONG_IDENT, MYF(0), name); + lex->unit.cleanup(); + delete lex->sphead; + lex->sphead= 0; + goto error; default: my_error(ER_SP_STORE_FAILED, MYF(0), SP_TYPE_STRING(lex), name); lex->unit.cleanup(); @@ -4256,7 +4296,7 @@ unsent_create_error: lex->sql_command == SQLCOM_DROP_PROCEDURE, 0)) goto error; #ifndef NO_EMBEDDED_ACCESS_CHECKS - if (sp_automatic_privileges && + if (sp_automatic_privileges && !opt_noacl && sp_revoke_privileges(thd, db, name, lex->sql_command == SQLCOM_DROP_PROCEDURE)) { @@ -4981,11 +5021,18 @@ long max_stack_used; #endif #ifndef EMBEDDED_LIBRARY -bool check_stack_overrun(THD *thd,char *buf __attribute__((unused))) +/* + Note: The 'buf' parameter is necessary, even if it is unused here. + - fix_fields functions has a "dummy" buffer large enough for the + corresponding exec. (Thus we only have to check in fix_fields.) + - Passing to check_stack_overrun() prevents the compiler from removing it. + */ +bool check_stack_overrun(THD *thd, long margin, + char *buf __attribute__((unused))) { long stack_used; if ((stack_used=used_stack(thd->thread_stack,(char*) &stack_used)) >= - (long) thread_stack_min) + thread_stack - margin) { sprintf(errbuff[0],ER(ER_STACK_OVERRUN),stack_used,thread_stack); my_message(ER_STACK_OVERRUN,errbuff[0],MYF(0)); @@ -5198,6 +5245,7 @@ void mysql_init_multi_delete(LEX *lex) lex->select_lex.select_limit= lex->unit.select_limit_cnt= HA_POS_ERROR; lex->select_lex.table_list.save_and_clear(&lex->auxilliary_table_list); + lex->lock_option= using_update_log ? TL_READ_NO_INSERT : TL_READ; lex->query_tables= 0; lex->query_tables_last= &lex->query_tables; } @@ -6776,6 +6824,14 @@ bool multi_delete_precheck(THD *thd, TABLE_LIST *tables, uint *table_count) } walk->lock_type= target_tbl->lock_type; target_tbl->correspondent_table= walk; // Remember corresponding table + + /* in case of subselects, we need to set lock_type in + * corresponding table in list of all tables */ + if (walk->correspondent_table) + { + target_tbl->correspondent_table= walk->correspondent_table; + walk->correspondent_table->lock_type= walk->lock_type; + } } DBUG_RETURN(FALSE); } @@ -6909,6 +6965,8 @@ bool create_table_precheck(THD *thd, TABLE_LIST *tables, { /* Check permissions for used tables in CREATE TABLE ... SELECT */ +#ifdef NOT_NECESSARY_TO_CHECK_CREATE_TABLE_EXIST_WHEN_PREPARING_STATEMENT + /* This code throws an ill error for CREATE TABLE t1 SELECT * FROM t1 */ /* Only do the check for PS, becasue we on execute we have to check that against the opened tables to ensure we don't use a table that is part @@ -6927,6 +6985,7 @@ bool create_table_precheck(THD *thd, TABLE_LIST *tables, goto err; } } +#endif if (tables && check_table_access(thd, SELECT_ACL, tables,0)) goto err; } diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 0dcfd985f88..71cebb61ae6 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -1478,9 +1478,12 @@ bool show_binlog_info(THD* thd) bool show_binlogs(THD* thd) { IO_CACHE *index_file; + LOG_INFO cur; + File file; char fname[FN_REFLEN]; List field_list; uint length; + int cur_dir_len; Protocol *protocol= thd->protocol; DBUG_ENTER("show_binlogs"); @@ -1491,21 +1494,44 @@ bool show_binlogs(THD* thd) } field_list.push_back(new Item_empty_string("Log_name", 255)); + field_list.push_back(new Item_return_int("File_size", 20, + MYSQL_TYPE_LONGLONG)); if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) DBUG_RETURN(TRUE); mysql_bin_log.lock_index(); index_file=mysql_bin_log.get_index_file(); - + + mysql_bin_log.get_current_log(&cur); + cur_dir_len= dirname_length(cur.log_file_name); + reinit_io_cache(index_file, READ_CACHE, (my_off_t) 0, 0, 0); /* The file ends with EOF or empty line */ while ((length=my_b_gets(index_file, fname, sizeof(fname))) > 1) { + int dir_len; + ulonglong file_length= 0; // Length if open fails + fname[--length] = '\0'; // remove the newline + protocol->prepare_for_resend(); - int dir_len = dirname_length(fname); - /* The -1 is for removing newline from fname */ - protocol->store(fname + dir_len, length-1-dir_len, &my_charset_bin); + dir_len= dirname_length(fname); + length-= dir_len; + protocol->store(fname + dir_len, length, &my_charset_bin); + + if (!(strncmp(fname+dir_len, cur.log_file_name+cur_dir_len, length))) + file_length= cur.pos; /* The active log, use the active position */ + else + { + /* this is an old log, open it and find the size */ + if ((file= my_open(fname+dir_len, O_RDONLY | O_SHARE | O_BINARY, + MYF(0))) >= 0) + { + file_length= (ulonglong) my_seek(file, 0L, MY_SEEK_END, MYF(0)); + my_close(file, MYF(0)); + } + } + protocol->store(file_length); if (protocol->write()) goto err; } diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 811fdc69ba7..429ffb90ba8 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -17,7 +17,9 @@ /* mysql_select and join optimization */ -#ifdef __GNUC__ +#include + +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif @@ -35,7 +37,7 @@ const char *join_type_str[]={ "UNKNOWN","system","const","eq_ref","ref", }; const key_map key_map_empty(0); -const key_map key_map_full(~0); +const key_map key_map_full(~(uint)0); static void optimize_keyuse(JOIN *join, DYNAMIC_ARRAY *keyuse_array); static bool make_join_statistics(JOIN *join, TABLE_LIST *leaves, COND *conds, @@ -233,7 +235,7 @@ bool handle_select(THD *thd, LEX *lex, select_result *result, else { SELECT_LEX_UNIT *unit= &lex->unit; - unit->set_limit(unit->global_parameters, select_lex); + unit->set_limit(unit->global_parameters); /* 'options' of mysql_select will be set in JOIN, as far as JOIN for every PS/SP execution new, we will not need reset this flag if @@ -342,7 +344,7 @@ JOIN::prepare(Item ***rref_pointer_array, if ((!(select_options & OPTION_SETUP_TABLES_DONE) && setup_tables(thd, tables_list, &conds, &select_lex->leaf_tables, - FALSE, FALSE)) || + FALSE)) || setup_wild(thd, tables_list, fields_list, &all_fields, wild_num) || select_lex->setup_ref_array(thd, og_num) || setup_fields(thd, (*rref_pointer_array), tables_list, fields_list, 1, @@ -465,13 +467,6 @@ JOIN::prepare(Item ***rref_pointer_array, count_field_types(&tmp_table_param, all_fields, 0); ref_pointer_array_size= all_fields.elements*sizeof(Item*); this->group= group_list != 0; - row_limit= ((select_distinct || order || group_list) ? HA_POS_ERROR : - unit_arg->select_limit_cnt); - /* select_limit is used to decide if we are likely to scan the whole table */ - select_limit= unit_arg->select_limit_cnt; - if (having || (select_options & OPTION_FOUND_ROWS)) - select_limit= HA_POS_ERROR; - do_send_rows = (unit_arg->select_limit_cnt) ? 1 : 0; unit= unit_arg; #ifdef RESTRICTED_GROUP @@ -550,6 +545,13 @@ JOIN::optimize() DBUG_RETURN(0); optimized= 1; + row_limit= ((select_distinct || order || group_list) ? HA_POS_ERROR : + unit->select_limit_cnt); + /* select_limit is used to decide if we are likely to scan the whole table */ + select_limit= unit->select_limit_cnt; + if (having || (select_options & OPTION_FOUND_ROWS)) + select_limit= HA_POS_ERROR; + do_send_rows = (unit->select_limit_cnt) ? 1 : 0; // Ignore errors of execution if option IGNORE present if (thd->lex->ignore) thd->lex->current_select->no_error= 1; @@ -1110,18 +1112,7 @@ int JOIN::reinit() { DBUG_ENTER("JOIN::reinit"); - /* TODO move to unit reinit */ - unit->set_limit(select_lex, select_lex); - /* conds should not be used here, it is added just for safety */ - if (tables_list) - { - if (setup_tables(thd, tables_list, &conds, &select_lex->leaf_tables, - TRUE, FALSE)) - DBUG_RETURN(1); - } - - /* Reset of sum functions */ first_record= 0; if (exec_tmp_table1) @@ -1147,6 +1138,7 @@ JOIN::reinit() if (tmp_join) restore_tmp(); + /* Reset of sum functions */ if (sum_funcs) { Item_sum *func, **func_ptr= sum_funcs; @@ -2825,17 +2817,14 @@ add_key_fields(KEY_FIELD **key_fields,uint *and_level, if (cond_func->functype() == Item_func::NOT_FUNC) { Item *item= cond_func->arguments()[0]; - /* - At this moment all NOT before simple comparison predicates - are eliminated. NOT IN and NOT BETWEEN are treated similar - IN and BETWEEN respectively. + /* + At this moment all NOT before simple comparison predicates + are eliminated. NOT IN and NOT BETWEEN are treated similar + IN and BETWEEN respectively. */ if (item->type() == Item::FUNC_ITEM && ((Item_func *) item)->select_optimize() == Item_func::OPTIMIZE_KEY) - { add_key_fields(key_fields,and_level,item,usable_tables); - return; - } return; } switch (cond_func->select_optimize()) { @@ -3799,8 +3788,7 @@ choose_plan(JOIN *join, table_map join_tables) Don't update last_query_cost for 'show status' command */ if (join->thd->lex->orig_sql_command != SQLCOM_SHOW_STATUS) - last_query_cost= join->best_read; - + join->thd->status_var.last_query_cost= join->best_read; DBUG_VOID_RETURN; } @@ -5100,7 +5088,7 @@ make_simple_join(JOIN *join,TABLE *tmp_table) join_tab->select_cond=0; join_tab->quick=0; join_tab->type= JT_ALL; /* Map through all records */ - join_tab->keys.init(~0); /* test everything in quick */ + join_tab->keys.init(~(uint)0); /* test everything in quick */ join_tab->info=0; join_tab->on_expr_ref=0; join_tab->last_inner= 0; @@ -12322,7 +12310,7 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param, { Item *pos; List_iterator_fast li(all_fields); - Copy_field *copy; + Copy_field *copy= NULL; res_selected_fields.empty(); res_all_fields.empty(); List_iterator_fast itr(res_all_fields); @@ -12330,7 +12318,8 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param, uint i, border= all_fields.elements - elements; DBUG_ENTER("setup_copy_fields"); - if (!(copy=param->copy_field= new Copy_field[param->field_count])) + if (param->field_count && + !(copy=param->copy_field= new Copy_field[param->field_count])) goto err2; param->copy_funcs.empty(); @@ -12369,9 +12358,12 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param, char *tmp=(char*) sql_alloc(field->pack_length()+1); if (!tmp) goto err; - copy->set(tmp, item->result_field); - item->result_field->move_field(copy->to_ptr,copy->to_null_ptr,1); - copy++; + if (copy) + { + copy->set(tmp, item->result_field); + item->result_field->move_field(copy->to_ptr,copy->to_null_ptr,1); + copy++; + } } } else if ((pos->type() == Item::FUNC_ITEM || @@ -12414,7 +12406,8 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param, DBUG_RETURN(0); err: - delete [] param->copy_field; // This is never 0 + if (copy) + delete [] param->copy_field; // This is never 0 param->copy_field=0; err2: DBUG_RETURN(TRUE); @@ -12821,6 +12814,76 @@ void free_underlaid_joins(THD *thd, SELECT_LEX *select) ROLLUP handling ****************************************************************************/ +/* + Replace occurences of group by fields in an expression by ref items + + SYNOPSIS + change_group_ref() + thd reference to the context + expr expression to make replacement + group_list list of references to group by items + changed out: returns 1 if item contains a replaced field item + + DESCRIPTION + The function replaces occurrences of group by fields in expr + by ref objects for these fields unless they are under aggregate + functions. + + IMPLEMENTATION + The function recursively traverses the tree of the expr expression, + looks for occurrences of the group by fields that are not under + aggregate functions and replaces them for the corresponding ref items. + + NOTES + This substitution is needed GROUP BY queries with ROLLUP if + SELECT list contains expressions over group by attributes. + + EXAMPLES + SELECT a+1 FROM t1 GROUP BY a WITH ROLLUP + SELECT SUM(a)+a FROM t1 GROUP BY a WITH ROLLUP + + RETURN + 0 if ok + 1 on error +*/ + +static bool change_group_ref(THD *thd, Item_func *expr, ORDER *group_list, + bool *changed) +{ + if (expr->arg_count) + { + Item **arg,**arg_end; + for (arg= expr->arguments(), + arg_end= expr->arguments()+expr->arg_count; + arg != arg_end; arg++) + { + Item *item= *arg; + if (item->type() == Item::FIELD_ITEM || item->type() == Item::REF_ITEM) + { + ORDER *group_tmp; + for (group_tmp= group_list; group_tmp; group_tmp= group_tmp->next) + { + if (item->eq(*group_tmp->item,0)) + { + Item *new_item; + if(!(new_item= new Item_ref(group_tmp->item, 0, item->name))) + return 1; // fatal_error is set + thd->change_item_tree(arg, new_item); + *changed= TRUE; + } + } + } + else if (item->type() == Item::FUNC_ITEM) + { + if (change_group_ref(thd, (Item_func *) item, group_list, changed)) + return 1; + } + } + } + return 0; +} + + /* Allocate memory needed for other rollup functions */ bool JOIN::rollup_init() @@ -12865,19 +12928,31 @@ bool JOIN::rollup_init() for (j=0 ; j < fields_list.elements ; j++) rollup.fields[i].push_back(rollup.null_items[i]); } - List_iterator_fast it(fields_list); + List_iterator_fast it(all_fields); Item *item; while ((item= it++)) { ORDER *group_tmp; for (group_tmp= group_list; group_tmp; group_tmp= group_tmp->next) { - if (*group_tmp->item == item) + if (item->eq(*group_tmp->item,0)) item->maybe_null= 1; } + if (item->type() == Item::FUNC_ITEM) + { + bool changed= 0; + if (change_group_ref(thd, (Item_func *) item, group_list, &changed)) + return 1; + /* + We have to prevent creation of a field in a temporary table for + an expression that contains GROUP BY attributes. + Marking the expression item as 'with_sum_func' will ensure this. + */ + if (changed) + item->with_sum_func= 1; + } } return 0; - } @@ -12973,14 +13048,14 @@ bool JOIN::rollup_make_fields(List &fields_arg, List &sel_fields, *(*func)= (Item_sum*) item; (*func)++; } - else if (real_fields) + else { /* Check if this is something that is part of this group by */ ORDER *group_tmp; for (group_tmp= start_group, i= pos ; group_tmp ; group_tmp= group_tmp->next, i++) { - if (*group_tmp->item == item) + if (item->eq(*group_tmp->item,0)) { Item_null_result *null_item; /* @@ -13490,7 +13565,7 @@ bool mysql_explain_union(THD *thd, SELECT_LEX_UNIT *unit, select_result *result) else { thd->lex->current_select= first; - unit->set_limit(unit->global_parameters, first); + unit->set_limit(unit->global_parameters); res= mysql_select(thd, &first->ref_pointer_array, (TABLE_LIST*) first->table_list.first, first->with_wild, first->item_list, diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 267d584d9eb..32ad85b88f7 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -396,7 +396,8 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list) else { if (table_list->schema_table) - protocol->store(table_list->schema_table_name, system_charset_info); + protocol->store(table_list->schema_table->table_name, + system_charset_info); else protocol->store(table->alias, system_charset_info); if (store_create_info(thd, table_list, &buffer)) @@ -757,7 +758,7 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet) else packet->append("CREATE TABLE ", 13); if (table_list->schema_table) - alias= table_list->schema_table_name; + alias= table_list->schema_table->table_name; else alias= (lower_case_table_names == 2 ? table->alias : share->table_name); @@ -1382,8 +1383,9 @@ static bool show_status_array(THD *thd, const char *wild, end= strend(pos); break; } - case SHOW_DOUBLE: + case SHOW_DOUBLE_STATUS: { + value= ((char *) status_var + (ulong) value); end= buff + sprintf(buff, "%f", *(double*) value); break; } diff --git a/sql/sql_string.cc b/sql/sql_string.cc index 0424723d97f..be4354227a5 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -16,11 +16,12 @@ /* This file is originally from the mysql distribution. Coded by monty */ -#ifdef __GNUC__ +#include + +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif -#include #include #include #include diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 4ddef3fc653..d98ae778bcf 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -40,6 +40,34 @@ static int copy_data_between_tables(TABLE *from,TABLE *to, ha_rows *copied,ha_rows *deleted); static bool prepare_blob_field(THD *thd, create_field *sql_field); + +/* + Build the path to a file for a table (or the base path that can + then have various extensions stuck on to it). + + SYNOPSIS + build_table_path() + buff Buffer to build the path into + bufflen sizeof(buff) + db Name of database + table Name of table + ext Filename extension + + RETURN + 0 Error + # Size of path + */ + +static uint build_table_path(char *buff, size_t bufflen, const char *db, + const char *table, const char *ext) +{ + strxnmov(buff, bufflen-1, mysql_data_home, "/", db, "/", table, ext, + NullS); + return unpack_filename(buff,buff); +} + + + /* delete (drop) tables. @@ -223,8 +251,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, } alias= (lower_case_table_names == 2) ? table->alias : table->table_name; /* remove form file and isam files */ - strxmov(path, mysql_data_home, "/", db, "/", alias, reg_ext, NullS); - (void) unpack_filename(path,path); + build_table_path(path, sizeof(path), db, alias, reg_ext); } if (drop_temporary || (access(path,F_OK) && @@ -316,13 +343,10 @@ int quick_rm_table(enum db_type base,const char *db, { char path[FN_REFLEN]; int error=0; - my_snprintf(path, sizeof(path), "%s/%s/%s%s", - mysql_data_home, db, table_name, reg_ext); - unpack_filename(path,path); + build_table_path(path, sizeof(path), db, table_name, reg_ext); if (my_delete(path,MYF(0))) error=1; /* purecov: inspected */ - my_snprintf(path, sizeof(path), "%s/%s/%s", mysql_data_home, db, table_name); - unpack_filename(path,path); + build_table_path(path, sizeof(path), db, table_name, ""); return ha_delete_table(current_thd, base, path, table_name, 0) || error; } @@ -1516,11 +1540,9 @@ bool mysql_create_table(THD *thd,const char *db, const char *table_name, if (!create_info->default_table_charset) { HA_CREATE_INFO db_info; - uint length; char path[FN_REFLEN]; - strxmov(path, mysql_data_home, "/", db, NullS); - length= unpack_dirname(path,path); // Convert if not unix - strmov(path+length, MY_DB_OPT_FILE); + /* Abuse build_table_path() to build the path to the db.opt file */ + build_table_path(path, sizeof(path), db, MY_DB_OPT_FILE, ""); load_db_opt(thd, path, &db_info); create_info->default_table_charset= db_info.default_table_charset; } @@ -1534,17 +1556,18 @@ bool mysql_create_table(THD *thd,const char *db, const char *table_name, /* Check if table exists */ if (create_info->options & HA_LEX_CREATE_TMP_TABLE) { - my_snprintf(path, sizeof(path), "%s%s%lx_%lx_%x%s", - mysql_tmpdir, tmp_file_prefix, current_pid, thd->thread_id, - thd->tmp_table++, reg_ext); + char tmp_table_name[NAME_LEN+1]; + my_snprintf(tmp_table_name, sizeof(tmp_table_name), "%s%lx_%lx_%x", + tmp_file_prefix, current_pid, thd->thread_id, + thd->tmp_table++); if (lower_case_table_names) - my_casedn_str(files_charset_info, path); + my_casedn_str(files_charset_info, tmp_table_name); create_info->table_options|=HA_CREATE_DELAY_KEY_WRITE; + build_table_path(path, sizeof(path), db, tmp_table_name, reg_ext); } else - my_snprintf(path, sizeof(path), "%s/%s/%s%s", mysql_data_home, db, - alias, reg_ext); - unpack_filename(path,path); + build_table_path(path, sizeof(path), db, alias, reg_ext); + /* Check if table already exists */ if ((create_info->options & HA_LEX_CREATE_TMP_TABLE) && find_temporary_table(thd,db,table_name)) @@ -1756,7 +1779,7 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, } table->reginfo.lock_type=TL_WRITE; - if (!((*lock)= mysql_lock_tables(thd, &table,1))) + if (! ((*lock)= mysql_lock_tables(thd, &table, 1, MYSQL_LOCK_IGNORE_FLUSH))) { VOID(pthread_mutex_lock(&LOCK_open)); hash_delete(&open_cache,(byte*) table); @@ -1781,40 +1804,43 @@ mysql_rename_table(enum db_type base, const char *new_db, const char *new_name) { - char from[FN_REFLEN], to[FN_REFLEN]; - char tmp_from[NAME_LEN+1], tmp_to[NAME_LEN+1]; + char from[FN_REFLEN], to[FN_REFLEN], lc_from[FN_REFLEN], lc_to[FN_REFLEN]; + char *from_base= from, *to_base= to; + char tmp_name[NAME_LEN+1]; handler *file=(base == DB_TYPE_UNKNOWN ? 0 : get_new_handler((TABLE*) 0, base)); int error=0; DBUG_ENTER("mysql_rename_table"); + build_table_path(from, sizeof(from), old_db, old_name, ""); + build_table_path(to, sizeof(to), new_db, new_name, ""); + + /* + If lower_case_table_names == 2 (case-preserving but case-insensitive + file system) and the storage is not HA_FILE_BASED, we need to provide + a lowercase file name, but we leave the .frm in mixed case. + */ if (lower_case_table_names == 2 && file && !(file->table_flags() & HA_FILE_BASED)) { - /* Table handler expects to get all file names as lower case */ - strmov(tmp_from, old_name); - my_casedn_str(files_charset_info, tmp_from); - old_name= tmp_from; + strmov(tmp_name, old_name); + my_casedn_str(files_charset_info, tmp_name); + build_table_path(lc_from, sizeof(lc_from), old_db, tmp_name, ""); + from_base= lc_from; - strmov(tmp_to, new_name); - my_casedn_str(files_charset_info, tmp_to); - new_name= tmp_to; + strmov(tmp_name, new_name); + my_casedn_str(files_charset_info, tmp_name); + build_table_path(lc_to, sizeof(lc_to), new_db, tmp_name, ""); + to_base= lc_to; } - my_snprintf(from, sizeof(from), "%s/%s/%s", - mysql_data_home, old_db, old_name); - my_snprintf(to, sizeof(to), "%s/%s/%s", - mysql_data_home, new_db, new_name); - fn_format(from,from,"","",4); - fn_format(to,to, "","",4); - if (!file || - !(error=file->rename_table((const char*) from,(const char *) to))) + if (!file || !(error=file->rename_table(from_base, to_base))) { if (rename_file_ext(from,to,reg_ext)) { error=my_errno; /* Restore old file name */ if (file) - file->rename_table((const char*) to,(const char *) from); + file->rename_table(to_base, from_base); } } delete file; @@ -1991,8 +2017,8 @@ static int prepare_for_repair(THD* thd, TABLE_LIST *table_list, if (!(table= table_list->table)) /* if open_ltable failed */ { char name[FN_REFLEN]; - strxmov(name, mysql_data_home, "/", table_list->db, "/", - table_list->table_name, NullS); + build_table_path(name, sizeof(name), table_list->db, + table_list->table_name, ""); if (openfrm(thd, name, "", 0, 0, 0, &tmp_table)) DBUG_RETURN(0); // Can't open frm file table= &tmp_table; @@ -2202,12 +2228,14 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, if ((table->table->db_stat & HA_READ_ONLY) && open_for_modify) { char buff[FN_REFLEN + MYSQL_ERRMSG_SIZE]; + uint length; protocol->prepare_for_resend(); protocol->store(table_name, system_charset_info); protocol->store(operator_name, system_charset_info); protocol->store("error", 5, system_charset_info); - my_snprintf(buff, sizeof(buff), ER(ER_OPEN_AS_READONLY), table_name); - protocol->store(buff, system_charset_info); + length= my_snprintf(buff, sizeof(buff), ER(ER_OPEN_AS_READONLY), + table_name); + protocol->store(buff, length, system_charset_info); close_thread_tables(thd); table->table=0; // For query cache if (protocol->write()) @@ -2238,6 +2266,17 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, open_for_modify= 0; } + if (table->table->s->crashed && operator_func == &handler::check) + { + protocol->prepare_for_resend(); + protocol->store(table_name, system_charset_info); + protocol->store(operator_name, system_charset_info); + protocol->store("warning", 7, system_charset_info); + protocol->store("Table is marked as crashed", 26, system_charset_info); + if (protocol->write()) + goto err; + } + result_code = (table->table->file->*operator_func)(thd, check_opt); send_result: @@ -2314,6 +2353,28 @@ send_result_message: ((result_code= table->table->file->analyze(thd, check_opt)) > 0)) result_code= 0; // analyze went ok } + if (result_code) // either mysql_recreate_table or analyze failed + { + const char *err_msg; + if ((err_msg= thd->net.last_error)) + { + if (!thd->vio_ok()) + { + sql_print_error(err_msg); + } + else + { + /* Hijack the row already in-progress. */ + protocol->store("error", 5, system_charset_info); + protocol->store(err_msg, system_charset_info); + (void)protocol->write(); + /* Start off another row for HA_ADMIN_FAILED */ + protocol->prepare_for_resend(); + protocol->store(table_name, system_charset_info); + protocol->store(operator_name, system_charset_info); + } + } + } result_code= result_code ? HA_ADMIN_FAILED : HA_ADMIN_OK; table->next_local= save_next_local; table->next_global= save_next_global; @@ -2845,11 +2906,10 @@ int mysql_create_indexes(THD *thd, TABLE_LIST *table_list, List &keys) else { if (table->file->add_index(table, key_info_buffer, key_count)|| - (my_snprintf(path, sizeof(path), "%s/%s/%s%s", mysql_data_home, - table_list->db, (lower_case_table_names == 2) ? - table_list->alias: table_list->table_name, reg_ext) >= - (int) sizeof(path)) || - ! unpack_filename(path, path) || + build_table_path(path, sizeof(path), table_list->db, + (lower_case_table_names == 2) ? + table_list->alias : table_list->table_name, + reg_ext) != 0 || mysql_create_frm(thd, path, &create_info, fields, key_count, key_info_buffer, table->file)) /* don't need to free((gptr) key_info_buffer);*/ @@ -2947,11 +3007,10 @@ int mysql_drop_indexes(THD *thd, TABLE_LIST *table_list, &keys, /*tmp_table*/ 0, &db_options, table->file, &key_info_buffer, key_count, /*select_field_count*/ 0)|| - (snprintf(path, sizeof(path), "%s/%s/%s%s", mysql_data_home, - table_list->db, (lower_case_table_names == 2)? - table_list->alias: table_list->table_name, reg_ext)>= - (int)sizeof(path))|| - ! unpack_filename(path, path)|| + build_table_path(path, sizeof(path), table_list->db, + (lower_case_table_names == 2) ? + table_list->alias : table_list->table_name, + reg_ext) != 0 || mysql_create_frm(thd, path, &create_info, fields, key_count, key_info_buffer, table->file)) /*don't need to free((gptr) key_numbers);*/ @@ -3705,9 +3764,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, shutdown. */ char path[FN_REFLEN]; - my_snprintf(path, sizeof(path), "%s/%s/%s", mysql_data_home, - new_db, table_name); - fn_format(path,path,"","",4); + build_table_path(path, sizeof(path), new_db, table_name, ""); table=open_temporary_table(thd, path, new_db, tmp_name,0); if (table) { diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index 670c618bec5..95524a6dfbf 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -85,7 +85,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) DBUG_RETURN(TRUE); } - if (!(table->triggers= new (&table->mem_root) Table_triggers_list())) + if (!(table->triggers= new (&table->mem_root) Table_triggers_list(table))) DBUG_RETURN(TRUE); } @@ -190,17 +190,16 @@ bool Table_triggers_list::create_trigger(THD *thd, TABLE_LIST *tables) to other tables from trigger we won't be able to catch changes in other tables... - To simplify code a bit we have to create Fields for accessing to old row - values if we have ON UPDATE trigger. + Since we don't plan to access to contents of the fields it does not + matter that we choose for both OLD and NEW values the same versions + of Field objects here. */ - if (!old_field && lex->trg_chistics.event == TRG_EVENT_UPDATE && - prepare_old_row_accessors(table)) - return 1; + old_field= new_field= table->field; for (trg_field= (Item_trigger_field *)(lex->trg_table_fields.first); trg_field; trg_field= trg_field->next_trg_field) { - trg_field->setup_field(thd, table, lex->trg_chistics.event); + trg_field->setup_field(thd, table); if (!trg_field->fixed && trg_field->fix_fields(thd, (TABLE_LIST *)0, (Item **)0)) return 1; @@ -318,34 +317,35 @@ Table_triggers_list::~Table_triggers_list() for (int j= 0; j < 2; j++) delete bodies[i][j]; - if (old_field) - for (Field **fld_ptr= old_field; *fld_ptr; fld_ptr++) + if (record1_field) + for (Field **fld_ptr= record1_field; *fld_ptr; fld_ptr++) delete *fld_ptr; } /* - Prepare array of Field objects which will represent OLD.* row values in - ON UPDATE trigger (by referencing to record[1] instead of record[0]). + Prepare array of Field objects referencing to TABLE::record[1] instead + of record[0] (they will represent OLD.* row values in ON UPDATE trigger + and in ON DELETE trigger which will be called during REPLACE execution). SYNOPSIS - prepare_old_row_accessors() + prepare_record1_accessors() table - pointer to TABLE object for which we are creating fields. RETURN VALUE False - success True - error */ -bool Table_triggers_list::prepare_old_row_accessors(TABLE *table) +bool Table_triggers_list::prepare_record1_accessors(TABLE *table) { Field **fld, **old_fld; - if (!(old_field= (Field **)alloc_root(&table->mem_root, - (table->s->fields + 1) * - sizeof(Field*)))) + if (!(record1_field= (Field **)alloc_root(&table->mem_root, + (table->s->fields + 1) * + sizeof(Field*)))) return 1; - for (fld= table->field, old_fld= old_field; *fld; fld++, old_fld++) + for (fld= table->field, old_fld= record1_field; *fld; fld++, old_fld++) { /* QQ: it is supposed that it is ok to use this function for field @@ -406,7 +406,7 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db, parser->type()->length)) { Table_triggers_list *triggers= - new (&table->mem_root) Table_triggers_list(); + new (&table->mem_root) Table_triggers_list(table); if (!triggers) DBUG_RETURN(1); @@ -417,8 +417,11 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db, table->triggers= triggers; - /* TODO: This could be avoided if there is no ON UPDATE trigger. */ - if (triggers->prepare_old_row_accessors(table)) + /* + TODO: This could be avoided if there is no triggers + for UPDATE and DELETE. + */ + if (triggers->prepare_record1_accessors(table)) DBUG_RETURN(1); List_iterator_fast it(triggers->definitions_list); @@ -478,7 +481,7 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db, (Item_trigger_field *)(lex.trg_table_fields.first); trg_field; trg_field= trg_field->next_trg_field) - trg_field->setup_field(thd, table, lex.trg_chistics.event); + trg_field->setup_field(thd, table); lex_end(&lex); } diff --git a/sql/sql_trigger.h b/sql/sql_trigger.h index 90c906fc72f..d61da8ff06b 100644 --- a/sql/sql_trigger.h +++ b/sql/sql_trigger.h @@ -8,10 +8,20 @@ class Table_triggers_list: public Sql_alloc /* Triggers as SPs grouped by event, action_time */ sp_head *bodies[3][2]; /* - Copy of TABLE::Field array with field pointers set to old version - of record, used for OLD values in trigger on UPDATE. + Copy of TABLE::Field array with field pointers set to TABLE::record[1] + buffer instead of TABLE::record[0] (used for OLD values in on UPDATE + trigger and DELETE trigger when it is called for REPLACE). */ + Field **record1_field; + /* + During execution of trigger new_field and old_field should point to the + array of fields representing new or old version of row correspondingly + (so it can point to TABLE::field or to Tale_triggers_list::record1_field) + */ + Field **new_field; Field **old_field; + /* TABLE instance for which this triggers list object was created */ + TABLE *table; /* Names of triggers. Should correspond to order of triggers on definitions_list, @@ -26,8 +36,8 @@ public: */ List definitions_list; - Table_triggers_list(): - old_field(0) + Table_triggers_list(TABLE *table_arg): + record1_field(0), table(table_arg) { bzero((char *)bodies, sizeof(bodies)); } @@ -36,7 +46,8 @@ public: bool create_trigger(THD *thd, TABLE_LIST *table); bool drop_trigger(THD *thd, TABLE_LIST *table); bool process_triggers(THD *thd, trg_event_type event, - trg_action_time_type time_type) + trg_action_time_type time_type, + bool old_row_is_record1) { int res= 0; @@ -48,6 +59,17 @@ public: thd->net.no_send_ok= TRUE; #endif + if (old_row_is_record1) + { + old_field= record1_field; + new_field= table->field; + } + else + { + new_field= record1_field; + old_field= table->field; + } + /* FIXME: We should juggle with security context here (because trigger should be invoked with creator rights). @@ -79,8 +101,13 @@ public: bodies[TRG_EVENT_DELETE][TRG_ACTION_AFTER]); } + bool has_before_update_triggers() + { + return test(bodies[TRG_EVENT_UPDATE][TRG_ACTION_BEFORE]); + } + friend class Item_trigger_field; private: - bool prepare_old_row_accessors(TABLE *table); + bool prepare_record1_accessors(TABLE *table); }; diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc index 1e1a5683d09..7c6e88306d9 100644 --- a/sql/sql_udf.cc +++ b/sql/sql_udf.cc @@ -28,7 +28,9 @@ dynamic functions, so this shouldn't be a real problem. */ -#ifdef __GNUC__ +#include + +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: implement sql_udf.h #endif diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 00770ba02a2..8d36889df76 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -115,27 +115,15 @@ bool select_union::flush() options of SELECT */ -ulong +void st_select_lex_unit::init_prepare_fake_select_lex(THD *thd) { - ulong options_tmp= thd->options | fake_select_lex->options; thd->lex->current_select= fake_select_lex; - offset_limit_cnt= global_parameters->offset_limit; - select_limit_cnt= global_parameters->select_limit + - global_parameters->offset_limit; - - if (select_limit_cnt < global_parameters->select_limit) - select_limit_cnt= HA_POS_ERROR; // no limit - if (select_limit_cnt == HA_POS_ERROR) - options_tmp&= ~OPTION_FOUND_ROWS; - else if (found_rows_for_union && !thd->lex->describe) - options_tmp|= OPTION_FOUND_ROWS; fake_select_lex->ftfunc_list_alloc.empty(); fake_select_lex->ftfunc_list= &fake_select_lex->ftfunc_list_alloc; fake_select_lex->table_list.link_in_list((byte *)&result_table_list, (byte **) &result_table_list.next_local); - return options_tmp; } @@ -217,11 +205,9 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, goto err; thd_arg->lex->current_select= sl; - set_limit(sl, sl); - can_skip_order_by= is_union && - (!sl->braces || select_limit_cnt == HA_POS_ERROR); - + can_skip_order_by= is_union && !(sl->braces && sl->explicit_limit); + res= join->prepare(&sl->ref_pointer_array, (TABLE_LIST*) sl->table_list.first, sl->with_wild, sl->where, @@ -340,7 +326,7 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, if (arena->is_stmt_prepare()) { /* prepare fake select to initialize it correctly */ - (void) init_prepare_fake_select_lex(thd); + init_prepare_fake_select_lex(thd); /* Should be done only once (the only item_list per statement). */ @@ -429,12 +415,8 @@ bool st_select_lex_unit::exec() res= sl->join->reinit(); else { - if (sl != global_parameters && !describe) - { - offset_limit_cnt= sl->offset_limit; - select_limit_cnt= sl->select_limit+sl->offset_limit; - } - else + set_limit(sl); + if (sl == global_parameters || describe) { offset_limit_cnt= 0; /* @@ -443,11 +425,7 @@ bool st_select_lex_unit::exec() */ if (sl->order_list.first || describe) select_limit_cnt= HA_POS_ERROR; - else - select_limit_cnt= sl->select_limit+sl->offset_limit; - } - if (select_limit_cnt < sl->select_limit) - select_limit_cnt= HA_POS_ERROR; // no limit + } /* When using braces, SQL_CALC_FOUND_ROWS affects the whole query: @@ -512,7 +490,8 @@ bool st_select_lex_unit::exec() if (!thd->is_fatal_error) // Check if EOM { - ulong options_tmp= init_prepare_fake_select_lex(thd); + set_limit(global_parameters); + init_prepare_fake_select_lex(thd); JOIN *join= fake_select_lex->join; if (!join) { diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 990f22635c7..0d00c38f638 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -398,14 +398,13 @@ int mysql_update(THD *thd, if (!(select && select->skip_record())) { store_record(table,record[1]); - if (fill_record(thd, fields, values, 0)) + if (fill_record_n_invoke_before_triggers(thd, fields, values, 0, + table->triggers, + TRG_EVENT_UPDATE)) break; /* purecov: inspected */ found++; - if (table->triggers) - table->triggers->process_triggers(thd, TRG_EVENT_UPDATE, TRG_ACTION_BEFORE); - if (compare_record(table, query_id)) { if ((res= table_list->view_check_option(thd, ignore)) != @@ -425,6 +424,14 @@ int mysql_update(THD *thd, { updated++; thd->no_trans_update= !transactional_table; + + if (table->triggers && + table->triggers->process_triggers(thd, TRG_EVENT_UPDATE, + TRG_ACTION_AFTER, TRUE)) + { + error= 1; + break; + } } else if (!ignore || error != HA_ERR_FOUND_DUPP_KEY) { @@ -435,9 +442,6 @@ int mysql_update(THD *thd, } } - if (table->triggers) - table->triggers->process_triggers(thd, TRG_EVENT_UPDATE, TRG_ACTION_AFTER); - if (!--limit && using_limit) { error= -1; // Simulate end of file @@ -553,8 +557,7 @@ bool mysql_prepare_update(THD *thd, TABLE_LIST *table_list, tables.table= table; tables.alias= table_list->alias; - if (setup_tables(thd, table_list, conds, &select_lex->leaf_tables, - FALSE, FALSE) || + if (setup_tables(thd, table_list, conds, &select_lex->leaf_tables, FALSE) || setup_conds(thd, table_list, select_lex->leaf_tables, conds) || select_lex->setup_ref_array(thd, order_num) || setup_order(thd, select_lex->ref_pointer_array, @@ -640,7 +643,7 @@ bool mysql_multi_update_prepare(THD *thd) */ if (setup_tables(thd, table_list, &lex->select_lex.where, - &lex->select_lex.leaf_tables, FALSE, FALSE)) + &lex->select_lex.leaf_tables, FALSE)) DBUG_RETURN(TRUE); leaves= lex->select_lex.leaf_tables; @@ -760,7 +763,7 @@ bool mysql_multi_update_prepare(THD *thd) tbl->cleanup_items(); if (setup_tables(thd, table_list, &lex->select_lex.where, - &lex->select_lex.leaf_tables, FALSE, FALSE) || + &lex->select_lex.leaf_tables, FALSE) || (lex->select_lex.no_wrap_view_item= 1, res= setup_fields(thd, 0, table_list, *fields, 1, 0, 0), lex->select_lex.no_wrap_view_item= 0, @@ -1073,8 +1076,8 @@ multi_update::initialize_tables(JOIN *join) NOTES We can update the first table in join on the fly if we know that - a row in this tabel will never be read twice. This is true under - the folloing conditions: + a row in this table will never be read twice. This is true under + the following conditions: - We are doing a table scan and the data is in a separate file (MyISAM) or if we don't update a clustered key. @@ -1082,6 +1085,10 @@ multi_update::initialize_tables(JOIN *join) - We are doing a range scan and we don't update the scan key or the primary key for a clustered table handler. + When checking for above cases we also should take into account that + BEFORE UPDATE trigger potentially may change value of any field in row + being updated. + WARNING This code is a bit dependent of how make_join_readinfo() works. @@ -1100,15 +1107,21 @@ static bool safe_update_on_fly(JOIN_TAB *join_tab, List *fields) return TRUE; // At most one matching row case JT_REF: case JT_REF_OR_NULL: - return !check_if_key_used(table, join_tab->ref.key, *fields); + return !check_if_key_used(table, join_tab->ref.key, *fields) && + !(table->triggers && + table->triggers->has_before_update_triggers()); case JT_ALL: /* If range search on index */ if (join_tab->quick) - return !join_tab->quick->check_if_keys_used(fields); + return !join_tab->quick->check_if_keys_used(fields) && + !(table->triggers && + table->triggers->has_before_update_triggers()); /* If scanning in clustered key */ if ((table->file->table_flags() & HA_PRIMARY_KEY_IN_READ_INDEX) && table->s->primary_key < MAX_KEY) - return !check_if_key_used(table, table->s->primary_key, *fields); + return !check_if_key_used(table, table->s->primary_key, *fields) && + !(table->triggers && + table->triggers->has_before_update_triggers()); return TRUE; default: break; // Avoid compler warning @@ -1171,8 +1184,10 @@ bool multi_update::send_data(List ¬_used_values) { table->status|= STATUS_UPDATED; store_record(table,record[1]); - if (fill_record(thd, *fields_for_table[offset], - *values_for_table[offset], 0)) + if (fill_record_n_invoke_before_triggers(thd, *fields_for_table[offset], + *values_for_table[offset], 0, + table->triggers, + TRG_EVENT_UPDATE)) DBUG_RETURN(1); found++; @@ -1208,8 +1223,15 @@ bool multi_update::send_data(List ¬_used_values) DBUG_RETURN(1); } } - else if (!table->file->has_transactions()) - thd->no_trans_update= 1; + else + { + if (!table->file->has_transactions()) + thd->no_trans_update= 1; + if (table->triggers && + table->triggers->process_triggers(thd, TRG_EVENT_UPDATE, + TRG_ACTION_AFTER, TRUE)) + DBUG_RETURN(1); + } } } else @@ -1330,6 +1352,11 @@ int multi_update::do_updates(bool from_send_error) copy_field_ptr++) (*copy_field_ptr->do_copy)(copy_field_ptr); + if (table->triggers && + table->triggers->process_triggers(thd, TRG_EVENT_UPDATE, + TRG_ACTION_BEFORE, TRUE)) + goto err2; + if (compare_record(table, thd->query_id)) { if ((local_error=table->file->update_row(table->record[1], @@ -1339,6 +1366,11 @@ int multi_update::do_updates(bool from_send_error) goto err; } updated++; + + if (table->triggers && + table->triggers->process_triggers(thd, TRG_EVENT_UPDATE, + TRG_ACTION_AFTER, TRUE)) + goto err2; } } @@ -1361,6 +1393,7 @@ err: table->file->print_error(local_error,MYF(0)); } +err2: (void) table->file->ha_rnd_end(); (void) tmp_table->file->ha_rnd_end(); diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 99b0f43db2d..c0f5d6e296c 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -3512,6 +3512,10 @@ alter_list_item: LEX *lex=Lex; lex->alter_info.flags|= ALTER_OPTIONS; } + | FORCE_SYM + { + Lex->alter_info.flags|= ALTER_FORCE; + } | order_clause { LEX *lex=Lex; @@ -3968,7 +3972,7 @@ select_part2: select_into select_lock_type; select_into: - opt_limit_clause {} + opt_order_clause opt_limit_clause {} | into | select_from | into select_from @@ -4339,7 +4343,18 @@ simple_expr: | CONVERT_SYM '(' expr USING charset_name ')' { $$= new Item_func_conv_charset($3,$5); } | DEFAULT '(' simple_ident ')' - { $$= new Item_default_value($3); } + { + if ($3->is_splocal()) + { + LEX_STRING name; + Item_splocal *il= static_cast($3); + + il->my_name(&name.str, &name.length); + my_error(ER_WRONG_COLUMN_NAME, MYF(0), name.str); + YYABORT; + } + $$= new Item_default_value($3); + } | VALUES '(' simple_ident ')' { $$= new Item_insert_value($3); } | FUNC_ARG0 '(' ')' @@ -6507,6 +6522,11 @@ flush: FLUSH_SYM opt_no_write_to_binlog { LEX *lex=Lex; + if (lex->sphead && lex->sphead->m_type == TYPE_ENUM_FUNCTION) + { + my_error(ER_SP_BADSTATEMENT, MYF(0), "FLUSH"); + YYABORT; + } lex->sql_command= SQLCOM_FLUSH; lex->type=0; lex->no_write_to_binlog= $2; } @@ -7069,7 +7089,32 @@ simple_ident_q: field_ident: ident { $$=$1;} - | ident '.' ident { $$=$3;} /* Skip schema name in create*/ + | ident '.' ident '.' ident + { + TABLE_LIST *table= (TABLE_LIST*) Select->table_list.first; + if (my_strcasecmp(table_alias_charset, $1.str, table->db)) + { + my_error(ER_WRONG_DB_NAME, MYF(0), $1.str); + YYABORT; + } + if (my_strcasecmp(table_alias_charset, $3.str, + table->table_name)) + { + my_error(ER_WRONG_TABLE_NAME, MYF(0), $3.str); + YYABORT; + } + $$=$5; + } + | ident '.' ident + { + TABLE_LIST *table= (TABLE_LIST*) Select->table_list.first; + if (my_strcasecmp(table_alias_charset, $1.str, table->alias)) + { + my_error(ER_WRONG_TABLE_NAME, MYF(0), $1.str); + YYABORT; + } + $$=$3; + } | '.' ident { $$=$2;} /* For Delphi */; table_ident: @@ -7565,6 +7610,7 @@ sys_option_value: { /* We are in trigger and assigning value to field of new row */ Item *it; + Item_trigger_field *trg_fld; sp_instr_set_trigger_field *i; if ($1) { @@ -7585,17 +7631,19 @@ sys_option_value: it= new Item_null(); } - if (!(i= new sp_instr_set_trigger_field( - lex->sphead->instructions(), lex->spcont, - $2.base_name, it))) + if (!(trg_fld= new Item_trigger_field(Item_trigger_field::NEW_ROW, + $2.base_name.str)) || + !(i= new sp_instr_set_trigger_field( + lex->sphead->instructions(), lex->spcont, + trg_fld, it))) YYABORT; /* Let us add this item to list of all Item_trigger_field objects in trigger. */ - lex->trg_table_fields.link_in_list((byte *)&i->trigger_field, - (byte **)&i->trigger_field.next_trg_field); + lex->trg_table_fields.link_in_list((byte *)trg_fld, + (byte **)&trg_fld->next_trg_field); lex->sphead->add_instr(i); } diff --git a/sql/structs.h b/sql/structs.h index 14c0100f5be..8f053f20776 100644 --- a/sql/structs.h +++ b/sql/structs.h @@ -164,7 +164,8 @@ typedef struct st_known_date_time_format { enum SHOW_TYPE { SHOW_UNDEF, - SHOW_LONG, SHOW_LONGLONG, SHOW_INT, SHOW_CHAR, SHOW_CHAR_PTR, SHOW_DOUBLE, + SHOW_LONG, SHOW_LONGLONG, SHOW_INT, SHOW_CHAR, SHOW_CHAR_PTR, + SHOW_DOUBLE_STATUS, SHOW_BOOL, SHOW_MY_BOOL, SHOW_OPENTABLES, SHOW_STARTTIME, SHOW_QUESTION, SHOW_LONG_CONST, SHOW_INT_CONST, SHOW_HAVE, SHOW_SYS, SHOW_HA_ROWS, SHOW_VARS, diff --git a/sql/table.cc b/sql/table.cc index d3ba4056571..eb4dbe5a1f3 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -166,6 +166,7 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat, share->db_type= ha_checktype((enum db_type) (uint) *(head+3)); share->db_create_options= db_create_options=uint2korr(head+30); share->db_options_in_use= share->db_create_options; + share->mysql_version= uint4korr(head+51); null_field_first= 0; if (!head[32]) // New frm file in 3.23 { @@ -553,6 +554,26 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat, unhex_type2(interval); } +#ifndef TO_BE_DELETED_ON_PRODUCTION + if (field_type == FIELD_TYPE_NEWDECIMAL && !share->mysql_version) + { + /* + Fix pack length of old decimal values from 5.0.3 -> 5.0.4 + The difference is that in the old version we stored precision + in the .frm table while we now store the display_length + */ + uint decimals= f_decimals(pack_flag); + field_length= my_decimal_precision_to_length(field_length, + decimals, + f_is_dec(pack_flag) == 0); + sql_print_error("Found incompatible DECIMAL field '%s' in %s; Please do \"ALTER TABLE '%s' FORCE\" to fix it!", share->fieldnames.type_names[i], name, share->table_name); + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, + ER_CRASHED_ON_USAGE, + "Found incompatible DECIMAL field '%s' in %s; Please do \"ALTER TABLE '%s' FORCE\" to fix it!", share->fieldnames.type_names[i], name, share->table_name); + share->crashed= 1; // Marker for CHECK TABLE + } +#endif + *field_ptr=reg_field= make_field(record+recpos, (uint32) field_length, @@ -572,6 +593,7 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat, error= 4; goto err; /* purecov: inspected */ } + reg_field->comment=comment; if (field_type == FIELD_TYPE_BIT && !f_bit_as_char(pack_flag)) { @@ -712,6 +734,28 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat, } if (field->key_length() != key_part->length) { +#ifndef TO_BE_DELETED_ON_PRODUCTION + if (field->type() == FIELD_TYPE_NEWDECIMAL) + { + /* + Fix a fatal error in decimal key handling that causes crashes + on Innodb. We fix it by reducing the key length so that + InnoDB never gets a too big key when searching. + This allows the end user to do an ALTER TABLE to fix the + error. + */ + keyinfo->key_length-= (key_part->length - field->key_length()); + key_part->store_length-= (key_part->length - field->key_length()); + key_part->length= field->key_length(); + sql_print_error("Found wrong key definition in %s; Please do \"ALTER TABLE '%s' FORCE \" to fix it!", name, share->table_name); + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, + ER_CRASHED_ON_USAGE, + "Found wrong key definition in %s; Please do \"ALTER TABLE '%s' FORCE\" to fix it!", name, share->table_name); + + share->crashed= 1; // Marker for CHECK TABLE + goto to_be_deleted; + } +#endif key_part->key_part_flag|= HA_PART_KEY_SEG; if (!(field->flags & BLOB_FLAG)) { // Create a new field @@ -720,6 +764,9 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat, field->field_length=key_part->length; } } + + to_be_deleted: + /* If the field can be NULL, don't optimize away the test key_part_column = expression from the WHERE clause @@ -1298,7 +1345,6 @@ File create_frm(register my_string name, uint reclength, uchar *fileinfo, HA_CREATE_INFO *create_info, uint keys) { register File file; - uint key_length; ulong length; char fill[IO_SIZE]; int create_flags= O_RDWR | O_TRUNC; @@ -1321,6 +1367,8 @@ File create_frm(register my_string name, uint reclength, uchar *fileinfo, if ((file= my_create(name, CREATE_MODE, create_flags, MYF(MY_WME))) >= 0) { + uint key_length, tmp_key_length; + uint tmp; bzero((char*) fileinfo,64); /* header */ fileinfo[0]=(uchar) 254; @@ -1333,8 +1381,8 @@ File create_frm(register my_string name, uint reclength, uchar *fileinfo, key_length=keys*(7+NAME_LEN+MAX_REF_PARTS*9)+16; length=(ulong) next_io_size((ulong) (IO_SIZE+key_length+reclength)); int4store(fileinfo+10,length); - if (key_length > 0xffff) key_length=0xffff; - int2store(fileinfo+14,key_length); + tmp_key_length= (key_length < 0xffff) ? key_length : 0xffff; + int2store(fileinfo+14,tmp_key_length); int2store(fileinfo+16,reclength); int4store(fileinfo+18,create_info->max_rows); int4store(fileinfo+22,create_info->min_rows); @@ -1350,6 +1398,9 @@ File create_frm(register my_string name, uint reclength, uchar *fileinfo, fileinfo[41]= (uchar) create_info->raid_type; fileinfo[42]= (uchar) create_info->raid_chunks; int4store(fileinfo+43,create_info->raid_chunksize); + int4store(fileinfo+47, key_length); + tmp= MYSQL_VERSION_ID; // Store to avoid warning from int4store + int4store(fileinfo+51, tmp); bzero(fill,IO_SIZE); for (; length > IO_SIZE ; length-= IO_SIZE) { @@ -1764,7 +1815,7 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds, bool res= FALSE; DBUG_ENTER("st_table_list::setup_ancestor"); - if (check_stack_overrun(thd, (char *)&res)) + if (check_stack_overrun(thd, STACK_MIN_SIZE, (char *)&res)) return TRUE; for (tbl= ancestor; tbl; tbl= tbl->next_local) diff --git a/sql/table.h b/sql/table.h index 2e397ff95bf..8043429999b 100644 --- a/sql/table.h +++ b/sql/table.h @@ -126,7 +126,7 @@ typedef struct st_table_share key_map keys_for_keyread; ulong avg_row_length; /* create information */ ulong raid_chunksize; - ulong version, flush_version; + ulong version, flush_version, mysql_version; ulong timestamp_offset; /* Set to offset+1 of record */ ulong reclength; /* Recordlength */ diff --git a/sql/tztime.cc b/sql/tztime.cc index 983c630071e..a52b9701e8e 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -20,18 +20,20 @@ (We will refer to this code as to elsie-code further.) */ -#ifdef __GNUC__ -#pragma implementation // gcc: Class implementation -#endif - /* We should not include mysql_priv.h in mysql_tzinfo_to_sql utility since it creates unsolved link dependencies on some platforms. */ + +#include + +#ifdef USE_PRAGMA_IMPLEMENTATION +#pragma implementation // gcc: Class implementation +#endif + #if !defined(TZINFO2SQL) && !defined(TESTTIME) #include "mysql_priv.h" #else -#include #include #include "tztime.h" #include diff --git a/sql/unireg.cc b/sql/unireg.cc index 57d9fd07e51..eda17d8f4a9 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -73,6 +73,7 @@ bool mysql_create_frm(THD *thd, my_string file_name, handler *db_file) { uint reclength,info_length,screens,key_info_length,maxlength; + ulong key_buff_length; File file; ulong filepos, data_offset; uchar fileinfo[64],forminfo[288],*keybuff; @@ -119,7 +120,7 @@ bool mysql_create_frm(THD *thd, my_string file_name, DBUG_RETURN(1); } - uint key_buff_length=keys*(7+NAME_LEN+MAX_REF_PARTS*9)+16; + key_buff_length= uint4korr(fileinfo+47); keybuff=(uchar*) my_malloc(key_buff_length, MYF(0)); key_info_length= pack_keys(keybuff, keys, key_info, data_offset); VOID(get_form_pos(file,fileinfo,&formnames)); @@ -128,7 +129,6 @@ bool mysql_create_frm(THD *thd, my_string file_name, maxlength=(uint) next_io_size((ulong) (uint2korr(forminfo)+1000)); int2store(forminfo+2,maxlength); int4store(fileinfo+10,(ulong) (filepos+maxlength)); - int4store(fileinfo+47,key_buff_length); fileinfo[26]= (uchar) test((create_info->max_rows == 1) && (create_info->min_rows == 1) && (keys == 0)); int2store(fileinfo+28,key_info_length); @@ -411,7 +411,8 @@ static bool pack_header(uchar *forminfo, enum db_type table_type, DBUG_RETURN(1); } - totlength=reclength=0L; + totlength= 0L; + reclength= data_offset; no_empty=int_count=int_parts=int_length=time_stamp_pos=null_fields= com_length=0; n_length=2L; @@ -440,6 +441,8 @@ static bool pack_header(uchar *forminfo, enum db_type table_type, !time_stamp_pos) time_stamp_pos= (uint) field->offset+ (uint) data_offset + 1; length=field->pack_length; + /* Ensure we don't have any bugs when generating offsets */ + DBUG_ASSERT(reclength == field->offset + data_offset); if ((uint) field->offset+ (uint) data_offset+ length > reclength) reclength=(uint) (field->offset+ data_offset + length); n_length+= (ulong) strlen(field->field_name)+1; @@ -756,8 +759,11 @@ static bool make_empty_rec(THD *thd, File file,enum db_type table_type, } DBUG_ASSERT(data_offset == ((null_count + 7) / 8)); - /* Fill not used startpos */ - if (null_count) + /* + We need to set the unused bits to 1. If the number of bits is a multiple + of 8 there are no unused bits. + */ + if (null_count & 7) *(null_pos + null_count / 8)|= ~(((uchar) 1 << (null_count & 7)) - 1); error=(int) my_write(file,(byte*) buff, (uint) reclength,MYF_RW); diff --git a/support-files/mysql-max.spec.sh b/support-files/mysql-max.spec.sh deleted file mode 100644 index 5c4b16f0e9d..00000000000 --- a/support-files/mysql-max.spec.sh +++ /dev/null @@ -1,263 +0,0 @@ -%define mysql_version @VERSION@ -%define shared_lib_version @SHARED_LIB_VERSION@ -%define release 2 -%define mysqld_user mysql - -%define see_base For a description of MySQL see the base MySQL RPM or http://www.mysql.com - -Name: MySQL -Summary: MySQL: a very fast and reliable SQL database engine -Group: Applications/Databases -Summary(pt_BR): MySQL: Um servidor SQL rápido e confiável. -Group(pt_BR): Aplicações/Banco_de_Dados -Version: @MYSQL_NO_DASH_VERSION@ -Release: %{release} -Copyright: GPL / LGPL -Source: http://www.mysql.com/Downloads/MySQL-@MYSQL_BASE_VERSION@/mysql-%{mysql_version}.tar.gz -Icon: mysql.gif -URL: http://www.mysql.com/ -Packager: David Axmark , Monty -Provides: msqlormysql MySQL-server -Obsoletes: mysql - -# Think about what you use here since the first step is to -# run a rm -rf -BuildRoot: /var/tmp/mysql-max - -# From the manual -%description -MySQL is a true multi-user, multi-threaded SQL (Structured Query -Language) database server. MySQL is a client/server implementation -that consists of a server daemon (mysqld) and many different client -programs/libraries. - -The main goals of MySQL are speed, robustness and ease of use. MySQL -was originally developed because we needed a SQL server that could -handle very big databases with magnitude higher speed than what any -database vendor could offer to us. And since we did not need all the -features that made their server slow we made our own. We have now been -using MySQL since 1996 in a environment with more than 40 databases, -10,000 tables, of which more than 500 have more than 7 million -rows. This is about 200G of data. - -The base upon which MySQL is built is a set of routines that have been -used in a highly demanding production environment for many -years. While MySQL is still in development, it already offers a rich -and highly useful function set. - -The MySQL-max version differs from the normal MySQL server distribution -in that the BDB and Innobase table handlers are enabled by default. -You can use any normal MySQL client with the MySQL-max server. - -See the documentation for more information. - -%description -l pt_BR -O MySQL é um servidor de banco de dados SQL realmente multiusuário e\ -multi-tarefa. A linguagem SQL é a mais popular linguagem para banco de\ -dados no mundo. O MySQL é uma implementação cliente/servidor que\ -consiste de um servidor chamado mysqld e diversos\ -programas/bibliotecas clientes. Os principais objetivos do MySQL são:\ -velocidade, robustez e facilidade de uso. O MySQL foi originalmente\ -desenvolvido porque nós na Tcx precisávamos de um servidor SQL que\ -pudesse lidar com grandes bases de dados e com uma velocidade muito\ -maior do que a que qualquer vendedor podia nos oferecer. Estamos\ -usando\ -o MySQL desde 1996 em um ambiente com mais de 40 bases de dados com 10.000\ -tabelas, das quais mais de 500 têm mais de 7 milhões de linhas. Isto é o\ -equivalente a aproximadamente 50G de dados críticos. A base da construção do\ -MySQL é uma série de rotinas que foram usadas em um ambiente de produção com\ -alta demanda por muitos anos. Mesmo o MySQL estando ainda em desenvolvimento,\ -ele já oferece um conjunto de funções muito ricas e úteis. Veja a documentação\ -para maiores informações. - -%prep -%setup -n mysql-max-%{mysql_version} -# %setup -T -D -a 1 -n mysql-max-%{mysql_version} - -%build -# The all-static flag is to make the RPM work on different -# distributions. This version tries to put shared mysqlclient libraries -# in a separate package. - -BuildMySQL() { -# The --enable-assembler simply does nothing on systems that does not -# support assembler speedups. -sh -c "PATH=\"${MYSQL_BUILD_PATH:-/bin:/usr/bin}\" \ - CC=\"${MYSQL_BUILD_CC:-egcs}\" \ - CFLAGS=\"${MYSQL_BUILD_CFLAGS:- -O6 -fno-omit-frame-pointer}\" \ - CXX=\"${MYSQL_BUILD_CXX:-egcs}\" \ - CXXFLAGS=\"${MYSQL_BUILD_CXXFLAGS:- -O6 \ - -felide-constructors -fno-exceptions -fno-rtti \ - -fno-omit-frame-pointer}\" \ - ./configure \ - $* \ - --enable-assembler \ - --with-mysqld-user=%{mysqld_user} \ - --with-unix-socket-path=/var/lib/mysql/mysql.sock \ - --prefix=/ \ - --with-extra-charsets=complex \ - --exec-prefix=/usr \ - --libexecdir=/usr/sbin \ - --sysconfdir=/etc \ - --datadir=/usr/share \ - --localstatedir=/var/lib/mysql \ - --infodir=/usr/info \ - --includedir=/usr/include \ - --mandir=/usr/man \ - --with-berkeley-db \ - --with-innodb \ - --with-comment=\"Official MySQL-Max RPM\"; - # Add this for more debugging support - # --with-debug - # Add this for MyISAM RAID support: - # --with-raid - " - make -} - -# Use the build root for temporary storage of the shared libraries. - -RBR=$RPM_BUILD_ROOT -MBD=$RPM_BUILD_DIR/mysql-max-%{mysql_version} -if test -z "$RBR" -o "$RBR" = "/" -then - echo "RPM_BUILD_ROOT has stupid value" - exit 1 -fi -rm -rf $RBR -mkdir -p $RBR - -#cd $MBD/db-%{db_version}/dist -#./configure --prefix=$RBR/usr/BDB -#make install -# -#echo $RBR $MBD -#cd $MBD - -BuildMySQL "--disable-shared" \ - "--with-mysqld-ldflags='-all-static'" \ - "--with-client-ldflags='-all-static'" - -%install -n mysql-max-%{mysql_version} -RBR=$RPM_BUILD_ROOT -MBD=$RPM_BUILD_DIR/mysql-max-%{mysql_version} -# Ensure that needed directories exists -install -d $RBR/etc/{logrotate.d,rc.d/init.d} -install -d $RBR/var/lib/mysql/mysql -install -d $RBR/usr/share/sql-bench -install -d $RBR/usr/share/mysql-test -install -d $RBR/usr/{sbin,share,man,include} -install -d $RBR/usr/doc/MySQL-%{mysql_version} -install -d $RBR/usr/lib -# Make install -make install DESTDIR=$RBR benchdir_root=/usr/share/ - -# Install logrotate and autostart -install -m644 $MBD/support-files/mysql-log-rotate $RBR/etc/logrotate.d/mysql -install -m755 $MBD/support-files/mysql.server $RBR/etc/rc.d/init.d/mysql - -# Install docs -install -m644 $RPM_BUILD_DIR/mysql-max-%{mysql_version}/Docs/mysql.info \ - $RBR/usr/info/mysql.info -for file in README COPYING COPYING.LIB Docs/manual_toc.html Docs/manual.html \ - Docs/manual.txt Docs/manual.texi Docs/manual.ps \ - support-files/my-huge.cnf support-files/my-large.cnf \ - support-files/my-medium.cnf support-files/my-small.cnf -do - b=`basename $file` - install -m644 $MBD/$file $RBR/usr/doc/MySQL-%{mysql_version}/$b -done - -%pre -if test -x /etc/rc.d/init.d/mysql -then - /etc/rc.d/init.d/mysql stop > /dev/null 2>&1 - echo "Giving mysqld a couple of seconds to exit nicely" - sleep 5 -fi - -%post -mysql_datadir=/var/lib/mysql - -# Create data directory if needed -if test ! -d $mysql_datadir; then mkdir $mysql_datadir; fi -if test ! -d $mysql_datadir/mysql; then mkdir $mysql_datadir/mysql; fi -if test ! -d $mysql_datadir/test; then mkdir $mysql_datadir/test; fi - -# Make MySQL start/shutdown automatically when the machine does it. -/sbin/chkconfig --add mysql - -# Create a MySQL user. Do not report any problems if it already -# exists. This is redhat specific and should be handled more portable -useradd -M -r -d $mysql_datadir -s /bin/bash -c "MySQL server" mysql 2> /dev/null || true - -# Change permissions so that the user that will run the MySQL daemon -# owns all database files. -chown -R mysql $mysql_datadir - -# Initiate databases -mysql_install_db -IN-RPM - -# Change permissions again to fix any new files. -chown -R mysql $mysql_datadir - -# Fix permissions for the permission database so that only the user -# can read them. -chmod -R og-rw $mysql_datadir/mysql - -# Restart in the same way that mysqld will be started normally. -/etc/rc.d/init.d/mysql start - -# Allow mysqld_safe to start mysqld and print a message before we exit -sleep 2 - -%preun -if test -x /etc/rc.d/init.d/mysql -then - /etc/rc.d/init.d/mysql stop > /dev/null -fi -# Remove autostart of mysql -if test $1 = 0 -then - /sbin/chkconfig --del mysql -fi -# We do not remove the mysql user since it may still own a lot of -# database files. - -%files -%attr(-, root, root) %doc /usr/doc/MySQL-%{mysql_version}/ - -%attr(755, root, root) /usr/bin/isamchk -%attr(755, root, root) /usr/bin/isamlog -%attr(755, root, root) /usr/bin/pack_isam -%attr(755, root, root) /usr/bin/myisamchk -%attr(755, root, root) /usr/bin/myisamlog -%attr(755, root, root) /usr/bin/myisampack -%attr(755, root, root) /usr/bin/mysql_fix_privilege_tables -%attr(755, root, root) /usr/bin/mysql_convert_table_format -%attr(755, root, root) /usr/bin/mysql_install_db -%attr(755, root, root) /usr/bin/mysql_setpermission -%attr(755, root, root) /usr/bin/mysql_zap -%attr(755, root, root) /usr/bin/mysqlbug -%attr(755, root, root) /usr/bin/mysqltest -%attr(755, root, root) /usr/bin/mysqlhotcopy -%attr(755, root, root) /usr/bin/perror -%attr(755, root, root) /usr/bin/replace -%attr(755, root, root) /usr/bin/resolveip -%attr(755, root, root) /usr/bin/mysqld_safe -%attr(755, root, root) /usr/bin/mysqld_multi -%attr(755, root, root) /usr/bin/my_print_defaults - -%attr(644, root, root) /usr/info/mysql.info* - -%attr(755, root, root) /usr/sbin/mysqld - -%attr(644, root, root) /etc/logrotate.d/mysql -%attr(755, root, root) /etc/rc.d/init.d/mysql - -%attr(755, root, root) /usr/share/mysql/ - -%changelog - -* Fri Apr 13 2001 Monty - First version of mysql-max.spec.sh based on mysql.spec.sh diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index 5e7499c5e5c..dd25862004a 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -16,8 +16,8 @@ Name: MySQL Summary: MySQL: a very fast and reliable SQL database server Group: Applications/Databases -Summary(pt_BR): MySQL: Um servidor SQL rápido e confiável. -Group(pt_BR): Aplicações/Banco_de_Dados +Summary(pt_BR): MySQL: Um servidor SQL rápido e confiável. +Group(pt_BR): Aplicações/Banco_de_Dados Version: @MYSQL_NO_DASH_VERSION@ Release: %{release} License: GPL @@ -57,8 +57,8 @@ documentation and the manual for more information. Release: %{release} Summary: MySQL: a very fast and reliable SQL database server Group: Applications/Databases -Summary(pt_BR): MySQL: Um servidor SQL rápido e confiável. -Group(pt_BR): Aplicações/Banco_de_Dados +Summary(pt_BR): MySQL: Um servidor SQL rápido e confiável. +Group(pt_BR): Aplicações/Banco_de_Dados Requires: fileutils sh-utils Provides: msqlormysql mysql-server mysql MySQL Obsoletes: MySQL mysql mysql-server @@ -92,7 +92,7 @@ Release: %{release} Summary: MySQL - Client Group: Applications/Databases Summary(pt_BR): MySQL - Cliente -Group(pt_BR): Aplicações/Banco_de_Dados +Group(pt_BR): Aplicações/Banco_de_Dados Obsoletes: mysql-client Provides: mysql-client @@ -102,7 +102,7 @@ This package contains the standard MySQL clients and administration tools. %{see_base} %description client -l pt_BR -Este pacote contém os clientes padrão para o MySQL. +Este pacote contém os clientes padrão para o MySQL. %package ndb-storage Release: %{release} @@ -156,8 +156,8 @@ Release: %{release} Requires: %{name}-client perl-DBI perl Summary: MySQL - Benchmarks and test system Group: Applications/Databases -Summary(pt_BR): MySQL - Medições de desempenho -Group(pt_BR): Aplicações/Banco_de_Dados +Summary(pt_BR): MySQL - Medições de desempenho +Group(pt_BR): Aplicações/Banco_de_Dados Provides: mysql-bench Obsoletes: mysql-bench @@ -167,14 +167,14 @@ This package contains MySQL benchmark scripts and data. %{see_base} %description bench -l pt_BR -Este pacote contém medições de desempenho de scripts e dados do MySQL. +Este pacote contém medições de desempenho de scripts e dados do MySQL. %package devel Release: %{release} Summary: MySQL - Development header files and libraries Group: Applications/Databases -Summary(pt_BR): MySQL - Medições de desempenho -Group(pt_BR): Aplicações/Banco_de_Dados +Summary(pt_BR): MySQL - Medições de desempenho +Group(pt_BR): Aplicações/Banco_de_Dados Provides: mysql-devel Obsoletes: mysql-devel @@ -185,8 +185,8 @@ necessary to develop MySQL client applications. %{see_base} %description devel -l pt_BR -Este pacote contém os arquivos de cabeçalho (header files) e bibliotecas -necessárias para desenvolver aplicações clientes do MySQL. +Este pacote contém os arquivos de cabeçalho (header files) e bibliotecas +necessárias para desenvolver aplicações clientes do MySQL. %package shared Release: %{release} @@ -226,8 +226,8 @@ Release: %{release} Requires: %{name}-devel Summary: MySQL - embedded library Group: Applications/Databases -Summary(pt_BR): MySQL - Medições de desempenho -Group(pt_BR): Aplicações/Banco_de_Dados +Summary(pt_BR): MySQL - Medições de desempenho +Group(pt_BR): Aplicações/Banco_de_Dados Obsoletes: mysql-embedded %description embedded @@ -364,6 +364,9 @@ fi (cd libmysql/.libs; tar cf $RBR/shared-libs.tar *.so*) (cd libmysql_r/.libs; tar rf $RBR/shared-libs.tar *.so*) +# Now clean up +make clean + # # Only link statically on our i386 build host (which has a specially # patched static glibc installed) - ia64 and x86_64 run glibc-2.3 (unpatched) @@ -686,6 +689,10 @@ fi # itself - note that they must be ordered by date (important when # merging BK trees) %changelog +* Wed May 25 2005 Joerg Bruehe + +- Added a "make clean" between separate calls to "BuildMySQL". + * Wed Apr 20 2005 Lenz Grimmer - Enabled the "blackhole" storage engine for the Max RPM diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 95db383bbb6..9a8ee44c54c 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -233,7 +233,7 @@ mysql_simple_prepare(MYSQL *mysql, const char *query) /* Connect to the server */ -static void client_connect() +static void client_connect(ulong flag) { int rc; myheader_r("client_connect"); @@ -251,7 +251,7 @@ static void client_connect() if (!(mysql_real_connect(mysql, opt_host, opt_user, opt_password, opt_db ? opt_db:"test", opt_port, - opt_unix_socket, 0))) + opt_unix_socket, flag))) { opt_silent= 0; myerror("connection failed"); @@ -13478,6 +13478,22 @@ static void print_test_output() } +static void check_mupltiquery_bug9992() +{ + + MYSQL_RES* res ; + mysql_query(mysql,"SHOW TABLES;SHOW DATABASE;SELECT 1;"); + + fprintf(stdout, "\n\n!!! check_mupltiquery_bug9992 !!!\n"); + do + { + if (!(res= mysql_store_result(mysql))) + return; + mysql_free_result(res); + } while (!mysql_next_result(mysql)); + fprintf(stdout, "\n\n!!! SUCCESS !!!\n"); + return; +} /*************************************************************************** main routine ***************************************************************************/ @@ -13499,7 +13515,7 @@ int main(int argc, char **argv) (char**) embedded_server_groups)) DIE("Can't initialize MySQL server"); - client_connect(); /* connect to server */ + client_connect(0); /* connect to server */ total_time= 0; for (iter_count= 1; iter_count <= opt_count; iter_count++) @@ -13543,6 +13559,10 @@ int main(int argc, char **argv) } client_disconnect(); /* disconnect from server */ + + client_connect(CLIENT_MULTI_STATEMENTS); + check_mupltiquery_bug9992(); + client_disconnect(); free_defaults(defaults_argv); print_test_output(); diff --git a/vio/viossl.c b/vio/viossl.c index 4233b276346..9a5eb1eb8df 100644 --- a/vio/viossl.c +++ b/vio/viossl.c @@ -128,26 +128,32 @@ int vio_ssl_write(Vio * vio, const gptr buf, int size) int vio_ssl_fastsend(Vio * vio __attribute__((unused))) { - int r= 0; + int r=0; DBUG_ENTER("vio_ssl_fastsend"); -#ifdef IPTOS_THROUGHPUT +#if defined(IPTOS_THROUGHPUT) && !defined(__EMX__) { -#ifndef __EMX__ - int tos = IPTOS_THROUGHPUT; - if (!setsockopt(vio->sd, IPPROTO_IP, IP_TOS, (void *) &tos, sizeof(tos))) -#endif /* !__EMX__ */ - { - int nodelay = 1; - if (setsockopt(vio->sd, IPPROTO_TCP, TCP_NODELAY, (void *) &nodelay, - sizeof(nodelay))) { - DBUG_PRINT("warning", - ("Couldn't set socket option for fast send")); - r= -1; - } - } + int tos= IPTOS_THROUGHPUT; + r= setsockopt(vio->sd, IPPROTO_IP, IP_TOS, (void *) &tos, sizeof(tos)); + } +#endif /* IPTOS_THROUGHPUT && !__EMX__ */ + if (!r) + { +#ifdef __WIN__ + BOOL nodelay= 1; + r= setsockopt(vio->sd, IPPROTO_TCP, TCP_NODELAY, (const char*) &nodelay, + sizeof(nodelay)); +#else + int nodelay= 1; + r= setsockopt(vio->sd, IPPROTO_TCP, TCP_NODELAY, (void*) &nodelay, + sizeof(nodelay)); +#endif /* __WIN__ */ + } + if (r) + { + DBUG_PRINT("warning", ("Couldn't set socket option for fast send")); + r= -1; } -#endif /* IPTOS_THROUGHPUT */ DBUG_PRINT("exit", ("%d", r)); DBUG_RETURN(r); } @@ -427,6 +433,11 @@ void vio_ssl_timeout(Vio *vio __attribute__((unused)), uint which __attribute__((unused)), uint timeout __attribute__((unused))) { - /* Not yet implemented (non critical) */ +#ifdef __WIN__ + ulong wait_timeout= (ulong) timeout * 1000; + (void) setsockopt(vio->sd, SOL_SOCKET, + which ? SO_SNDTIMEO : SO_RCVTIMEO, (char*) &wait_timeout, + sizeof(wait_timeout)); +#endif /* __WIN__ */ } #endif /* HAVE_OPENSSL */