summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--VC++Files/copy_mysql_files.bat5
-rw-r--r--VC++Files/libmysqltest/myTest-package.dsp92
-rw-r--r--VC++Files/libmysqltest/myTest-package_ia64.dsp92
-rw-r--r--VC++Files/libmysqltest/myTest.dsp92
-rw-r--r--VC++Files/libmysqltest/myTest.vcproj146
-rw-r--r--VC++Files/libmysqltest/myTest_ia64.dsp94
-rw-r--r--VC++Files/libmysqltest/mytest.c175
-rw-r--r--VC++Files/libmysqltest/mytest.dsw28
-rw-r--r--client/mysql.cc21
-rw-r--r--client/mysqltest.c2
-rw-r--r--include/m_string.h1
-rw-r--r--include/my_getopt.h3
-rw-r--r--include/mysql_com.h14
-rwxr-xr-xlibmysql/CMakeLists.txt3
-rw-r--r--libmysql/Makefile.am2
-rw-r--r--libmysql/mytest.c175
-rw-r--r--libmysqld/lib_sql.cc2
-rw-r--r--myisam/mi_check.c2
-rw-r--r--mysql-test/include/ps_query.inc4
-rw-r--r--mysql-test/r/delayed.result16
-rw-r--r--mysql-test/r/delete.result37
-rw-r--r--mysql-test/r/explain.result20
-rw-r--r--mysql-test/r/federated.result111
-rw-r--r--mysql-test/r/func_misc.result5
-rw-r--r--mysql-test/r/func_time.result12
-rw-r--r--mysql-test/r/gis.result40
-rw-r--r--mysql-test/r/group_min_max.result46
-rw-r--r--mysql-test/r/index_merge.result2
-rw-r--r--mysql-test/r/innodb.result4
-rw-r--r--mysql-test/r/innodb_mysql.result14
-rw-r--r--mysql-test/r/key_cache.result2
-rw-r--r--mysql-test/r/merge.result37
-rw-r--r--mysql-test/r/myisam.result22
-rw-r--r--mysql-test/r/outfile_loaddata.result18
-rw-r--r--mysql-test/r/packet.result8
-rw-r--r--mysql-test/r/ps.result2
-rw-r--r--mysql-test/r/ps_2myisam.result28
-rw-r--r--mysql-test/r/ps_3innodb.result28
-rw-r--r--mysql-test/r/ps_4heap.result28
-rw-r--r--mysql-test/r/ps_5merge.result56
-rw-r--r--mysql-test/r/ps_6bdb.result28
-rw-r--r--mysql-test/r/ps_7ndb.result28
-rw-r--r--mysql-test/r/range.result18
-rw-r--r--mysql-test/r/select.result6
-rw-r--r--mysql-test/r/subselect.result234
-rw-r--r--mysql-test/r/subselect3.result2
-rw-r--r--mysql-test/r/type_bit.result12
-rw-r--r--mysql-test/r/type_bit_innodb.result2
-rw-r--r--mysql-test/r/type_blob.result14
-rw-r--r--mysql-test/r/type_date.result39
-rw-r--r--mysql-test/r/type_datetime.result55
-rw-r--r--mysql-test/r/udf.result27
-rw-r--r--mysql-test/r/variables.result30
-rw-r--r--mysql-test/t/delete.test44
-rw-r--r--mysql-test/t/explain.test28
-rw-r--r--mysql-test/t/federated.test31
-rw-r--r--mysql-test/t/func_misc.test16
-rw-r--r--mysql-test/t/func_time.test10
-rw-r--r--mysql-test/t/gis.test51
-rw-r--r--mysql-test/t/group_min_max.test24
-rw-r--r--mysql-test/t/innodb_mysql.test13
-rw-r--r--mysql-test/t/merge.test22
-rw-r--r--mysql-test/t/myisam.test17
-rw-r--r--mysql-test/t/outfile_loaddata.test24
-rw-r--r--mysql-test/t/range.test20
-rw-r--r--mysql-test/t/select.test11
-rw-r--r--mysql-test/t/subselect.test200
-rw-r--r--mysql-test/t/type_bit.test15
-rw-r--r--mysql-test/t/type_blob.test11
-rw-r--r--mysql-test/t/type_date.test20
-rw-r--r--mysql-test/t/type_datetime.test37
-rw-r--r--mysql-test/t/udf.test21
-rw-r--r--mysql-test/t/variables.test2
-rw-r--r--mysys/my_getopt.c175
-rwxr-xr-xscripts/make_win_bin_dist1
-rw-r--r--sql-common/my_time.c9
-rw-r--r--sql/field.cc3
-rw-r--r--sql/field.h1
-rw-r--r--sql/ha_blackhole.cc122
-rw-r--r--sql/ha_blackhole.h18
-rw-r--r--sql/ha_federated.cc18
-rw-r--r--sql/ha_federated.h1
-rw-r--r--sql/ha_myisam.cc8
-rw-r--r--sql/ha_myisammrg.cc8
-rw-r--r--sql/handler.cc4
-rw-r--r--sql/item.cc16
-rw-r--r--sql/item.h22
-rw-r--r--sql/item_cmpfunc.cc69
-rw-r--r--sql/item_func.cc8
-rw-r--r--sql/item_func.h50
-rw-r--r--sql/item_geofunc.cc2
-rw-r--r--sql/item_subselect.cc4
-rw-r--r--sql/key.cc13
-rw-r--r--sql/mysql_priv.h2
-rw-r--r--sql/mysqld.cc100
-rw-r--r--sql/opt_range.cc38
-rw-r--r--sql/protocol.cc10
-rw-r--r--sql/set_var.cc96
-rw-r--r--sql/set_var.h1
-rw-r--r--sql/sql_class.cc17
-rw-r--r--sql/sql_class.h7
-rw-r--r--sql/sql_insert.cc66
-rw-r--r--sql/sql_select.cc39
-rw-r--r--sql/sql_select.h11
-rw-r--r--sql/sql_string.cc5
-rw-r--r--sql/sql_table.cc7
-rw-r--r--sql/sql_yacc.yy60
-rw-r--r--sql/udf_example.c10
-rw-r--r--strings/llstr.c6
-rw-r--r--tests/bug25714.c6
-rw-r--r--tests/mysql_client_test.c200
111 files changed, 2398 insertions, 1436 deletions
diff --git a/VC++Files/copy_mysql_files.bat b/VC++Files/copy_mysql_files.bat
index 7d6070eb1a8..8a296187cf3 100644
--- a/VC++Files/copy_mysql_files.bat
+++ b/VC++Files/copy_mysql_files.bat
@@ -78,11 +78,6 @@ copy include\conf*.h c:\mysql\include
copy include\my_global.h c:\mysql\include\my_global.h
copy libmysql\libmysql.def c:\mysql\include
-REM Copy test files
-
-copy libmysqltest\*.* c:\mysql\examples\libmysqltest
-copy libmysqltest\release\myTest.exe c:\mysql\examples\libmysqltest
-
REM Copy share, docs etc
xcopy share\*.* c:\mysql\share /E /Y
diff --git a/VC++Files/libmysqltest/myTest-package.dsp b/VC++Files/libmysqltest/myTest-package.dsp
deleted file mode 100644
index a5c73d447b3..00000000000
--- a/VC++Files/libmysqltest/myTest-package.dsp
+++ /dev/null
@@ -1,92 +0,0 @@
-# Microsoft Developer Studio Project File - Name="myTest" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=myTest - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "myTest.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "myTest.mak" CFG="myTest - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "myTest - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "myTest - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=xicl6.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "myTest - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "release"
-# PROP Intermediate_Dir "release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /G6 /W3 /O2 /I "..\..\include" /D "NDEBUG" /D "DBUG_UFF" /D "_CONSOLE" /D "_MBCS" /FD /c
-# SUBTRACT CPP /YX
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# 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 ..\..\lib\opt\libmysql.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 /libpath:"..\lib_release"
-
-!ELSEIF "$(CFG)" == "myTest - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "debug"
-# PROP Intermediate_Dir "debug"
-# 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 "..\..\include" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
-# SUBTRACT CPP /Fr /YX
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# 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 ..\..\lib\debug\libmysql.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 /pdbtype:sept /libpath:"..\lib_debug"
-
-!ENDIF
-
-# Begin Target
-
-# Name "myTest - Win32 Release"
-# Name "myTest - Win32 Debug"
-# Begin Source File
-
-SOURCE=.\Mytest.c
-# End Source File
-# End Target
-# End Project
diff --git a/VC++Files/libmysqltest/myTest-package_ia64.dsp b/VC++Files/libmysqltest/myTest-package_ia64.dsp
deleted file mode 100644
index ef80a773815..00000000000
--- a/VC++Files/libmysqltest/myTest-package_ia64.dsp
+++ /dev/null
@@ -1,92 +0,0 @@
-# Microsoft Developer Studio Project File - Name="myTest" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=myTest - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "myTest.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "myTest.mak" CFG="myTest - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "myTest - WinIA64 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "myTest - WinIA64 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=xicl6.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "myTest - WinIA64 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "release"
-# PROP Intermediate_Dir "release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN64" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /W3 /I "..\include" /D"NDEBUG" /D"DBUG_UFF" /D"_CONSOLE" /D"_MBCS" /FD /c /O2 /G2 /EHsc /D"_IA64_" /Zi /D"WIN64" /D"WIN32" /D"_AFX_NO_DAO_SUPPORT" /Wp64 /Zm600
-# SUBTRACT CPP /YX
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# 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:IA64
-# ADD LINK32 ..\lib_release\libmysql.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 /libpath:"..\lib_release" /incremental:no
-
-!ELSEIF "$(CFG)" == "myTest - WinIA64 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "debug"
-# PROP Intermediate_Dir "debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN64" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MTd /W3 /Z7 /I "..\include" /D"_DEBUG" /D"_CONSOLE" /D"_MBCS" /FD /c /Od /G2 /EHsc /D"_IA64_" /Zi /D"WIN64" /D"WIN32" /D"_AFX_NO_DAO_SUPPORT" /Wp64 /Zm600
-# SUBTRACT CPP /Fr /YX
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# 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:IA64
-# ADD LINK32 ..\lib_debug\libmysql.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 /libpath:"..\lib_debug" /incremental:no
-
-!ENDIF
-
-# Begin Target
-
-# Name "myTest - WinIA64 Release"
-# Name "myTest - WinIA64 Debug"
-# Begin Source File
-
-SOURCE=.\Mytest.c
-# End Source File
-# End Target
-# End Project
diff --git a/VC++Files/libmysqltest/myTest.dsp b/VC++Files/libmysqltest/myTest.dsp
deleted file mode 100644
index ca0f9e6e147..00000000000
--- a/VC++Files/libmysqltest/myTest.dsp
+++ /dev/null
@@ -1,92 +0,0 @@
-# Microsoft Developer Studio Project File - Name="myTest" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=myTest - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "myTest.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "myTest.mak" CFG="myTest - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "myTest - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "myTest - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=xicl6.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "myTest - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "release"
-# PROP Intermediate_Dir "release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /G6 /W3 /O2 /I "..\include" /D "DBUG_UFF" /D "_CONSOLE" /D "_MBCS" /D "NDEBUG" /FD /c
-# SUBTRACT CPP /YX
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# 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 libmysql.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 /libpath:"..\lib_release"
-
-!ELSEIF "$(CFG)" == "myTest - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "debug"
-# PROP Intermediate_Dir "debug"
-# 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 "..\include" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
-# SUBTRACT CPP /Fr /YX
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# 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 libmysql.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 /pdbtype:sept /libpath:"..\lib_debug"
-
-!ENDIF
-
-# Begin Target
-
-# Name "myTest - Win32 Release"
-# Name "myTest - Win32 Debug"
-# Begin Source File
-
-SOURCE=.\Mytest.c
-# End Source File
-# End Target
-# End Project
diff --git a/VC++Files/libmysqltest/myTest.vcproj b/VC++Files/libmysqltest/myTest.vcproj
deleted file mode 100644
index 53f93a7e05d..00000000000
--- a/VC++Files/libmysqltest/myTest.vcproj
+++ /dev/null
@@ -1,146 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="7.10"
- Name="myTest"
- SccProjectName=""
- SccLocalPath="">
- <Platforms>
- <Platform
- Name="Win32"/>
- </Platforms>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory=".\debug_obj"
- IntermediateDirectory=".\debug_obj"
- ConfigurationType="1"
- UseOfMFC="0"
- ATLMinimizesCRunTimeLibraryUsage="FALSE"
- CharacterSet="2">
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- OptimizeForProcessor="2"
- AdditionalIncludeDirectories="..\include"
- PreprocessorDefinitions="_DEBUG;_CONSOLE"
- RuntimeLibrary="5"
- PrecompiledHeaderFile=".\debug_obj/myTest.pch"
- AssemblerListingLocation=".\debug_obj/"
- ObjectFile=".\debug_obj/"
- ProgramDataBaseFileName=".\debug_obj/"
- WarningLevel="3"
- SuppressStartupBanner="TRUE"
- DebugInformationFormat="1"
- CompileAs="0"/>
- <Tool
- Name="VCCustomBuildTool"/>
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="libmysql.lib odbc32.lib odbccp32.lib"
- OutputFile=".\debug/myTest.exe"
- LinkIncremental="1"
- SuppressStartupBanner="TRUE"
- AdditionalLibraryDirectories=""
- GenerateDebugInformation="TRUE"
- ProgramDatabaseFile=".\debug_obj/myTest.pdb"
- SubSystem="1"
- TargetMachine="1"/>
- <Tool
- Name="VCMIDLTool"
- TypeLibraryName=".\debug_obj/myTest.tlb"
- HeaderFileName=""/>
- <Tool
- Name="VCPostBuildEventTool"/>
- <Tool
- Name="VCPreBuildEventTool"/>
- <Tool
- Name="VCPreLinkEventTool"/>
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG"
- Culture="1033"/>
- <Tool
- Name="VCWebServiceProxyGeneratorTool"/>
- <Tool
- Name="VCXMLDataGeneratorTool"/>
- <Tool
- Name="VCWebDeploymentTool"/>
- <Tool
- Name="VCManagedWrapperGeneratorTool"/>
- <Tool
- Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory=".\release_obj"
- IntermediateDirectory=".\release_obj"
- ConfigurationType="1"
- UseOfMFC="0"
- ATLMinimizesCRunTimeLibraryUsage="FALSE"
- CharacterSet="2">
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- InlineFunctionExpansion="1"
- OptimizeForProcessor="2"
- AdditionalIncludeDirectories="..\include"
- PreprocessorDefinitions="DBUG_UFF;_CONSOLE;NDEBUG"
- StringPooling="TRUE"
- RuntimeLibrary="4"
- EnableFunctionLevelLinking="TRUE"
- PrecompiledHeaderFile=".\release_obj/myTest.pch"
- AssemblerListingLocation=".\release_obj/"
- ObjectFile=".\release_obj/"
- ProgramDataBaseFileName=".\release_obj/"
- WarningLevel="3"
- SuppressStartupBanner="TRUE"
- CompileAs="0"/>
- <Tool
- Name="VCCustomBuildTool"/>
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="libmysql.lib odbc32.lib odbccp32.lib"
- OutputFile=".\release/myTest.exe"
- LinkIncremental="1"
- SuppressStartupBanner="TRUE"
- AdditionalLibraryDirectories=""
- ProgramDatabaseFile=".\release_obj/myTest.pdb"
- SubSystem="1"
- TargetMachine="1"/>
- <Tool
- Name="VCMIDLTool"
- TypeLibraryName=".\release_obj/myTest.tlb"
- HeaderFileName=""/>
- <Tool
- Name="VCPostBuildEventTool"/>
- <Tool
- Name="VCPreBuildEventTool"/>
- <Tool
- Name="VCPreLinkEventTool"/>
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG"
- Culture="1033"/>
- <Tool
- Name="VCWebServiceProxyGeneratorTool"/>
- <Tool
- Name="VCXMLDataGeneratorTool"/>
- <Tool
- Name="VCWebDeploymentTool"/>
- <Tool
- Name="VCManagedWrapperGeneratorTool"/>
- <Tool
- Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <File
- RelativePath="Mytest.c">
- </File>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/VC++Files/libmysqltest/myTest_ia64.dsp b/VC++Files/libmysqltest/myTest_ia64.dsp
deleted file mode 100644
index 4affa81ef54..00000000000
--- a/VC++Files/libmysqltest/myTest_ia64.dsp
+++ /dev/null
@@ -1,94 +0,0 @@
-# Microsoft Developer Studio Project File - Name="myTest" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=myTest - WinIA64 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "myTest_ia64.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "myTest_ia64.mak" CFG="myTest - WinIA64 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "myTest - WinIA64 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "myTest - WinIA64 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "myTest - WinIA64 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "release"
-# PROP Intermediate_Dir "release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-MTL=midl.exe
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN64" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /W3 /Zi /O2 /I "..\include" /D "DBUG_UFF" /D "_CONSOLE" /D "_MBCS" /D "NDEBUG" /D "_IA64_" /D "WIN64" /D "WIN32" /D "_AFX_NO_DAO_SUPPORT" /FD /G2 /EHsc /Wp64 /Zm600 /c
-# SUBTRACT CPP /YX
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# 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 libmysql.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 /libpath:"..\lib_release" /machine:IA64
-
-!ELSEIF "$(CFG)" == "myTest - WinIA64 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "debug"
-# PROP Intermediate_Dir "debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-MTL=midl.exe
-# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN64" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MTd /W3 /Zi /Od /I "..\include" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "_IA64_" /D "WIN64" /D "WIN32" /D "_AFX_NO_DAO_SUPPORT" /FD /G2 /EHsc /Wp64 /Zm600 /c
-# SUBTRACT CPP /Fr /YX
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# 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 libmysql.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 /libpath:"..\lib_debug" /machine:IA64
-
-!ENDIF
-
-# Begin Target
-
-# Name "myTest - WinIA64 Release"
-# Name "myTest - WinIA64 Debug"
-# Begin Source File
-
-SOURCE=.\Mytest.c
-# End Source File
-# End Target
-# End Project
diff --git a/VC++Files/libmysqltest/mytest.c b/VC++Files/libmysqltest/mytest.c
deleted file mode 100644
index a1dc13db39f..00000000000
--- a/VC++Files/libmysqltest/mytest.c
+++ /dev/null
@@ -1,175 +0,0 @@
-/*C4*/
-/****************************************************************/
-/* Author: Jethro Wright, III TS : 3/ 4/1998 9:15 */
-/* Date: 02/18/1998 */
-/* mytest.c : do some testing of the libmySQL.DLL.... */
-/* */
-/* History: */
-/* 02/18/1998 jw3 also sprach zarathustra.... */
-/****************************************************************/
-
-
-#include <windows.h>
-#include <stdio.h>
-#include <string.h>
-
-#include <mysql.h>
-
-#define DEFALT_SQL_STMT "SELECT * FROM db"
-#ifndef offsetof
-#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
-#endif
-
-
-/********************************************************
-**
-** main :-
-**
-********************************************************/
-
-int
-main( int argc, char * argv[] )
-{
-
- char szSQL[ 200 ], aszFlds[ 25 ][ 25 ], szDB[ 50 ] ;
- const char *pszT;
- int i, j, k, l, x ;
- MYSQL * myData ;
- MYSQL_RES * res ;
- MYSQL_FIELD * fd ;
- MYSQL_ROW row ;
-
- //....just curious....
- printf( "sizeof( MYSQL ) == %d\n", (int) sizeof( MYSQL ) ) ;
- if ( argc == 2 )
- {
- strcpy( szDB, argv[ 1 ] ) ;
- strcpy( szSQL, DEFALT_SQL_STMT ) ;
- if (!strcmp(szDB,"--debug"))
- {
- strcpy( szDB, "mysql" ) ;
- printf("Some mysql struct information (size and offset):\n");
- printf("net:\t%3d %3d\n",(int) sizeof(myData->net),
- (int) offsetof(MYSQL,net));
- printf("host:\t%3d %3d\n",(int) sizeof(myData->host),
- (int) offsetof(MYSQL,host));
- printf("port:\t%3d %3d\n", (int) sizeof(myData->port),
- (int) offsetof(MYSQL,port));
- printf("protocol_version:\t%3d %3d\n",
- (int) sizeof(myData->protocol_version),
- (int) offsetof(MYSQL,protocol_version));
- printf("thread_id:\t%3d %3d\n",(int) sizeof(myData->thread_id),
- (int) offsetof(MYSQL,thread_id));
- printf("affected_rows:\t%3d %3d\n",(int) sizeof(myData->affected_rows),
- (int) offsetof(MYSQL,affected_rows));
- printf("packet_length:\t%3d %3d\n",(int) sizeof(myData->packet_length),
- (int) offsetof(MYSQL,packet_length));
- printf("status:\t%3d %3d\n",(int) sizeof(myData->status),
- (int) offsetof(MYSQL,status));
- printf("fields:\t%3d %3d\n",(int) sizeof(myData->fields),
- (int) offsetof(MYSQL,fields));
- printf("field_alloc:\t%3d %3d\n",(int) sizeof(myData->field_alloc),
- (int) offsetof(MYSQL,field_alloc));
- printf("free_me:\t%3d %3d\n",(int) sizeof(myData->free_me),
- (int) offsetof(MYSQL,free_me));
- printf("options:\t%3d %3d\n",(int) sizeof(myData->options),
- (int) offsetof(MYSQL,options));
- puts("");
- }
- }
- else if ( argc > 2 ) {
- strcpy( szDB, argv[ 1 ] ) ;
- strcpy( szSQL, argv[ 2 ] ) ;
- }
- else {
- strcpy( szDB, "mysql" ) ;
- strcpy( szSQL, DEFALT_SQL_STMT ) ;
- }
- //....
-
- if ( (myData = mysql_init((MYSQL*) 0)) &&
- mysql_real_connect( myData, NULL, NULL, NULL, NULL, MYSQL_PORT,
- NULL, 0 ) )
- {
- myData->reconnect= 1;
- if ( mysql_select_db( myData, szDB ) < 0 ) {
- printf( "Can't select the %s database !\n", szDB ) ;
- mysql_close( myData ) ;
- return 2 ;
- }
- }
- else {
- printf( "Can't connect to the mysql server on port %d !\n",
- MYSQL_PORT ) ;
- mysql_close( myData ) ;
- return 1 ;
- }
- //....
- if ( ! mysql_query( myData, szSQL ) ) {
- res = mysql_store_result( myData ) ;
- i = (int) mysql_num_rows( res ) ; l = 1 ;
- printf( "Query: %s\nNumber of records found: %ld\n", szSQL, i ) ;
- //....we can get the field-specific characteristics here....
- for ( x = 0 ; fd = mysql_fetch_field( res ) ; x++ )
- strcpy( aszFlds[ x ], fd->name ) ;
- //....
- while ( row = mysql_fetch_row( res ) ) {
- j = mysql_num_fields( res ) ;
- printf( "Record #%ld:-\n", l++ ) ;
- for ( k = 0 ; k < j ; k++ )
- printf( " Fld #%d (%s): %s\n", k + 1, aszFlds[ k ],
- (((row[k]==NULL)||(!strlen(row[k])))?"NULL":row[k])) ;
- puts( "==============================\n" ) ;
- }
- mysql_free_result( res ) ;
- }
- else printf( "Couldn't execute %s on the server !\n", szSQL ) ;
- //....
- puts( "==== Diagnostic info ====" ) ;
- pszT = mysql_get_client_info() ;
- printf( "Client info: %s\n", pszT ) ;
- //....
- pszT = mysql_get_host_info( myData ) ;
- printf( "Host info: %s\n", pszT ) ;
- //....
- pszT = mysql_get_server_info( myData ) ;
- printf( "Server info: %s\n", pszT ) ;
- //....
- res = mysql_list_processes( myData ) ; l = 1 ;
- if (res)
- {
- for ( x = 0 ; fd = mysql_fetch_field( res ) ; x++ )
- strcpy( aszFlds[ x ], fd->name ) ;
- while ( row = mysql_fetch_row( res ) ) {
- j = mysql_num_fields( res ) ;
- printf( "Process #%ld:-\n", l++ ) ;
- for ( k = 0 ; k < j ; k++ )
- printf( " Fld #%d (%s): %s\n", k + 1, aszFlds[ k ],
- (((row[k]==NULL)||(!strlen(row[k])))?"NULL":row[k])) ;
- puts( "==============================\n" ) ;
- }
- }
- else
- {
- printf("Got error %s when retreiving processlist\n",mysql_error(myData));
- }
- //....
- res = mysql_list_tables( myData, "%" ) ; l = 1 ;
- for ( x = 0 ; fd = mysql_fetch_field( res ) ; x++ )
- strcpy( aszFlds[ x ], fd->name ) ;
- while ( row = mysql_fetch_row( res ) ) {
- j = mysql_num_fields( res ) ;
- printf( "Table #%ld:-\n", l++ ) ;
- for ( k = 0 ; k < j ; k++ )
- printf( " Fld #%d (%s): %s\n", k + 1, aszFlds[ k ],
- (((row[k]==NULL)||(!strlen(row[k])))?"NULL":row[k])) ;
- puts( "==============================\n" ) ;
- }
- //....
- pszT = mysql_stat( myData ) ;
- puts( pszT ) ;
- //....
- mysql_close( myData ) ;
- return 0 ;
-
-}
diff --git a/VC++Files/libmysqltest/mytest.dsw b/VC++Files/libmysqltest/mytest.dsw
deleted file mode 100644
index 1aa804386bc..00000000000
--- a/VC++Files/libmysqltest/mytest.dsw
+++ /dev/null
@@ -1,28 +0,0 @@
-Microsoft Developer Studio Workspace File, Format Version 5.00
-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
-
-###############################################################################
-
-Project: "myTest"=".\myTest.dsp" - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Global:
-
-Package=<5>
-{{{
-}}}
-
-Package=<3>
-{{{
-}}}
-
-###############################################################################
diff --git a/client/mysql.cc b/client/mysql.cc
index 2162e4bc25e..999a37e0f7e 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -595,6 +595,10 @@ static struct my_option my_long_options[] =
{"default-character-set", OPT_DEFAULT_CHARSET,
"Set the default character set.", (gptr*) &default_charset,
(gptr*) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+ {"comments", 'c', "Preserve comments. Send comments to the server."
+ " The default is --skip-comments (discard comments), enable with --comments",
+ (gptr*) &preserve_comments, (gptr*) &preserve_comments,
+ 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"compress", 'C', "Use compression in server/client protocol.",
(gptr*) &opt_compress, (gptr*) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0,
0, 0, 0},
@@ -738,9 +742,9 @@ static struct my_option my_long_options[] =
0, 1},
{"max_allowed_packet", OPT_MAX_ALLOWED_PACKET,
"Max packet length to send to, or receive from server",
- (gptr*) &opt_max_allowed_packet, (gptr*) &opt_max_allowed_packet, 0, GET_ULONG,
- REQUIRED_ARG, 16 *1024L*1024L, 4096, (longlong) 2*1024L*1024L*1024L,
- MALLOC_OVERHEAD, 1024, 0},
+ (gptr*) &opt_max_allowed_packet, (gptr*) &opt_max_allowed_packet, 0,
+ GET_ULONG, REQUIRED_ARG, 16 *1024L*1024L, 4096,
+ (longlong) 2*1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0},
{"net_buffer_length", OPT_NET_BUFFER_LENGTH,
"Buffer for TCP/IP and socket communication",
(gptr*) &opt_net_buffer_length, (gptr*) &opt_net_buffer_length, 0, GET_ULONG,
@@ -748,22 +752,19 @@ static struct my_option my_long_options[] =
{"select_limit", OPT_SELECT_LIMIT,
"Automatic limit for SELECT when using --safe-updates",
(gptr*) &select_limit,
- (gptr*) &select_limit, 0, GET_ULONG, REQUIRED_ARG, 1000L, 1, ~0L, 0, 1, 0},
+ (gptr*) &select_limit, 0, GET_ULONG, REQUIRED_ARG, 1000L, 1, ULONG_MAX,
+ 0, 1, 0},
{"max_join_size", OPT_MAX_JOIN_SIZE,
"Automatic limit for rows in a join when using --safe-updates",
(gptr*) &max_join_size,
- (gptr*) &max_join_size, 0, GET_ULONG, REQUIRED_ARG, 1000000L, 1, ~0L, 0, 1,
- 0},
+ (gptr*) &max_join_size, 0, GET_ULONG, REQUIRED_ARG, 1000000L, 1, ULONG_MAX,
+ 0, 1, 0},
{"secure-auth", OPT_SECURE_AUTH, "Refuse client connecting to server if it"
" uses old (pre-4.1.1) protocol", (gptr*) &opt_secure_auth,
(gptr*) &opt_secure_auth, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"show-warnings", OPT_SHOW_WARNINGS, "Show warnings after every statement.",
(gptr*) &show_warnings, (gptr*) &show_warnings, 0, GET_BOOL, NO_ARG,
0, 0, 0, 0, 0, 0},
- {"comments", 'c', "Preserve comments. Send comments to the server."
- " Comments are discarded by default, enable with --enable-comments",
- (gptr*) &preserve_comments, (gptr*) &preserve_comments,
- 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
diff --git a/client/mysqltest.c b/client/mysqltest.c
index e5ae9e80a88..15bf7d792fb 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -4986,7 +4986,7 @@ static struct my_option my_long_options[] =
"Don't use the memory allocation checking.", 0, 0, 0, GET_NO_ARG, NO_ARG,
0, 0, 0, 0, 0, 0},
{"sleep", 'T', "Sleep always this many seconds on sleep commands.",
- (gptr*) &opt_sleep, (gptr*) &opt_sleep, 0, GET_INT, REQUIRED_ARG, -1, 0, 0,
+ (gptr*) &opt_sleep, (gptr*) &opt_sleep, 0, GET_INT, REQUIRED_ARG, -1, -1, 0,
0, 0, 0},
{"socket", 'S', "Socket file to use for connection.",
(gptr*) &unix_sock, (gptr*) &unix_sock, 0, GET_STR, REQUIRED_ARG, 0, 0, 0,
diff --git a/include/m_string.h b/include/m_string.h
index 981111b8718..c26d0fb9260 100644
--- a/include/m_string.h
+++ b/include/m_string.h
@@ -219,6 +219,7 @@ double my_strtod(const char *str, char **end, int *error);
double my_atof(const char *nptr);
extern char *llstr(longlong value,char *buff);
+extern char *ullstr(longlong value,char *buff);
#ifndef HAVE_STRTOUL
extern long strtol(const char *str, char **ptr, int base);
extern ulong strtoul(const char *str, char **ptr, int base);
diff --git a/include/my_getopt.h b/include/my_getopt.h
index dcd6ad9d79b..f5688a37231 100644
--- a/include/my_getopt.h
+++ b/include/my_getopt.h
@@ -67,7 +67,8 @@ extern void my_print_variables(const struct my_option *options);
extern void my_getopt_register_get_addr(gptr* (*func_addr)(const char *, uint,
const struct my_option *));
-ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp);
+ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp,
+ bool *fixed);
my_bool getopt_compare_strings(const char *s, const char *t, uint length);
C_MODE_END
diff --git a/include/mysql_com.h b/include/mysql_com.h
index 889579e3622..94b34c1c3f0 100644
--- a/include/mysql_com.h
+++ b/include/mysql_com.h
@@ -387,12 +387,16 @@ typedef struct st_udf_args
typedef struct st_udf_init
{
- my_bool maybe_null; /* 1 if function can return NULL */
- unsigned int decimals; /* for real functions */
- unsigned long max_length; /* For string functions */
- char *ptr; /* free pointer for function data */
- my_bool const_item; /* 0 if result is independent of arguments */
+ my_bool maybe_null; /* 1 if function can return NULL */
+ unsigned int decimals; /* for real functions */
+ unsigned long max_length; /* For string functions */
+ char *ptr; /* free pointer for function data */
+ my_bool const_item; /* 1 if function always returns the same value */
} UDF_INIT;
+/*
+ TODO: add a notion for determinism of the UDF.
+ See Item_udf_func::update_used_tables ()
+*/
/* Constants when using compression */
#define NET_HEADER_SIZE 4 /* standard header size */
diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt
index 6efdd4afb90..cd90b2b1257 100755
--- a/libmysql/CMakeLists.txt
+++ b/libmysql/CMakeLists.txt
@@ -125,9 +125,6 @@ TARGET_LINK_LIBRARIES(mysqlclient)
ADD_DEPENDENCIES(mysqlclient_notls GenError)
TARGET_LINK_LIBRARIES(mysqlclient_notls)
-ADD_EXECUTABLE(myTest mytest.c)
-TARGET_LINK_LIBRARIES(myTest libmysql)
-
IF(EMBED_MANIFESTS)
MYSQL_EMBED_MANIFEST("myTest" "asInvoker")
ENDIF(EMBED_MANIFESTS)
diff --git a/libmysql/Makefile.am b/libmysql/Makefile.am
index 38680c98d53..13497331683 100644
--- a/libmysql/Makefile.am
+++ b/libmysql/Makefile.am
@@ -31,7 +31,7 @@ include $(srcdir)/Makefile.shared
libmysqlclient_la_SOURCES = $(target_sources)
libmysqlclient_la_LIBADD = $(target_libadd) $(yassl_las)
libmysqlclient_la_LDFLAGS = $(target_ldflags)
-EXTRA_DIST = Makefile.shared libmysql.def dll.c mytest.c CMakeLists.txt
+EXTRA_DIST = Makefile.shared libmysql.def dll.c CMakeLists.txt
noinst_HEADERS = client_settings.h
# This is called from the toplevel makefile
diff --git a/libmysql/mytest.c b/libmysql/mytest.c
deleted file mode 100644
index 2d5c576b72a..00000000000
--- a/libmysql/mytest.c
+++ /dev/null
@@ -1,175 +0,0 @@
-/*C4*/
-/****************************************************************/
-/* Author: Jethro Wright, III TS : 3/ 4/1998 9:15 */
-/* Date: 02/18/1998 */
-/* mytest.c : do some testing of the libmySQL.DLL.... */
-/* */
-/* History: */
-/* 02/18/1998 jw3 also sprach zarathustra.... */
-/****************************************************************/
-
-
-#include <windows.h>
-#include <stdio.h>
-#include <string.h>
-
-#include <mysql.h>
-
-#define DEFALT_SQL_STMT "SELECT * FROM db"
-#ifndef offsetof
-#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
-#endif
-
-
-/********************************************************
-**
-** main :-
-**
-********************************************************/
-
-int
-main( int argc, char * argv[] )
-{
-
- char szSQL[ 200 ], aszFlds[ 25 ][ 25 ], szDB[ 50 ] ;
- const char *pszT;
- int i, j, k, l, x ;
- MYSQL * myData ;
- MYSQL_RES * res ;
- MYSQL_FIELD * fd ;
- MYSQL_ROW row ;
-
- //....just curious....
- printf( "sizeof( MYSQL ) == %d\n", (int) sizeof( MYSQL ) ) ;
- if ( argc == 2 )
- {
- strcpy( szDB, argv[ 1 ] ) ;
- strcpy( szSQL, DEFALT_SQL_STMT ) ;
- if (!strcmp(szDB,"--debug"))
- {
- strcpy( szDB, "mysql" ) ;
- printf("Some mysql struct information (size and offset):\n");
- printf("net:\t%3d %3d\n",(int) sizeof(myData->net),
- (int) offsetof(MYSQL,net));
- printf("host:\t%3d %3d\n",(int) sizeof(myData->host),
- (int) offsetof(MYSQL,host));
- printf("port:\t%3d %3d\n", (int) sizeof(myData->port),
- (int) offsetof(MYSQL,port));
- printf("protocol_version:\t%3d %3d\n",
- (int) sizeof(myData->protocol_version),
- (int) offsetof(MYSQL,protocol_version));
- printf("thread_id:\t%3d %3d\n",(int) sizeof(myData->thread_id),
- (int) offsetof(MYSQL,thread_id));
- printf("affected_rows:\t%3d %3d\n",(int) sizeof(myData->affected_rows),
- (int) offsetof(MYSQL,affected_rows));
- printf("packet_length:\t%3d %3d\n",(int) sizeof(myData->packet_length),
- (int) offsetof(MYSQL,packet_length));
- printf("status:\t%3d %3d\n",(int) sizeof(myData->status),
- (int) offsetof(MYSQL,status));
- printf("fields:\t%3d %3d\n",(int) sizeof(myData->fields),
- (int) offsetof(MYSQL,fields));
- printf("field_alloc:\t%3d %3d\n",(int) sizeof(myData->field_alloc),
- (int) offsetof(MYSQL,field_alloc));
- printf("free_me:\t%3d %3d\n",(int) sizeof(myData->free_me),
- (int) offsetof(MYSQL,free_me));
- printf("options:\t%3d %3d\n",(int) sizeof(myData->options),
- (int) offsetof(MYSQL,options));
- puts("");
- }
- }
- else if ( argc > 2 ) {
- strcpy( szDB, argv[ 1 ] ) ;
- strcpy( szSQL, argv[ 2 ] ) ;
- }
- else {
- strcpy( szDB, "mysql" ) ;
- strcpy( szSQL, DEFALT_SQL_STMT ) ;
- }
- //....
-
- if ( (myData = mysql_init((MYSQL*) 0)) &&
- mysql_real_connect( myData, NULL, NULL, NULL, NULL, MYSQL_PORT,
- NULL, 0 ) )
- {
- myData->reconnect= 1;
- if ( mysql_select_db( myData, szDB ) < 0 ) {
- printf( "Can't select the %s database !\n", szDB ) ;
- mysql_close( myData ) ;
- return 2 ;
- }
- }
- else {
- printf( "Can't connect to the mysql server on port %d !\n",
- MYSQL_PORT ) ;
- mysql_close( myData ) ;
- return 1 ;
- }
- //....
- if ( ! mysql_query( myData, szSQL ) ) {
- res = mysql_store_result( myData ) ;
- i = (int) mysql_num_rows( res ) ; l = 1 ;
- printf( "Query: %s\nNumber of records found: %ld\n", szSQL, i ) ;
- //....we can get the field-specific characteristics here....
- for ( x = 0 ; fd = mysql_fetch_field( res ) ; x++ )
- strcpy( aszFlds[ x ], fd->name ) ;
- //....
- while ( row = mysql_fetch_row( res ) ) {
- j = mysql_num_fields( res ) ;
- printf( "Record #%ld:-\n", l++ ) ;
- for ( k = 0 ; k < j ; k++ )
- printf( " Fld #%d (%s): %s\n", k + 1, aszFlds[ k ],
- (((row[k]==NULL)||(!strlen(row[k])))?"NULL":row[k])) ;
- puts( "==============================\n" ) ;
- }
- mysql_free_result( res ) ;
- }
- else printf( "Couldn't execute %s on the server !\n", szSQL ) ;
- //....
- puts( "==== Diagnostic info ====" ) ;
- pszT = mysql_get_client_info() ;
- printf( "Client info: %s\n", pszT ) ;
- //....
- pszT = mysql_get_host_info( myData ) ;
- printf( "Host info: %s\n", pszT ) ;
- //....
- pszT = mysql_get_server_info( myData ) ;
- printf( "Server info: %s\n", pszT ) ;
- //....
- res = mysql_list_processes( myData ) ; l = 1 ;
- if (res)
- {
- for ( x = 0 ; fd = mysql_fetch_field( res ) ; x++ )
- strcpy( aszFlds[ x ], fd->name ) ;
- while ( row = mysql_fetch_row( res ) ) {
- j = mysql_num_fields( res ) ;
- printf( "Process #%ld:-\n", l++ ) ;
- for ( k = 0 ; k < j ; k++ )
- printf( " Fld #%d (%s): %s\n", k + 1, aszFlds[ k ],
- (((row[k]==NULL)||(!strlen(row[k])))?"NULL":row[k])) ;
- puts( "==============================\n" ) ;
- }
- }
- else
- {
- printf("Got error %s when retreiving processlist\n",mysql_error(myData));
- }
- //....
- res = mysql_list_tables( myData, "%" ) ; l = 1 ;
- for ( x = 0 ; fd = mysql_fetch_field( res ) ; x++ )
- strcpy( aszFlds[ x ], fd->name ) ;
- while ( row = mysql_fetch_row( res ) ) {
- j = mysql_num_fields( res ) ;
- printf( "Table #%ld:-\n", l++ ) ;
- for ( k = 0 ; k < j ; k++ )
- printf( " Fld #%d (%s): %s\n", k + 1, aszFlds[ k ],
- (((row[k]==NULL)||(!strlen(row[k])))?"NULL":row[k])) ;
- puts( "==============================\n" ) ;
- }
- //....
- pszT = mysql_stat( myData ) ;
- puts( pszT ) ;
- //....
- mysql_close( myData ) ;
- return 0 ;
-
-}
diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc
index 7ac663480c8..ce692169a5f 100644
--- a/libmysqld/lib_sql.cc
+++ b/libmysqld/lib_sql.cc
@@ -73,6 +73,7 @@ void embedded_get_error(MYSQL *mysql, MYSQL_DATA *data)
net->last_errno= ei->last_errno;
strmake(net->last_error, ei->info, sizeof(net->last_error));
memcpy(net->sqlstate, ei->sqlstate, sizeof(net->sqlstate));
+ mysql->server_status= ei->server_status;
my_free((gptr) data, MYF(0));
}
@@ -1027,6 +1028,7 @@ void net_send_error_packet(THD *thd, uint sql_errno, const char *err)
ei->last_errno= sql_errno;
strmake(ei->info, err, sizeof(ei->info)-1);
strmov(ei->sqlstate, mysql_errno_to_sqlstate(sql_errno));
+ ei->server_status= thd->server_status;
thd->cur_data= 0;
}
diff --git a/myisam/mi_check.c b/myisam/mi_check.c
index 420bc974752..4407a787950 100644
--- a/myisam/mi_check.c
+++ b/myisam/mi_check.c
@@ -454,7 +454,7 @@ int chk_key(MI_CHECK *param, register MI_INFO *info)
if ((!(param->testflag & T_SILENT)))
printf ("- check data record references index: %d\n",key+1);
- if (keyinfo->flag & HA_FULLTEXT)
+ if (keyinfo->flag & (HA_FULLTEXT | HA_SPATIAL))
full_text_keys++;
if (share->state.key_root[key] == HA_OFFSET_ERROR &&
(info->state->records == 0 || keyinfo->flag & HA_FULLTEXT))
diff --git a/mysql-test/include/ps_query.inc b/mysql-test/include/ps_query.inc
index e96d666eaec..ae6027a0e07 100644
--- a/mysql-test/include/ps_query.inc
+++ b/mysql-test/include/ps_query.inc
@@ -434,8 +434,8 @@ execute stmt1 ;
let $1= 3 ;
while ($1)
{
- prepare stmt1 from ' SELECT a as ccc from t1 where a+1=
- (SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) ';
+ prepare stmt1 from ' SELECT a as ccc from t1 outr where a+1=
+ (SELECT 1+outr.a from t1 where outr.a+1=a+1 and a=1) ';
execute stmt1 ;
deallocate prepare stmt1 ;
dec $1 ;
diff --git a/mysql-test/r/delayed.result b/mysql-test/r/delayed.result
index 9f6ebea7e1b..e7ee23b3e2a 100644
--- a/mysql-test/r/delayed.result
+++ b/mysql-test/r/delayed.result
@@ -109,12 +109,20 @@ c1
DROP TABLE t1;
SET @@auto_increment_offset=
@bug20627_old_auto_increment_offset;
+Warnings:
+Warning 1292 Truncated incorrect auto-increment-offset value: '0'
SET @@auto_increment_increment=
@bug20627_old_auto_increment_increment;
+Warnings:
+Warning 1292 Truncated incorrect auto-increment-increment value: '0'
SET @@session.auto_increment_offset=
@bug20627_old_session_auto_increment_offset;
+Warnings:
+Warning 1292 Truncated incorrect auto-increment-offset value: '0'
SET @@session.auto_increment_increment=
@bug20627_old_session_auto_increment_increment;
+Warnings:
+Warning 1292 Truncated incorrect auto-increment-increment value: '0'
SET @bug20830_old_auto_increment_offset=
@@auto_increment_offset;
SET @bug20830_old_auto_increment_increment=
@@ -237,12 +245,20 @@ SUM(c1)
DROP TABLE t1;
SET @@auto_increment_offset=
@bug20830_old_auto_increment_offset;
+Warnings:
+Warning 1292 Truncated incorrect auto-increment-offset value: '0'
SET @@auto_increment_increment=
@bug20830_old_auto_increment_increment;
+Warnings:
+Warning 1292 Truncated incorrect auto-increment-increment value: '0'
SET @@session.auto_increment_offset=
@bug20830_old_session_auto_increment_offset;
+Warnings:
+Warning 1292 Truncated incorrect auto-increment-offset value: '0'
SET @@session.auto_increment_increment=
@bug20830_old_session_auto_increment_increment;
+Warnings:
+Warning 1292 Truncated incorrect auto-increment-increment value: '0'
CREATE TABLE t1(a BIT);
INSERT DELAYED INTO t1 VALUES(1);
FLUSH TABLE t1;
diff --git a/mysql-test/r/delete.result b/mysql-test/r/delete.result
index eb93c69d960..a682d90fbf7 100644
--- a/mysql-test/r/delete.result
+++ b/mysql-test/r/delete.result
@@ -234,43 +234,6 @@ ERROR 42S22: Unknown column 't2.x' in 'order clause'
DELETE FROM t1 ORDER BY (SELECT x);
ERROR 42S22: Unknown column 'x' in 'field list'
DROP TABLE t1;
-CREATE TABLE t1 (
-a INT
-);
-CREATE TABLE t2 (
-a INT
-);
-CREATE DATABASE db1;
-CREATE TABLE db1.t1 (
-a INT
-);
-INSERT INTO db1.t1 (a) SELECT * FROM t1;
-CREATE DATABASE db2;
-CREATE TABLE db2.t1 (
-a INT
-);
-INSERT INTO db2.t1 (a) SELECT * FROM t2;
-DELETE FROM t1 alias USING t1, t2 alias WHERE t1.a = alias.a;
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'alias USING t1, t2 alias WHERE t1.a = alias.a' at line 1
-DELETE FROM alias USING t1, t2 alias WHERE t1.a = alias.a;
-DELETE FROM t1, alias USING t1, t2 alias WHERE t1.a = alias.a;
-DELETE FROM t1, t2 USING t1, t2 alias WHERE t1.a = alias.a;
-ERROR 42S02: Unknown table 't2' in MULTI DELETE
-DELETE FROM db1.t1 alias USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a;
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'alias USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a' at line 1
-DELETE FROM alias USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a;
-ERROR 42S02: Unknown table 'alias' in MULTI DELETE
-DELETE FROM db2.alias USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a;
-DELETE FROM t1 USING t1 WHERE a = 1;
-SELECT * FROM t1;
-a
-DELETE FROM t1 alias USING t1 alias WHERE a = 2;
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'alias USING t1 alias WHERE a = 2' at line 1
-SELECT * FROM t1;
-a
-DROP TABLE t1, t2;
-DROP DATABASE db1;
-DROP DATABASE db2;
CREATE FUNCTION f1() RETURNS INT RETURN 1;
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (0);
diff --git a/mysql-test/r/explain.result b/mysql-test/r/explain.result
index 24ff44945bf..a4c8432d2a4 100644
--- a/mysql-test/r/explain.result
+++ b/mysql-test/r/explain.result
@@ -87,3 +87,23 @@ Warnings:
Note 1003 select '1' AS `f1`,'1' AS `f2` from `test`.`t1` having 1
drop view v1;
drop table t1;
+CREATE TABLE t1(c INT);
+INSERT INTO t1 VALUES (),();
+CREATE TABLE t2 (b INT,
+KEY(b),KEY(b),KEY(b),KEY(b),KEY(b),
+KEY(b),KEY(b),KEY(b),KEY(b),KEY(b),
+KEY(b),KEY(b),KEY(b),KEY(b),KEY(b),
+KEY(b),KEY(b),KEY(b),KEY(b),KEY(b),
+KEY(b),KEY(b),KEY(b),KEY(b),KEY(b),
+KEY(b),KEY(b),KEY(b),KEY(b),KEY(b),
+KEY(b),KEY(b),KEY(b),KEY(b),KEY(b),
+KEY(b),KEY(b),KEY(b),KEY(b),KEY(b));
+INSERT INTO t2 VALUES (),(),();
+EXPLAIN SELECT 1 FROM
+(SELECT 1 FROM t2,t1 WHERE b < c GROUP BY 1 LIMIT 1) AS d2;
+id select_type table type possible_keys key key_len ref rows Extra
+X X X X X X X X X const row not found
+X X X X X X X X X
+X X X X X X X X X Range checked for each record (index map: 0xFFFFFFFFFF)
+DROP TABLE t2;
+DROP TABLE t1;
diff --git a/mysql-test/r/federated.result b/mysql-test/r/federated.result
index 2e7d0ddcea7..a005db4deac 100644
--- a/mysql-test/r/federated.result
+++ b/mysql-test/r/federated.result
@@ -1934,6 +1934,117 @@ select * from federated.t2;
a
1
drop table federated.t1, federated.t2;
+create table t1 (a varchar(256));
+drop view if exists v1;
+create view v1 as select a from t1;
+create table t1
+(a varchar(256)) engine=federated
+connection='mysql://root@127.0.0.1:SLAVE_PORT/test/v1';
+select 1 from t1 order by a;
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+drop table t1;
+drop table t1;
+drop view v1;
DROP TABLE IF EXISTS federated.t1;
DROP DATABASE IF EXISTS federated;
DROP TABLE IF EXISTS federated.t1;
diff --git a/mysql-test/r/func_misc.result b/mysql-test/r/func_misc.result
index c0b666dbc79..4ba5ee674a9 100644
--- a/mysql-test/r/func_misc.result
+++ b/mysql-test/r/func_misc.result
@@ -207,6 +207,11 @@ test
SELECT NAME_CONST('test', 'test');
test
test
+CREATE TABLE t1 (a int);
+INSERT INTO t1 VALUES (5), (2);
+SELECT NAME_CONST(x,2) FROM (SELECT a x FROM t1) t;
+ERROR HY000: The 'NAME_CONST' syntax is reserved for purposes internal to the MySQL server
+DROP TABLE t1;
CREATE TABLE t1(a INT);
INSERT INTO t1 VALUES (), (), ();
SELECT NAME_CONST(a, '1') FROM t1;
diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result
index 74859be4d04..71234385c0d 100644
--- a/mysql-test/r/func_time.result
+++ b/mysql-test/r/func_time.result
@@ -1270,4 +1270,16 @@ select concat(a,ifnull(min(date_format(now(), '%Y-%m-%d')),' ull')) from t1;
ERROR HY000: Illegal mix of collations (ascii_general_ci,IMPLICIT) and (latin1_swedish_ci,COERCIBLE) for operation 'concat'
set lc_time_names=en_US;
drop table t1;
+select DATE_ADD('20071108181000', INTERVAL 1 DAY);
+DATE_ADD('20071108181000', INTERVAL 1 DAY)
+2007-11-09 18:10:00
+select DATE_ADD(20071108181000, INTERVAL 1 DAY);
+DATE_ADD(20071108181000, INTERVAL 1 DAY)
+2007-11-09 18:10:00
+select DATE_ADD('20071108', INTERVAL 1 DAY);
+DATE_ADD('20071108', INTERVAL 1 DAY)
+2007-11-09
+select DATE_ADD(20071108, INTERVAL 1 DAY);
+DATE_ADD(20071108, INTERVAL 1 DAY)
+2007-11-09
End of 5.0 tests
diff --git a/mysql-test/r/gis.result b/mysql-test/r/gis.result
index 40c70721347..ac6356f8203 100644
--- a/mysql-test/r/gis.result
+++ b/mysql-test/r/gis.result
@@ -680,7 +680,7 @@ def test t1 t1 g g 255 4294967295 0 Y 144 0 63
g
select asbinary(g) from t1;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
-def asbinary(g) 252 8192 0 Y 128 0 63
+def asbinary(g) 252 4294967295 0 Y 128 0 63
asbinary(g)
drop table t1;
create table t1 (a TEXT, b GEOMETRY NOT NULL, SPATIAL KEY(b));
@@ -742,6 +742,38 @@ select geomfromtext(col9,col89) as a from t1;
a
NULL
DROP TABLE t1;
+CREATE TABLE t1 (
+geomdata polygon NOT NULL,
+SPATIAL KEY index_geom (geomdata)
+) ENGINE=MyISAM DEFAULT CHARSET=latin2 DELAY_KEY_WRITE=1 ROW_FORMAT=FIXED;
+CREATE TABLE t2 (
+geomdata polygon NOT NULL,
+SPATIAL KEY index_geom (geomdata)
+) ENGINE=MyISAM DEFAULT CHARSET=latin2 DELAY_KEY_WRITE=1 ROW_FORMAT=FIXED;
+CREATE TABLE t3
+select
+aswkb(ws.geomdata) AS geomdatawkb
+from
+t1 ws
+union
+select
+aswkb(ws.geomdata) AS geomdatawkb
+from
+t2 ws;
+describe t3;
+Field Type Null Key Default Extra
+geomdatawkb longblob YES NULL
+drop table t1;
+drop table t2;
+drop table t3;
+create table t1(col1 geometry default null,col15 geometrycollection not
+null,spatial index(col15),index(col1(15)))engine=myisam;
+insert into t1 set col15 = GeomFromText('POINT(6 5)');
+insert into t1 set col15 = GeomFromText('POINT(6 5)');
+check table t1 extended;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+drop table t1;
End of 4.1 tests
create table t1 (s1 geometry not null,s2 char(100));
create trigger t1_bu before update on t1 for each row set new.s1 = null;
@@ -933,4 +965,10 @@ COUNT(*)
2
DROP TABLE t1, t2;
End of 5.0 tests
+create table `t1` (`col002` point)engine=myisam;
+insert into t1 values (),(),();
+select min(`col002`) from t1 union select `col002` from t1;
+min(`col002`)
+NULL
+drop table t1;
End of 5.0 tests
diff --git a/mysql-test/r/group_min_max.result b/mysql-test/r/group_min_max.result
index 2e5193f8563..5982931e677 100644
--- a/mysql-test/r/group_min_max.result
+++ b/mysql-test/r/group_min_max.result
@@ -2307,3 +2307,49 @@ a
2
4
DROP TABLE t1;
+CREATE TABLE t1 (a INT, b INT);
+INSERT INTO t1 (a, b) VALUES (1,1), (1,2), (1,3);
+INSERT INTO t1 SELECT a + 1, b FROM t1;
+INSERT INTO t1 SELECT a + 2, b FROM t1;
+EXPLAIN
+SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 12 Using temporary; Using filesort
+SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC;
+a MIN(b) MAX(b)
+4 1 3
+3 1 3
+2 1 3
+1 1 3
+CREATE INDEX break_it ON t1 (a, b);
+EXPLAIN
+SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL break_it 10 NULL 7 Using index for group-by
+SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a;
+a MIN(b) MAX(b)
+1 1 3
+2 1 3
+3 1 3
+4 1 3
+EXPLAIN
+SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL break_it 10 NULL 7 Using index for group-by; Using temporary; Using filesort
+SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC;
+a MIN(b) MAX(b)
+4 1 3
+3 1 3
+2 1 3
+1 1 3
+EXPLAIN
+SELECT a, MIN(b), MAX(b), AVG(b) FROM t1 GROUP BY a ORDER BY a DESC;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL break_it 10 NULL 12 Using index
+SELECT a, MIN(b), MAX(b), AVG(b) FROM t1 GROUP BY a ORDER BY a DESC;
+a MIN(b) MAX(b) AVG(b)
+4 1 3 2.0000
+3 1 3 2.0000
+2 1 3 2.0000
+1 1 3 2.0000
+DROP TABLE t1;
diff --git a/mysql-test/r/index_merge.result b/mysql-test/r/index_merge.result
index 15aa636d740..3a152fb2327 100644
--- a/mysql-test/r/index_merge.result
+++ b/mysql-test/r/index_merge.result
@@ -340,6 +340,8 @@ create table t4 (a int);
insert into t4 values (1),(4),(3);
set @save_join_buffer_size=@@join_buffer_size;
set join_buffer_size= 4000;
+Warnings:
+Warning 1292 Truncated incorrect join_buffer_size value: '4000'
explain select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5)
from t0 as A force index(i1,i2), t0 as B force index (i1,i2)
where (A.key1 < 500000 or A.key2 < 3)
diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result
index 38b26425ec8..854712fdb1d 100644
--- a/mysql-test/r/innodb.result
+++ b/mysql-test/r/innodb.result
@@ -1846,6 +1846,8 @@ show variables like "innodb_thread_concurrency";
Variable_name Value
innodb_thread_concurrency 8
set global innodb_thread_concurrency=1001;
+Warnings:
+Warning 1292 Truncated incorrect innodb_thread_concurrency value: '1001'
show variables like "innodb_thread_concurrency";
Variable_name Value
innodb_thread_concurrency 1000
@@ -1865,6 +1867,8 @@ show variables like "innodb_concurrency_tickets";
Variable_name Value
innodb_concurrency_tickets 1000
set global innodb_concurrency_tickets=0;
+Warnings:
+Warning 1292 Truncated incorrect innodb_concurrency_tickets value: '0'
show variables like "innodb_concurrency_tickets";
Variable_name Value
innodb_concurrency_tickets 1
diff --git a/mysql-test/r/innodb_mysql.result b/mysql-test/r/innodb_mysql.result
index 5a85df76347..2ab463e7f85 100644
--- a/mysql-test/r/innodb_mysql.result
+++ b/mysql-test/r/innodb_mysql.result
@@ -712,6 +712,8 @@ INSERT INTO t1(b,c) SELECT b,c FROM t2;
UPDATE t2 SET c='2007-01-03';
INSERT INTO t1(b,c) SELECT b,c FROM t2;
set @@sort_buffer_size=8192;
+Warnings:
+Warning 1292 Truncated incorrect sort_buffer_size value: '8192'
SELECT COUNT(*) FROM t1;
COUNT(*)
3072
@@ -1211,6 +1213,18 @@ a b
3 2
1 1
DROP TABLE t1;
+CREATE TABLE t1 (id int, type char(6), d int, INDEX idx(id,d)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES
+(191, 'member', 1), (NULL, 'member', 3), (NULL, 'member', 4), (201, 'member', 2);
+EXPLAIN SELECT * FROM t1 WHERE id=191 OR id IS NULL ORDER BY d;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL idx NULL NULL NULL 3 Using where; Using filesort
+SELECT * FROM t1 WHERE id=191 OR id IS NULL ORDER BY d;
+id type d
+191 member 1
+NULL member 3
+NULL member 4
+DROP TABLE t1;
create table t1(a char(10) not null, unique key aa(a(1)),
b char(4) not null, unique key bb(b(4))) engine=innodb;
desc t1;
diff --git a/mysql-test/r/key_cache.result b/mysql-test/r/key_cache.result
index 08d8059f61b..9ada5dc0784 100644
--- a/mysql-test/r/key_cache.result
+++ b/mysql-test/r/key_cache.result
@@ -276,6 +276,8 @@ Variable_name Value
Key_blocks_unused KEY_BLOCKS_UNUSED
set global keycache2.key_buffer_size=0;
set global keycache3.key_buffer_size=100;
+Warnings:
+Warning 1292 Truncated incorrect key_buffer_size value: '100'
set global keycache3.key_buffer_size=0;
create table t1 (mytext text, FULLTEXT (mytext));
insert t1 values ('aaabbb');
diff --git a/mysql-test/r/merge.result b/mysql-test/r/merge.result
index 24a56fbf575..2ceae95dfca 100644
--- a/mysql-test/r/merge.result
+++ b/mysql-test/r/merge.result
@@ -881,4 +881,41 @@ CREATE TABLE t2 (c1 INT) ENGINE=MERGE UNION=(t1) INSERT_METHOD=FIRST;
CREATE TABLE IF NOT EXISTS t1 SELECT * FROM t2;
ERROR HY000: You can't specify target table 't1' for update in FROM clause
DROP TABLE t1, t2;
+CREATE TABLE t1 (id INT NOT NULL, ref INT NOT NULL, INDEX (id)) ENGINE=MyISAM;
+CREATE TABLE t2 LIKE t1;
+INSERT INTO t2 (id, ref) VALUES (1,3), (2,1), (3,2), (4,5), (4,4);
+INSERT INTO t1 SELECT * FROM t2;
+INSERT INTO t1 SELECT * FROM t2;
+CREATE TABLE t3 (id INT NOT NULL, ref INT NOT NULL, INDEX (id)) ENGINE=MERGE
+UNION(t1);
+SELECT * FROM t3 AS a INNER JOIN t3 AS b USING (id) WHERE a.ref < b.ref;
+id ref ref
+4 4 5
+4 4 5
+4 4 5
+4 4 5
+SELECT * FROM t3;
+id ref
+1 3
+2 1
+3 2
+4 5
+4 4
+1 3
+2 1
+3 2
+4 5
+4 4
+DELETE FROM a USING t3 AS a INNER JOIN t3 AS b USING (id) WHERE a.ref < b.ref;
+SELECT * FROM t3;
+id ref
+1 3
+2 1
+3 2
+4 5
+1 3
+2 1
+3 2
+4 5
+DROP TABLE t1, t2, t3;
End of 5.0 tests
diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result
index 56933f45fbf..33f64d600bb 100644
--- a/mysql-test/r/myisam.result
+++ b/mysql-test/r/myisam.result
@@ -1839,4 +1839,26 @@ CHECK TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 check status OK
DROP TABLE t1;
+CREATE TABLE t1 (id int NOT NULL, ref int NOT NULL, INDEX (id)) ENGINE=MyISAM;
+CREATE TABLE t2 LIKE t1;
+INSERT INTO t2 (id, ref) VALUES (1,3), (2,1), (3,2), (4,5), (4,4);
+INSERT INTO t1 SELECT * FROM t2;
+SELECT * FROM t1 AS a INNER JOIN t1 AS b USING (id) WHERE a.ref < b.ref;
+id ref ref
+4 4 5
+SELECT * FROM t1;
+id ref
+1 3
+2 1
+3 2
+4 5
+4 4
+DELETE FROM a USING t1 AS a INNER JOIN t1 AS b USING (id) WHERE a.ref < b.ref;
+SELECT * FROM t1;
+id ref
+1 3
+2 1
+3 2
+4 5
+DROP TABLE t1, t2;
End of 5.0 tests
diff --git a/mysql-test/r/outfile_loaddata.result b/mysql-test/r/outfile_loaddata.result
index 1bcaf308b7c..4a9bdcf412d 100644
--- a/mysql-test/r/outfile_loaddata.result
+++ b/mysql-test/r/outfile_loaddata.result
@@ -82,4 +82,22 @@ c1 c2
-r- =raker=
DROP TABLE t2;
DROP TABLE t1;
+#
+# Bug#32533: SELECT INTO OUTFILE never escapes multibyte character
+#
+CREATE TABLE t1 (c1 VARCHAR(256));
+INSERT INTO t1 VALUES (0xC3);
+SELECT HEX(c1) FROM t1;
+HEX(c1)
+C3
+SELECT * INTO OUTFILE 'MYSQLTEST_VARDIR/tmp/bug32533.txt' FIELDS ENCLOSED BY 0xC3 FROM t1;
+TRUNCATE t1;
+SELECT HEX(LOAD_FILE('MYSQLTEST_VARDIR/tmp/bug32533.txt'));
+HEX(LOAD_FILE('MYSQLTEST_VARDIR/tmp/bug32533.txt'))
+C35CC3C30A
+LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/bug32533.txt' INTO TABLE t1 FIELDS ENCLOSED BY 0xC3;
+SELECT HEX(c1) FROM t1;
+HEX(c1)
+C3
+DROP TABLE t1;
# End of 5.0 tests.
diff --git a/mysql-test/r/packet.result b/mysql-test/r/packet.result
index dfb5595e02d..df0d9ff9adc 100644
--- a/mysql-test/r/packet.result
+++ b/mysql-test/r/packet.result
@@ -1,7 +1,15 @@
set global max_allowed_packet=100;
+Warnings:
+Warning 1292 Truncated incorrect max_allowed_packet value: '100'
set max_allowed_packet=100;
+Warnings:
+Warning 1292 Truncated incorrect max_allowed_packet value: '100'
set global net_buffer_length=100;
+Warnings:
+Warning 1292 Truncated incorrect net_buffer_length value: '100'
set net_buffer_length=100;
+Warnings:
+Warning 1292 Truncated incorrect net_buffer_length value: '100'
SELECT length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") as len;
len
1024
diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result
index 0682cae5c80..f547654bed1 100644
--- a/mysql-test/r/ps.result
+++ b/mysql-test/r/ps.result
@@ -806,6 +806,8 @@ select @@max_prepared_stmt_count;
@@max_prepared_stmt_count
0
set global max_prepared_stmt_count=10000000000000000;
+Warnings:
+Warning 1292 Truncated incorrect max_prepared_stmt_count value: '10000000000000000'
select @@max_prepared_stmt_count;
@@max_prepared_stmt_count
1048576
diff --git a/mysql-test/r/ps_2myisam.result b/mysql-test/r/ps_2myisam.result
index 57932a6c455..891e8e4ff02 100644
--- a/mysql-test/r/ps_2myisam.result
+++ b/mysql-test/r/ps_2myisam.result
@@ -783,20 +783,20 @@ a b
2 two
3 three
4 four
-prepare stmt1 from ' SELECT a as ccc from t1 where a+1=
- (SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) ';
+prepare stmt1 from ' SELECT a as ccc from t1 outr where a+1=
+ (SELECT 1+outr.a from t1 where outr.a+1=a+1 and a=1) ';
execute stmt1 ;
ccc
1
deallocate prepare stmt1 ;
-prepare stmt1 from ' SELECT a as ccc from t1 where a+1=
- (SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) ';
+prepare stmt1 from ' SELECT a as ccc from t1 outr where a+1=
+ (SELECT 1+outr.a from t1 where outr.a+1=a+1 and a=1) ';
execute stmt1 ;
ccc
1
deallocate prepare stmt1 ;
-prepare stmt1 from ' SELECT a as ccc from t1 where a+1=
- (SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) ';
+prepare stmt1 from ' SELECT a as ccc from t1 outr where a+1=
+ (SELECT 1+outr.a from t1 where outr.a+1=a+1 and a=1) ';
execute stmt1 ;
ccc
1
@@ -1933,7 +1933,7 @@ def @arg13 253 8192 10 Y 128 31 63
def @arg14 253 8192 19 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 8 Y 128 31 63
-def @arg17 253 20 4 Y 128 0 63
+def @arg17 253 20 4 Y 160 0 63
def @arg18 253 20 1 Y 128 0 63
def @arg19 253 20 1 Y 128 0 63
def @arg20 253 8192 1 Y 0 31 8
@@ -1980,7 +1980,7 @@ def @arg13 253 8192 0 Y 128 31 63
def @arg14 253 8192 0 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 0 Y 128 31 63
-def @arg17 253 20 0 Y 128 0 63
+def @arg17 253 20 0 Y 160 0 63
def @arg18 253 20 0 Y 128 0 63
def @arg19 253 20 0 Y 128 0 63
def @arg20 253 8192 0 Y 0 31 8
@@ -2030,7 +2030,7 @@ def @arg13 253 8192 10 Y 128 31 63
def @arg14 253 8192 19 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 8 Y 128 31 63
-def @arg17 253 20 4 Y 128 0 63
+def @arg17 253 20 4 Y 160 0 63
def @arg18 253 20 1 Y 128 0 63
def @arg19 253 20 1 Y 128 0 63
def @arg20 253 8192 1 Y 0 31 8
@@ -2070,7 +2070,7 @@ def @arg13 253 8192 0 Y 128 31 63
def @arg14 253 8192 0 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 0 Y 128 31 63
-def @arg17 253 20 0 Y 128 0 63
+def @arg17 253 20 0 Y 160 0 63
def @arg18 253 20 0 Y 128 0 63
def @arg19 253 20 0 Y 128 0 63
def @arg20 253 8192 0 Y 0 31 8
@@ -2118,7 +2118,7 @@ def @arg13 253 8192 10 Y 128 31 63
def @arg14 253 8192 19 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 8 Y 128 31 63
-def @arg17 253 20 4 Y 128 0 63
+def @arg17 253 20 4 Y 160 0 63
def @arg18 253 20 1 Y 128 0 63
def @arg19 253 20 1 Y 128 0 63
def @arg20 253 8192 1 Y 0 31 8
@@ -2162,7 +2162,7 @@ def @arg13 253 8192 0 Y 128 31 63
def @arg14 253 8192 0 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 0 Y 128 31 63
-def @arg17 253 20 0 Y 128 0 63
+def @arg17 253 20 0 Y 160 0 63
def @arg18 253 20 0 Y 128 0 63
def @arg19 253 20 0 Y 128 0 63
def @arg20 253 8192 0 Y 0 31 8
@@ -2208,7 +2208,7 @@ def @arg13 253 8192 10 Y 128 31 63
def @arg14 253 8192 19 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 8 Y 128 31 63
-def @arg17 253 20 4 Y 128 0 63
+def @arg17 253 20 4 Y 160 0 63
def @arg18 253 20 1 Y 128 0 63
def @arg19 253 20 1 Y 128 0 63
def @arg20 253 8192 1 Y 0 31 8
@@ -2246,7 +2246,7 @@ def @arg13 253 8192 0 Y 128 31 63
def @arg14 253 8192 0 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 0 Y 128 31 63
-def @arg17 253 20 0 Y 128 0 63
+def @arg17 253 20 0 Y 160 0 63
def @arg18 253 20 0 Y 128 0 63
def @arg19 253 20 0 Y 128 0 63
def @arg20 253 8192 0 Y 0 31 8
diff --git a/mysql-test/r/ps_3innodb.result b/mysql-test/r/ps_3innodb.result
index fd24c29d558..abbaba7463c 100644
--- a/mysql-test/r/ps_3innodb.result
+++ b/mysql-test/r/ps_3innodb.result
@@ -783,20 +783,20 @@ a b
2 two
3 three
4 four
-prepare stmt1 from ' SELECT a as ccc from t1 where a+1=
- (SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) ';
+prepare stmt1 from ' SELECT a as ccc from t1 outr where a+1=
+ (SELECT 1+outr.a from t1 where outr.a+1=a+1 and a=1) ';
execute stmt1 ;
ccc
1
deallocate prepare stmt1 ;
-prepare stmt1 from ' SELECT a as ccc from t1 where a+1=
- (SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) ';
+prepare stmt1 from ' SELECT a as ccc from t1 outr where a+1=
+ (SELECT 1+outr.a from t1 where outr.a+1=a+1 and a=1) ';
execute stmt1 ;
ccc
1
deallocate prepare stmt1 ;
-prepare stmt1 from ' SELECT a as ccc from t1 where a+1=
- (SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) ';
+prepare stmt1 from ' SELECT a as ccc from t1 outr where a+1=
+ (SELECT 1+outr.a from t1 where outr.a+1=a+1 and a=1) ';
execute stmt1 ;
ccc
1
@@ -1916,7 +1916,7 @@ def @arg13 253 8192 10 Y 128 31 63
def @arg14 253 8192 19 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 8 Y 128 31 63
-def @arg17 253 20 4 Y 128 0 63
+def @arg17 253 20 4 Y 160 0 63
def @arg18 253 20 1 Y 128 0 63
def @arg19 253 20 1 Y 128 0 63
def @arg20 253 8192 1 Y 0 31 8
@@ -1963,7 +1963,7 @@ def @arg13 253 8192 0 Y 128 31 63
def @arg14 253 8192 0 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 0 Y 128 31 63
-def @arg17 253 20 0 Y 128 0 63
+def @arg17 253 20 0 Y 160 0 63
def @arg18 253 20 0 Y 128 0 63
def @arg19 253 20 0 Y 128 0 63
def @arg20 253 8192 0 Y 0 31 8
@@ -2013,7 +2013,7 @@ def @arg13 253 8192 10 Y 128 31 63
def @arg14 253 8192 19 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 8 Y 128 31 63
-def @arg17 253 20 4 Y 128 0 63
+def @arg17 253 20 4 Y 160 0 63
def @arg18 253 20 1 Y 128 0 63
def @arg19 253 20 1 Y 128 0 63
def @arg20 253 8192 1 Y 0 31 8
@@ -2053,7 +2053,7 @@ def @arg13 253 8192 0 Y 128 31 63
def @arg14 253 8192 0 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 0 Y 128 31 63
-def @arg17 253 20 0 Y 128 0 63
+def @arg17 253 20 0 Y 160 0 63
def @arg18 253 20 0 Y 128 0 63
def @arg19 253 20 0 Y 128 0 63
def @arg20 253 8192 0 Y 0 31 8
@@ -2101,7 +2101,7 @@ def @arg13 253 8192 10 Y 128 31 63
def @arg14 253 8192 19 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 8 Y 128 31 63
-def @arg17 253 20 4 Y 128 0 63
+def @arg17 253 20 4 Y 160 0 63
def @arg18 253 20 1 Y 128 0 63
def @arg19 253 20 1 Y 128 0 63
def @arg20 253 8192 1 Y 0 31 8
@@ -2145,7 +2145,7 @@ def @arg13 253 8192 0 Y 128 31 63
def @arg14 253 8192 0 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 0 Y 128 31 63
-def @arg17 253 20 0 Y 128 0 63
+def @arg17 253 20 0 Y 160 0 63
def @arg18 253 20 0 Y 128 0 63
def @arg19 253 20 0 Y 128 0 63
def @arg20 253 8192 0 Y 0 31 8
@@ -2191,7 +2191,7 @@ def @arg13 253 8192 10 Y 128 31 63
def @arg14 253 8192 19 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 8 Y 128 31 63
-def @arg17 253 20 4 Y 128 0 63
+def @arg17 253 20 4 Y 160 0 63
def @arg18 253 20 1 Y 128 0 63
def @arg19 253 20 1 Y 128 0 63
def @arg20 253 8192 1 Y 0 31 8
@@ -2229,7 +2229,7 @@ def @arg13 253 8192 0 Y 128 31 63
def @arg14 253 8192 0 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 0 Y 128 31 63
-def @arg17 253 20 0 Y 128 0 63
+def @arg17 253 20 0 Y 160 0 63
def @arg18 253 20 0 Y 128 0 63
def @arg19 253 20 0 Y 128 0 63
def @arg20 253 8192 0 Y 0 31 8
diff --git a/mysql-test/r/ps_4heap.result b/mysql-test/r/ps_4heap.result
index b4596ab85bc..e6a4caadf1e 100644
--- a/mysql-test/r/ps_4heap.result
+++ b/mysql-test/r/ps_4heap.result
@@ -784,20 +784,20 @@ a b
2 two
3 three
4 four
-prepare stmt1 from ' SELECT a as ccc from t1 where a+1=
- (SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) ';
+prepare stmt1 from ' SELECT a as ccc from t1 outr where a+1=
+ (SELECT 1+outr.a from t1 where outr.a+1=a+1 and a=1) ';
execute stmt1 ;
ccc
1
deallocate prepare stmt1 ;
-prepare stmt1 from ' SELECT a as ccc from t1 where a+1=
- (SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) ';
+prepare stmt1 from ' SELECT a as ccc from t1 outr where a+1=
+ (SELECT 1+outr.a from t1 where outr.a+1=a+1 and a=1) ';
execute stmt1 ;
ccc
1
deallocate prepare stmt1 ;
-prepare stmt1 from ' SELECT a as ccc from t1 where a+1=
- (SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) ';
+prepare stmt1 from ' SELECT a as ccc from t1 outr where a+1=
+ (SELECT 1+outr.a from t1 where outr.a+1=a+1 and a=1) ';
execute stmt1 ;
ccc
1
@@ -1917,7 +1917,7 @@ def @arg13 253 8192 10 Y 128 31 63
def @arg14 253 8192 19 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 8 Y 128 31 63
-def @arg17 253 20 4 Y 128 0 63
+def @arg17 253 20 4 Y 160 0 63
def @arg18 253 20 1 Y 128 0 63
def @arg19 253 20 1 Y 128 0 63
def @arg20 253 8192 1 Y 0 31 8
@@ -1964,7 +1964,7 @@ def @arg13 253 8192 0 Y 128 31 63
def @arg14 253 8192 0 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 0 Y 128 31 63
-def @arg17 253 20 0 Y 128 0 63
+def @arg17 253 20 0 Y 160 0 63
def @arg18 253 20 0 Y 128 0 63
def @arg19 253 20 0 Y 128 0 63
def @arg20 253 8192 0 Y 0 31 8
@@ -2014,7 +2014,7 @@ def @arg13 253 8192 10 Y 128 31 63
def @arg14 253 8192 19 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 8 Y 128 31 63
-def @arg17 253 20 4 Y 128 0 63
+def @arg17 253 20 4 Y 160 0 63
def @arg18 253 20 1 Y 128 0 63
def @arg19 253 20 1 Y 128 0 63
def @arg20 253 8192 1 Y 0 31 8
@@ -2054,7 +2054,7 @@ def @arg13 253 8192 0 Y 128 31 63
def @arg14 253 8192 0 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 0 Y 128 31 63
-def @arg17 253 20 0 Y 128 0 63
+def @arg17 253 20 0 Y 160 0 63
def @arg18 253 20 0 Y 128 0 63
def @arg19 253 20 0 Y 128 0 63
def @arg20 253 8192 0 Y 0 31 8
@@ -2102,7 +2102,7 @@ def @arg13 253 8192 10 Y 128 31 63
def @arg14 253 8192 19 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 8 Y 128 31 63
-def @arg17 253 20 4 Y 128 0 63
+def @arg17 253 20 4 Y 160 0 63
def @arg18 253 20 1 Y 128 0 63
def @arg19 253 20 1 Y 128 0 63
def @arg20 253 8192 1 Y 0 31 8
@@ -2146,7 +2146,7 @@ def @arg13 253 8192 0 Y 128 31 63
def @arg14 253 8192 0 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 0 Y 128 31 63
-def @arg17 253 20 0 Y 128 0 63
+def @arg17 253 20 0 Y 160 0 63
def @arg18 253 20 0 Y 128 0 63
def @arg19 253 20 0 Y 128 0 63
def @arg20 253 8192 0 Y 0 31 8
@@ -2192,7 +2192,7 @@ def @arg13 253 8192 10 Y 128 31 63
def @arg14 253 8192 19 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 8 Y 128 31 63
-def @arg17 253 20 4 Y 128 0 63
+def @arg17 253 20 4 Y 160 0 63
def @arg18 253 20 1 Y 128 0 63
def @arg19 253 20 1 Y 128 0 63
def @arg20 253 8192 1 Y 0 31 8
@@ -2230,7 +2230,7 @@ def @arg13 253 8192 0 Y 128 31 63
def @arg14 253 8192 0 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 0 Y 128 31 63
-def @arg17 253 20 0 Y 128 0 63
+def @arg17 253 20 0 Y 160 0 63
def @arg18 253 20 0 Y 128 0 63
def @arg19 253 20 0 Y 128 0 63
def @arg20 253 8192 0 Y 0 31 8
diff --git a/mysql-test/r/ps_5merge.result b/mysql-test/r/ps_5merge.result
index 18982db937a..34ade911e78 100644
--- a/mysql-test/r/ps_5merge.result
+++ b/mysql-test/r/ps_5merge.result
@@ -826,20 +826,20 @@ a b
2 two
3 three
4 four
-prepare stmt1 from ' SELECT a as ccc from t1 where a+1=
- (SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) ';
+prepare stmt1 from ' SELECT a as ccc from t1 outr where a+1=
+ (SELECT 1+outr.a from t1 where outr.a+1=a+1 and a=1) ';
execute stmt1 ;
ccc
1
deallocate prepare stmt1 ;
-prepare stmt1 from ' SELECT a as ccc from t1 where a+1=
- (SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) ';
+prepare stmt1 from ' SELECT a as ccc from t1 outr where a+1=
+ (SELECT 1+outr.a from t1 where outr.a+1=a+1 and a=1) ';
execute stmt1 ;
ccc
1
deallocate prepare stmt1 ;
-prepare stmt1 from ' SELECT a as ccc from t1 where a+1=
- (SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) ';
+prepare stmt1 from ' SELECT a as ccc from t1 outr where a+1=
+ (SELECT 1+outr.a from t1 where outr.a+1=a+1 and a=1) ';
execute stmt1 ;
ccc
1
@@ -1853,7 +1853,7 @@ def @arg13 253 8192 10 Y 128 31 63
def @arg14 253 8192 19 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 8 Y 128 31 63
-def @arg17 253 20 4 Y 128 0 63
+def @arg17 253 20 4 Y 160 0 63
def @arg18 253 20 1 Y 128 0 63
def @arg19 253 20 1 Y 128 0 63
def @arg20 253 8192 1 Y 0 31 8
@@ -1900,7 +1900,7 @@ def @arg13 253 8192 0 Y 128 31 63
def @arg14 253 8192 0 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 0 Y 128 31 63
-def @arg17 253 20 0 Y 128 0 63
+def @arg17 253 20 0 Y 160 0 63
def @arg18 253 20 0 Y 128 0 63
def @arg19 253 20 0 Y 128 0 63
def @arg20 253 8192 0 Y 0 31 8
@@ -1950,7 +1950,7 @@ def @arg13 253 8192 10 Y 128 31 63
def @arg14 253 8192 19 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 8 Y 128 31 63
-def @arg17 253 20 4 Y 128 0 63
+def @arg17 253 20 4 Y 160 0 63
def @arg18 253 20 1 Y 128 0 63
def @arg19 253 20 1 Y 128 0 63
def @arg20 253 8192 1 Y 0 31 8
@@ -1990,7 +1990,7 @@ def @arg13 253 8192 0 Y 128 31 63
def @arg14 253 8192 0 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 0 Y 128 31 63
-def @arg17 253 20 0 Y 128 0 63
+def @arg17 253 20 0 Y 160 0 63
def @arg18 253 20 0 Y 128 0 63
def @arg19 253 20 0 Y 128 0 63
def @arg20 253 8192 0 Y 0 31 8
@@ -2038,7 +2038,7 @@ def @arg13 253 8192 10 Y 128 31 63
def @arg14 253 8192 19 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 8 Y 128 31 63
-def @arg17 253 20 4 Y 128 0 63
+def @arg17 253 20 4 Y 160 0 63
def @arg18 253 20 1 Y 128 0 63
def @arg19 253 20 1 Y 128 0 63
def @arg20 253 8192 1 Y 0 31 8
@@ -2082,7 +2082,7 @@ def @arg13 253 8192 0 Y 128 31 63
def @arg14 253 8192 0 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 0 Y 128 31 63
-def @arg17 253 20 0 Y 128 0 63
+def @arg17 253 20 0 Y 160 0 63
def @arg18 253 20 0 Y 128 0 63
def @arg19 253 20 0 Y 128 0 63
def @arg20 253 8192 0 Y 0 31 8
@@ -2128,7 +2128,7 @@ def @arg13 253 8192 10 Y 128 31 63
def @arg14 253 8192 19 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 8 Y 128 31 63
-def @arg17 253 20 4 Y 128 0 63
+def @arg17 253 20 4 Y 160 0 63
def @arg18 253 20 1 Y 128 0 63
def @arg19 253 20 1 Y 128 0 63
def @arg20 253 8192 1 Y 0 31 8
@@ -2166,7 +2166,7 @@ def @arg13 253 8192 0 Y 128 31 63
def @arg14 253 8192 0 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 0 Y 128 31 63
-def @arg17 253 20 0 Y 128 0 63
+def @arg17 253 20 0 Y 160 0 63
def @arg18 253 20 0 Y 128 0 63
def @arg19 253 20 0 Y 128 0 63
def @arg20 253 8192 0 Y 0 31 8
@@ -3848,20 +3848,20 @@ a b
2 two
3 three
4 four
-prepare stmt1 from ' SELECT a as ccc from t1 where a+1=
- (SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) ';
+prepare stmt1 from ' SELECT a as ccc from t1 outr where a+1=
+ (SELECT 1+outr.a from t1 where outr.a+1=a+1 and a=1) ';
execute stmt1 ;
ccc
1
deallocate prepare stmt1 ;
-prepare stmt1 from ' SELECT a as ccc from t1 where a+1=
- (SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) ';
+prepare stmt1 from ' SELECT a as ccc from t1 outr where a+1=
+ (SELECT 1+outr.a from t1 where outr.a+1=a+1 and a=1) ';
execute stmt1 ;
ccc
1
deallocate prepare stmt1 ;
-prepare stmt1 from ' SELECT a as ccc from t1 where a+1=
- (SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) ';
+prepare stmt1 from ' SELECT a as ccc from t1 outr where a+1=
+ (SELECT 1+outr.a from t1 where outr.a+1=a+1 and a=1) ';
execute stmt1 ;
ccc
1
@@ -4875,7 +4875,7 @@ def @arg13 253 8192 10 Y 128 31 63
def @arg14 253 8192 19 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 8 Y 128 31 63
-def @arg17 253 20 4 Y 128 0 63
+def @arg17 253 20 4 Y 160 0 63
def @arg18 253 20 1 Y 128 0 63
def @arg19 253 20 1 Y 128 0 63
def @arg20 253 8192 1 Y 0 31 8
@@ -4922,7 +4922,7 @@ def @arg13 253 8192 0 Y 128 31 63
def @arg14 253 8192 0 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 0 Y 128 31 63
-def @arg17 253 20 0 Y 128 0 63
+def @arg17 253 20 0 Y 160 0 63
def @arg18 253 20 0 Y 128 0 63
def @arg19 253 20 0 Y 128 0 63
def @arg20 253 8192 0 Y 0 31 8
@@ -4972,7 +4972,7 @@ def @arg13 253 8192 10 Y 128 31 63
def @arg14 253 8192 19 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 8 Y 128 31 63
-def @arg17 253 20 4 Y 128 0 63
+def @arg17 253 20 4 Y 160 0 63
def @arg18 253 20 1 Y 128 0 63
def @arg19 253 20 1 Y 128 0 63
def @arg20 253 8192 1 Y 0 31 8
@@ -5012,7 +5012,7 @@ def @arg13 253 8192 0 Y 128 31 63
def @arg14 253 8192 0 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 0 Y 128 31 63
-def @arg17 253 20 0 Y 128 0 63
+def @arg17 253 20 0 Y 160 0 63
def @arg18 253 20 0 Y 128 0 63
def @arg19 253 20 0 Y 128 0 63
def @arg20 253 8192 0 Y 0 31 8
@@ -5060,7 +5060,7 @@ def @arg13 253 8192 10 Y 128 31 63
def @arg14 253 8192 19 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 8 Y 128 31 63
-def @arg17 253 20 4 Y 128 0 63
+def @arg17 253 20 4 Y 160 0 63
def @arg18 253 20 1 Y 128 0 63
def @arg19 253 20 1 Y 128 0 63
def @arg20 253 8192 1 Y 0 31 8
@@ -5104,7 +5104,7 @@ def @arg13 253 8192 0 Y 128 31 63
def @arg14 253 8192 0 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 0 Y 128 31 63
-def @arg17 253 20 0 Y 128 0 63
+def @arg17 253 20 0 Y 160 0 63
def @arg18 253 20 0 Y 128 0 63
def @arg19 253 20 0 Y 128 0 63
def @arg20 253 8192 0 Y 0 31 8
@@ -5150,7 +5150,7 @@ def @arg13 253 8192 10 Y 128 31 63
def @arg14 253 8192 19 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 8 Y 128 31 63
-def @arg17 253 20 4 Y 128 0 63
+def @arg17 253 20 4 Y 160 0 63
def @arg18 253 20 1 Y 128 0 63
def @arg19 253 20 1 Y 128 0 63
def @arg20 253 8192 1 Y 0 31 8
@@ -5188,7 +5188,7 @@ def @arg13 253 8192 0 Y 128 31 63
def @arg14 253 8192 0 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 0 Y 128 31 63
-def @arg17 253 20 0 Y 128 0 63
+def @arg17 253 20 0 Y 160 0 63
def @arg18 253 20 0 Y 128 0 63
def @arg19 253 20 0 Y 128 0 63
def @arg20 253 8192 0 Y 0 31 8
diff --git a/mysql-test/r/ps_6bdb.result b/mysql-test/r/ps_6bdb.result
index 0e4086bc202..a4205ac134e 100644
--- a/mysql-test/r/ps_6bdb.result
+++ b/mysql-test/r/ps_6bdb.result
@@ -783,20 +783,20 @@ a b
2 two
3 three
4 four
-prepare stmt1 from ' SELECT a as ccc from t1 where a+1=
- (SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) ';
+prepare stmt1 from ' SELECT a as ccc from t1 outr where a+1=
+ (SELECT 1+outr.a from t1 where outr.a+1=a+1 and a=1) ';
execute stmt1 ;
ccc
1
deallocate prepare stmt1 ;
-prepare stmt1 from ' SELECT a as ccc from t1 where a+1=
- (SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) ';
+prepare stmt1 from ' SELECT a as ccc from t1 outr where a+1=
+ (SELECT 1+outr.a from t1 where outr.a+1=a+1 and a=1) ';
execute stmt1 ;
ccc
1
deallocate prepare stmt1 ;
-prepare stmt1 from ' SELECT a as ccc from t1 where a+1=
- (SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) ';
+prepare stmt1 from ' SELECT a as ccc from t1 outr where a+1=
+ (SELECT 1+outr.a from t1 where outr.a+1=a+1 and a=1) ';
execute stmt1 ;
ccc
1
@@ -1916,7 +1916,7 @@ def @arg13 253 8192 10 Y 128 31 63
def @arg14 253 8192 19 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 8 Y 128 31 63
-def @arg17 253 20 4 Y 128 0 63
+def @arg17 253 20 4 Y 160 0 63
def @arg18 253 20 1 Y 128 0 63
def @arg19 253 20 1 Y 128 0 63
def @arg20 253 8192 1 Y 0 31 8
@@ -1963,7 +1963,7 @@ def @arg13 253 8192 0 Y 128 31 63
def @arg14 253 8192 0 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 0 Y 128 31 63
-def @arg17 253 20 0 Y 128 0 63
+def @arg17 253 20 0 Y 160 0 63
def @arg18 253 20 0 Y 128 0 63
def @arg19 253 20 0 Y 128 0 63
def @arg20 253 8192 0 Y 0 31 8
@@ -2013,7 +2013,7 @@ def @arg13 253 8192 10 Y 128 31 63
def @arg14 253 8192 19 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 8 Y 128 31 63
-def @arg17 253 20 4 Y 128 0 63
+def @arg17 253 20 4 Y 160 0 63
def @arg18 253 20 1 Y 128 0 63
def @arg19 253 20 1 Y 128 0 63
def @arg20 253 8192 1 Y 0 31 8
@@ -2053,7 +2053,7 @@ def @arg13 253 8192 0 Y 128 31 63
def @arg14 253 8192 0 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 0 Y 128 31 63
-def @arg17 253 20 0 Y 128 0 63
+def @arg17 253 20 0 Y 160 0 63
def @arg18 253 20 0 Y 128 0 63
def @arg19 253 20 0 Y 128 0 63
def @arg20 253 8192 0 Y 0 31 8
@@ -2101,7 +2101,7 @@ def @arg13 253 8192 10 Y 128 31 63
def @arg14 253 8192 19 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 8 Y 128 31 63
-def @arg17 253 20 4 Y 128 0 63
+def @arg17 253 20 4 Y 160 0 63
def @arg18 253 20 1 Y 128 0 63
def @arg19 253 20 1 Y 128 0 63
def @arg20 253 8192 1 Y 0 31 8
@@ -2145,7 +2145,7 @@ def @arg13 253 8192 0 Y 128 31 63
def @arg14 253 8192 0 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 0 Y 128 31 63
-def @arg17 253 20 0 Y 128 0 63
+def @arg17 253 20 0 Y 160 0 63
def @arg18 253 20 0 Y 128 0 63
def @arg19 253 20 0 Y 128 0 63
def @arg20 253 8192 0 Y 0 31 8
@@ -2191,7 +2191,7 @@ def @arg13 253 8192 10 Y 128 31 63
def @arg14 253 8192 19 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 8 Y 128 31 63
-def @arg17 253 20 4 Y 128 0 63
+def @arg17 253 20 4 Y 160 0 63
def @arg18 253 20 1 Y 128 0 63
def @arg19 253 20 1 Y 128 0 63
def @arg20 253 8192 1 Y 0 31 8
@@ -2229,7 +2229,7 @@ def @arg13 253 8192 0 Y 128 31 63
def @arg14 253 8192 0 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 0 Y 128 31 63
-def @arg17 253 20 0 Y 128 0 63
+def @arg17 253 20 0 Y 160 0 63
def @arg18 253 20 0 Y 128 0 63
def @arg19 253 20 0 Y 128 0 63
def @arg20 253 8192 0 Y 0 31 8
diff --git a/mysql-test/r/ps_7ndb.result b/mysql-test/r/ps_7ndb.result
index 7a20fb3146d..8eec789d061 100644
--- a/mysql-test/r/ps_7ndb.result
+++ b/mysql-test/r/ps_7ndb.result
@@ -783,20 +783,20 @@ a b
2 two
3 three
4 four
-prepare stmt1 from ' SELECT a as ccc from t1 where a+1=
- (SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) ';
+prepare stmt1 from ' SELECT a as ccc from t1 outr where a+1=
+ (SELECT 1+outr.a from t1 where outr.a+1=a+1 and a=1) ';
execute stmt1 ;
ccc
1
deallocate prepare stmt1 ;
-prepare stmt1 from ' SELECT a as ccc from t1 where a+1=
- (SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) ';
+prepare stmt1 from ' SELECT a as ccc from t1 outr where a+1=
+ (SELECT 1+outr.a from t1 where outr.a+1=a+1 and a=1) ';
execute stmt1 ;
ccc
1
deallocate prepare stmt1 ;
-prepare stmt1 from ' SELECT a as ccc from t1 where a+1=
- (SELECT 1+ccc from t1 where ccc+1=a+1 and a=1) ';
+prepare stmt1 from ' SELECT a as ccc from t1 outr where a+1=
+ (SELECT 1+outr.a from t1 where outr.a+1=a+1 and a=1) ';
execute stmt1 ;
ccc
1
@@ -1916,7 +1916,7 @@ def @arg13 253 8192 10 Y 128 31 63
def @arg14 253 8192 19 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 8 Y 128 31 63
-def @arg17 253 20 4 Y 128 0 63
+def @arg17 253 20 4 Y 160 0 63
def @arg18 253 20 1 Y 128 0 63
def @arg19 253 20 1 Y 128 0 63
def @arg20 253 8192 1 Y 0 31 8
@@ -1963,7 +1963,7 @@ def @arg13 253 8192 0 Y 128 31 63
def @arg14 253 8192 0 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 0 Y 128 31 63
-def @arg17 253 20 0 Y 128 0 63
+def @arg17 253 20 0 Y 160 0 63
def @arg18 253 20 0 Y 128 0 63
def @arg19 253 20 0 Y 128 0 63
def @arg20 253 8192 0 Y 0 31 8
@@ -2013,7 +2013,7 @@ def @arg13 253 8192 10 Y 128 31 63
def @arg14 253 8192 19 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 8 Y 128 31 63
-def @arg17 253 20 4 Y 128 0 63
+def @arg17 253 20 4 Y 160 0 63
def @arg18 253 20 1 Y 128 0 63
def @arg19 253 20 1 Y 128 0 63
def @arg20 253 8192 1 Y 0 31 8
@@ -2053,7 +2053,7 @@ def @arg13 253 8192 0 Y 128 31 63
def @arg14 253 8192 0 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 0 Y 128 31 63
-def @arg17 253 20 0 Y 128 0 63
+def @arg17 253 20 0 Y 160 0 63
def @arg18 253 20 0 Y 128 0 63
def @arg19 253 20 0 Y 128 0 63
def @arg20 253 8192 0 Y 0 31 8
@@ -2101,7 +2101,7 @@ def @arg13 253 8192 10 Y 128 31 63
def @arg14 253 8192 19 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 8 Y 128 31 63
-def @arg17 253 20 4 Y 128 0 63
+def @arg17 253 20 4 Y 160 0 63
def @arg18 253 20 1 Y 128 0 63
def @arg19 253 20 1 Y 128 0 63
def @arg20 253 8192 1 Y 0 31 8
@@ -2145,7 +2145,7 @@ def @arg13 253 8192 0 Y 128 31 63
def @arg14 253 8192 0 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 0 Y 128 31 63
-def @arg17 253 20 0 Y 128 0 63
+def @arg17 253 20 0 Y 160 0 63
def @arg18 253 20 0 Y 128 0 63
def @arg19 253 20 0 Y 128 0 63
def @arg20 253 8192 0 Y 0 31 8
@@ -2191,7 +2191,7 @@ def @arg13 253 8192 10 Y 128 31 63
def @arg14 253 8192 19 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 8 Y 128 31 63
-def @arg17 253 20 4 Y 128 0 63
+def @arg17 253 20 4 Y 160 0 63
def @arg18 253 20 1 Y 128 0 63
def @arg19 253 20 1 Y 128 0 63
def @arg20 253 8192 1 Y 0 31 8
@@ -2229,7 +2229,7 @@ def @arg13 253 8192 0 Y 128 31 63
def @arg14 253 8192 0 Y 128 31 63
def @arg15 253 8192 19 Y 128 31 63
def @arg16 253 8192 0 Y 128 31 63
-def @arg17 253 20 0 Y 128 0 63
+def @arg17 253 20 0 Y 160 0 63
def @arg18 253 20 0 Y 128 0 63
def @arg19 253 20 0 Y 128 0 63
def @arg20 253 8192 0 Y 0 31 8
diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result
index 58f8d077ac5..e0084b53320 100644
--- a/mysql-test/r/range.result
+++ b/mysql-test/r/range.result
@@ -1135,3 +1135,21 @@ item started price
A1 2005-11-01 08:00:00 1000.000
A1 2005-11-15 00:00:00 2000.000
DROP TABLE t1;
+
+BUG#32198 "Comparison of DATE with DATETIME still not using indexes correctly"
+
+CREATE TABLE t1 (
+id int(11) NOT NULL auto_increment,
+dateval date default NULL,
+PRIMARY KEY (id),
+KEY dateval (dateval)
+) AUTO_INCREMENT=173;
+INSERT INTO t1 VALUES
+(1,'2007-01-01'),(2,'2007-01-02'),(3,'2007-01-03'),(4,'2007-01-04'),
+(5,'2007-01-05'),(6,'2007-01-06'),(7,'2007-01-07'),(8,'2007-01-08'),
+(9,'2007-01-09'),(10,'2007-01-10'),(11,'2007-01-11');
+This must use range access:
+explain select * from t1 where dateval >= '2007-01-01 00:00:00' and dateval <= '2007-01-02 23:59:59';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range dateval dateval 4 NULL 2 Using where
+drop table t1;
diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result
index a1ba58a536c..3ca84bcf34b 100644
--- a/mysql-test/r/select.result
+++ b/mysql-test/r/select.result
@@ -4322,4 +4322,10 @@ c3
DROP TABLE t1;
DROP TABLE t2;
+CREATE TABLE t1 (c1 BIGINT NOT NULL);
+INSERT INTO t1 (c1) VALUES (1);
+SELECT * FROM t1 WHERE c1 > NULL + 1;
+c1
+DROP TABLE t1;
+
End of 5.0 tests
diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result
index 1c450269809..f6487ae3ddf 100644
--- a/mysql-test/r/subselect.result
+++ b/mysql-test/r/subselect.result
@@ -77,10 +77,9 @@ ERROR HY000: Incorrect usage of PROCEDURE and subquery
SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1));
ERROR HY000: Incorrect parameters to procedure 'ANALYSE'
SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL;
-a
+ERROR 42S22: Unknown column 'a' in 'field list'
SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NOT NULL;
-a
-1
+ERROR 42S22: Unknown column 'a' in 'field list'
SELECT (SELECT 1,2,3) = ROW(1,2,3);
(SELECT 1,2,3) = ROW(1,2,3)
1
@@ -1307,7 +1306,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 index NULL PRIMARY 4 NULL 4 Using where; Using index
2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 Using where
Warnings:
-Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,<exists>(<primary_index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on PRIMARY where (`test`.`t1`.`b` <> 30))))
+Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,<exists>(<primary_index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on PRIMARY where ((`test`.`t1`.`b` <> 30) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`)))))
select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
a
2
@@ -1315,8 +1314,8 @@ a
explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 index NULL PRIMARY 4 NULL 4 Using where; Using index
-2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 func 1 Using where
-2 DEPENDENT SUBQUERY t3 eq_ref PRIMARY PRIMARY 4 test.t1.b 1 Using where; Using index
+2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 func 1
+2 DEPENDENT SUBQUERY t3 eq_ref PRIMARY PRIMARY 4 test.t1.b 1 Using index
Warnings:
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,<exists>(select 1 AS `Not_used` from `test`.`t1` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t1`.`b`) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`))))
drop table t1, t2, t3;
@@ -1334,9 +1333,9 @@ a
explain extended select * from t2 where t2.a in (select a from t1);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 index NULL a 5 NULL 4 Using where; Using index
-2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 1001 Using index
+2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 1001 Using index; Using where
Warnings:
-Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on a)))
+Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on a where (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`))))
select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
a
2
@@ -1346,7 +1345,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 index NULL a 5 NULL 4 Using where; Using index
2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 1001 Using index; Using where
Warnings:
-Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on a where (`test`.`t1`.`b` <> 30))))
+Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on a where ((`test`.`t1`.`b` <> 30) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`)))))
select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
a
2
@@ -1373,7 +1372,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 index NULL a 5 NULL 4 Using where; Using index
2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 1001 Using index; Using where
Warnings:
-Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on a where (`test`.`t1`.`b` <> 30))))
+Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on a where ((`test`.`t1`.`b` <> 30) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`)))))
drop table t1, t2, t3;
create table t1 (a int, b int);
create table t2 (a int, b int);
@@ -1737,7 +1736,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 12 Using where
2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 Using index; Using where
Warnings:
-Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`text` AS `text` from `test`.`t1` where (not(<in_optimizer>(`test`.`t1`.`id`,<exists>(<primary_index_lookup>(<cache>(`test`.`t1`.`id`) in t1 on PRIMARY where (`test`.`t1`.`id` < 8))))))
+Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`text` AS `text` from `test`.`t1` where (not(<in_optimizer>(`test`.`t1`.`id`,<exists>(<primary_index_lookup>(<cache>(`test`.`t1`.`id`) in t1 on PRIMARY where ((`test`.`t1`.`id` < 8) and (<cache>(`test`.`t1`.`id`) = `test`.`t1`.`id`)))))))
explain extended select * from t1 as tt where not exists (select id from t1 where id < 8 and (id = tt.id or id is null) having id is not null);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY tt ALL NULL NULL NULL NULL 12 Using where
@@ -2304,24 +2303,27 @@ drop table t1,t2;
CREATE TABLE t1 ( a int, b int );
CREATE TABLE t2 ( c int, d int );
INSERT INTO t1 VALUES (1,2), (2,3), (3,4);
-SELECT a AS abc, b FROM t1 WHERE b = (SELECT MIN(b) FROM t1 WHERE a=abc);
+SELECT a AS abc, b FROM t1 outr WHERE b =
+(SELECT MIN(b) FROM t1 WHERE a=outr.a);
abc b
1 2
2 3
3 4
-INSERT INTO t2 SELECT a AS abc, b FROM t1 WHERE b = (SELECT MIN(b) FROM t1 WHERE a=abc);
+INSERT INTO t2 SELECT a AS abc, b FROM t1 outr WHERE b =
+(SELECT MIN(b) FROM t1 WHERE a=outr.a);
select * from t2;
c d
1 2
2 3
3 4
-CREATE TABLE t3 SELECT a AS abc, b FROM t1 WHERE b = (SELECT MIN(b) FROM t1 WHERE a=abc);
+CREATE TABLE t3 SELECT a AS abc, b FROM t1 outr WHERE b =
+(SELECT MIN(b) FROM t1 WHERE a=outr.a);
select * from t3;
abc b
1 2
2 3
3 4
-prepare stmt1 from "INSERT INTO t2 SELECT a AS abc, b FROM t1 WHERE b = (SELECT MIN(b) FROM t1 WHERE a=abc);";
+prepare stmt1 from "INSERT INTO t2 SELECT a AS abc, b FROM t1 outr WHERE b = (SELECT MIN(b) FROM t1 WHERE a=outr.a);";
execute stmt1;
deallocate prepare stmt1;
select * from t2;
@@ -2333,7 +2335,7 @@ c d
2 3
3 4
drop table t3;
-prepare stmt1 from "CREATE TABLE t3 SELECT a AS abc, b FROM t1 WHERE b = (SELECT MIN(b) FROM t1 WHERE a=abc);";
+prepare stmt1 from "CREATE TABLE t3 SELECT a AS abc, b FROM t1 outr WHERE b = (SELECT MIN(b) FROM t1 WHERE a=outr.a);";
execute stmt1;
select * from t3;
abc b
@@ -2515,7 +2517,9 @@ INSERT INTO t1 VALUES ('ASM','American Samoa','Oceania','Polynesia',199.00,0,680
INSERT INTO t1 VALUES ('ATF','French Southern territories','Antarctica','Antarctica',7780.00,0,0,NULL,0.00,NULL,'Terres australes françaises','Nonmetropolitan Territory of France','Jacques Chirac',NULL,'TF');
INSERT INTO t1 VALUES ('UMI','United States Minor Outlying Islands','Oceania','Micronesia/Caribbean',16.00,0,0,NULL,0.00,NULL,'United States Minor Outlying Islands','Dependent Territory of the US','George W. Bush',NULL,'UM');
/*!40000 ALTER TABLE t1 ENABLE KEYS */;
-SELECT DISTINCT Continent AS c FROM t1 WHERE Code <> SOME ( SELECT Code FROM t1 WHERE Continent = c AND Population < 200);
+SELECT DISTINCT Continent AS c FROM t1 outr WHERE
+Code <> SOME ( SELECT Code FROM t1 WHERE Continent = outr.Continent AND
+Population < 200);
c
Oceania
drop table t1;
@@ -3558,22 +3562,19 @@ SELECT sql_no_cache * FROM t1 WHERE NOT EXISTS
(SELECT i FROM t1) UNION
(SELECT i FROM t1)
);
-i
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION
+(SELECT i FROM t1)
+)' at line 3
SELECT * FROM t1
WHERE NOT EXISTS (((SELECT i FROM t1) UNION (SELECT i FROM t1)));
-i
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION (SELECT i FROM t1)))' at line 2
explain select ((select t11.i from t1 t11) union (select t12.i from t1 t12))
from t1;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'union (select t12.i from t1 t12))
from t1' at line 1
explain select * from t1 where not exists
((select t11.i from t1 t11) union (select t12.i from t1 t12));
-id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 system NULL NULL NULL NULL 0 const row not found
-2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
-3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table
-4 UNION t12 system NULL NULL NULL NULL 0 const row not found
-NULL UNION RESULT <union2,4> ALL NULL NULL NULL NULL NULL
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'union (select t12.i from t1 t12))' at line 2
DROP TABLE t1;
CREATE TABLE t1 (a VARCHAR(250), b INT auto_increment, PRIMARY KEY (b));
insert into t1 (a) values (FLOOR(rand() * 100));
@@ -3666,6 +3667,8 @@ CREATE TABLE t1 (a int, b int auto_increment, PRIMARY KEY (b));
CREATE TABLE t2 (x int auto_increment, y int, z int,
PRIMARY KEY (x), FOREIGN KEY (y) REFERENCES t1 (b));
SET SESSION sort_buffer_size = 32 * 1024;
+Warnings:
+Warning 1292 Truncated incorrect sort_buffer_size value: '32768'
SELECT SQL_NO_CACHE COUNT(*)
FROM (SELECT a, b, (SELECT x FROM t2 WHERE y=b ORDER BY z DESC LIMIT 1) c
FROM t1) t;
@@ -4101,6 +4104,8 @@ INSERT INTO `t1` VALUES ('asdf','2007-02-08 01:11:26');
INSERT INTO `t2` VALUES ('abcdefghijk');
INSERT INTO `t2` VALUES ('asdf');
SET session sort_buffer_size=8192;
+Warnings:
+Warning 1292 Truncated incorrect sort_buffer_size value: '8192'
SELECT (SELECT 1 FROM t1 WHERE t1.a=t2.a ORDER BY t1.b LIMIT 1) AS d1 FROM t2;
d1
1
@@ -4139,6 +4144,107 @@ SELECT (SELECT SUM(t1.a) FROM t2 WHERE a=1) FROM t1;
(SELECT SUM(t1.a) FROM t2 WHERE a=1)
3
DROP TABLE t1,t2;
+create table t1(a int,b int,key(a),key(b));
+insert into t1(a,b) values (1,2),(2,1),(2,3),(3,4),(5,4),(5,5),
+(6,7),(7,4),(5,3);
+select sum(a),a from t1 where a> (
+select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+select sum(a) from t1 where a> ( select sum(a) from t1
+)group by b limit 1)group by b limit 1
+)group by b limit 1)group by b limit 1)group by b limit 1
+)group by b limit 1)group by b limit 1)group by b limit 1
+)group by b limit 1)group by b limit 1)group by b limit 1)
+group by a;
+sum(a) a
+select sum(a),a from t1 where a> (
+select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+select sum(a) from t1
+)group by b limit 1)group by b limit 1)group by b limit 1
+)group by b limit 1)group by b limit 1)group by b limit 1
+)group by b limit 1)group by b limit 1)group by b limit 1
+)group by b limit 1)group by b limit 1)group by b limit 1
+)group by b limit 1)group by b limit 1)group by b limit 1
+)group by b limit 1)group by b limit 1)group by b limit 1
+)group by b limit 1)group by b limit 1)group by b limit 1
+)group by b limit 1)group by b limit 1)group by b limit 1
+)group by b limit 1)group by b limit 1)group by b limit 1
+)group by b limit 1)group by b limit 1)group by b limit 1)
+group by a;
+ERROR HY000: Thread stack overrun detected
+explain select sum(a),a from t1 where a> (
+select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+select sum(a) from t1 where a> ( select sum(a) from t1
+)group by b limit 1)group by b limit 1
+)group by b limit 1)group by b limit 1)group by b limit 1
+)group by b limit 1)group by b limit 1)group by b limit 1
+)group by b limit 1)group by b limit 1)group by b limit 1)
+group by a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index a a 5 NULL 9 Using where; Using index
+2 SUBQUERY t1 range a a 5 NULL 9 Using where; Using temporary; Using filesort
+3 SUBQUERY t1 range a a 5 NULL 9 Using where; Using temporary; Using filesort
+4 SUBQUERY t1 range a a 5 NULL 9 Using where; Using temporary; Using filesort
+5 SUBQUERY t1 range a a 5 NULL 9 Using where; Using temporary; Using filesort
+6 SUBQUERY t1 range a a 5 NULL 9 Using where; Using temporary; Using filesort
+7 SUBQUERY t1 range a a 5 NULL 9 Using where; Using temporary; Using filesort
+8 SUBQUERY t1 range a a 5 NULL 9 Using where; Using temporary; Using filesort
+9 SUBQUERY t1 range a a 5 NULL 9 Using where; Using temporary; Using filesort
+10 SUBQUERY t1 range a a 5 NULL 9 Using where; Using temporary; Using filesort
+11 SUBQUERY t1 range a a 5 NULL 9 Using where; Using temporary; Using filesort
+12 SUBQUERY t1 range a a 5 NULL 1 Using where; Using temporary; Using filesort
+13 SUBQUERY t1 index NULL a 5 NULL 9 Using index
+explain select sum(a),a from t1 where a> (
+select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+select sum(a) from t1
+)group by b limit 1)group by b limit 1)group by b limit 1
+)group by b limit 1)group by b limit 1)group by b limit 1
+)group by b limit 1)group by b limit 1)group by b limit 1
+)group by b limit 1)group by b limit 1)group by b limit 1
+)group by b limit 1)group by b limit 1)group by b limit 1
+)group by b limit 1)group by b limit 1)group by b limit 1
+)group by b limit 1)group by b limit 1)group by b limit 1
+)group by b limit 1)group by b limit 1)group by b limit 1
+)group by b limit 1)group by b limit 1)group by b limit 1
+)group by b limit 1)group by b limit 1)group by b limit 1)
+group by a;
+ERROR HY000: Thread stack overrun detected
+drop table t1;
CREATE TABLE t1 (a1 INT, a2 INT);
CREATE TABLE t2 (b1 INT, b2 INT);
INSERT INTO t1 VALUES (100, 200);
@@ -4199,4 +4305,82 @@ LEFT(t1.a1,1)
SELECT a2 FROM t2 WHERE t2.a2 IN (SELECT t1.a1 FROM t1,t3 WHERE t1.b1=t3.a3);
a2
DROP TABLE t1, t2, t3;
+CREATE TABLE t1 (a CHAR(1), b VARCHAR(10));
+INSERT INTO t1 VALUES ('a', 'aa');
+INSERT INTO t1 VALUES ('a', 'aaa');
+SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1);
+a b
+CREATE INDEX I1 ON t1 (a);
+CREATE INDEX I2 ON t1 (b);
+EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
+2 DEPENDENT SUBQUERY t1 index_subquery I1 I1 2 func 2 Using index; Using where
+SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1);
+a b
+CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10));
+INSERT INTO t2 SELECT * FROM t1;
+CREATE INDEX I1 ON t2 (a);
+CREATE INDEX I2 ON t2 (b);
+EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where
+2 DEPENDENT SUBQUERY t2 index_subquery I1 I1 4 func 2 Using index; Using where
+SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2);
+a b
+EXPLAIN
+SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
+2 DEPENDENT SUBQUERY t1 index_subquery I1 I1 2 func 2 Using index; Using where
+SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500);
+a b
+DROP TABLE t1,t2;
+CREATE TABLE t1(a INT, b INT);
+INSERT INTO t1 VALUES (1,1), (1,2), (2,3), (2,4);
+EXPLAIN
+SELECT a AS out_a, MIN(b) FROM t1
+WHERE b > (SELECT MIN(b) FROM t1 WHERE a = out_a)
+GROUP BY a;
+ERROR 42S22: Unknown column 'out_a' in 'where clause'
+SELECT a AS out_a, MIN(b) FROM t1
+WHERE b > (SELECT MIN(b) FROM t1 WHERE a = out_a)
+GROUP BY a;
+ERROR 42S22: Unknown column 'out_a' in 'where clause'
+EXPLAIN
+SELECT a AS out_a, MIN(b) FROM t1 t1_outer
+WHERE b > (SELECT MIN(b) FROM t1 WHERE a = t1_outer.a)
+GROUP BY a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1_outer ALL NULL NULL NULL NULL 4 Using where; Using temporary; Using filesort
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 4 Using where
+SELECT a AS out_a, MIN(b) FROM t1 t1_outer
+WHERE b > (SELECT MIN(b) FROM t1 WHERE a = t1_outer.a)
+GROUP BY a;
+out_a MIN(b)
+1 2
+2 4
+DROP TABLE t1;
+CREATE TABLE t1 (a INT);
+CREATE TABLE t2 (a INT);
+INSERT INTO t1 VALUES (1),(2);
+INSERT INTO t2 VALUES (1),(2);
+SELECT 2 FROM t1 WHERE EXISTS ((SELECT 1 FROM t2 WHERE t1.a=t2.a));
+2
+2
+2
+EXPLAIN EXTENDED
+SELECT 2 FROM t1 WHERE EXISTS ((SELECT 1 FROM t2 WHERE t1.a=t2.a));
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
+Warnings:
+Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1
+Note 1003 select 2 AS `2` from `test`.`t1` where exists(select 1 AS `1` from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`))
+EXPLAIN EXTENDED
+SELECT 2 FROM t1 WHERE EXISTS ((SELECT 1 FROM t2 WHERE t1.a=t2.a) UNION
+(SELECT 1 FROM t2 WHERE t1.a = t2.a));
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION
+(SELECT 1 FROM t2 WHERE t1.a = t2.a))' at line 2
+DROP TABLE t1,t2;
End of 5.0 tests.
diff --git a/mysql-test/r/subselect3.result b/mysql-test/r/subselect3.result
index 098dacc8189..bdf00e4c307 100644
--- a/mysql-test/r/subselect3.result
+++ b/mysql-test/r/subselect3.result
@@ -757,6 +757,6 @@ a
EXPLAIN SELECT a FROM t1 WHERE a NOT IN (SELECT a FROM t2);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where
-2 DEPENDENT SUBQUERY t2 unique_subquery PRIMARY PRIMARY 4 func 1 Using index
+2 DEPENDENT SUBQUERY t2 unique_subquery PRIMARY PRIMARY 4 func 1 Using index; Using where
DROP TABLE t1;
End of 5.0 tests
diff --git a/mysql-test/r/type_bit.result b/mysql-test/r/type_bit.result
index 4c1b80c2fd5..4c4fcb9a9ae 100644
--- a/mysql-test/r/type_bit.result
+++ b/mysql-test/r/type_bit.result
@@ -269,6 +269,8 @@ a+0 b+0
56 379
68 454
set @@max_length_for_sort_data=0;
+Warnings:
+Warning 1292 Truncated incorrect max_length_for_sort_data value: '0'
select a+0, b+0 from t1 where a > 40 and a < 70 order by 2;
a+0 b+0
57 135
@@ -672,4 +674,14 @@ COUNT(DISTINCT b,c)
2
2
DROP TABLE t2;
+CREATE TABLE t1(a BIT(13), KEY(a));
+INSERT INTO t1(a) VALUES
+(65535),(65525),(65535),(65535),(65535),(65535),(65535),(65535),(65535),(65535);
+EXPLAIN SELECT 1 FROM t1 GROUP BY a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL a 3 NULL 6 Using index for group-by
+SELECT 1 FROM t1 GROUP BY a;
+1
+1
+DROP TABLE t1;
End of 5.0 tests
diff --git a/mysql-test/r/type_bit_innodb.result b/mysql-test/r/type_bit_innodb.result
index c4506231f27..d0cf15e59a5 100644
--- a/mysql-test/r/type_bit_innodb.result
+++ b/mysql-test/r/type_bit_innodb.result
@@ -269,6 +269,8 @@ a+0 b+0
56 379
68 454
set @@max_length_for_sort_data=0;
+Warnings:
+Warning 1292 Truncated incorrect max_length_for_sort_data value: '0'
select a+0, b+0 from t1 where a > 40 and a < 70 order by 2;
a+0 b+0
57 135
diff --git a/mysql-test/r/type_blob.result b/mysql-test/r/type_blob.result
index c72ee005428..80d233ee16a 100644
--- a/mysql-test/r/type_blob.result
+++ b/mysql-test/r/type_blob.result
@@ -807,4 +807,18 @@ set @@sql_mode='TRADITIONAL';
create table t1 (a text default '');
ERROR 42000: BLOB/TEXT column 'a' can't have a default value
set @@sql_mode='';
+CREATE TABLE t (c TEXT CHARSET ASCII);
+INSERT INTO t (c) VALUES (REPEAT('1',65537));
+Warnings:
+Warning 1265 Data truncated for column 'c' at row 1
+INSERT INTO t (c) VALUES (REPEAT('2',65536));
+Warnings:
+Warning 1265 Data truncated for column 'c' at row 1
+INSERT INTO t (c) VALUES (REPEAT('3',65535));
+SELECT LENGTH(c), CHAR_LENGTH(c) FROM t;
+LENGTH(c) CHAR_LENGTH(c)
+65535 65535
+65535 65535
+65535 65535
+DROP TABLE t;
End of 5.0 tests
diff --git a/mysql-test/r/type_date.result b/mysql-test/r/type_date.result
index bd2a43569dd..3cf1a166e7f 100644
--- a/mysql-test/r/type_date.result
+++ b/mysql-test/r/type_date.result
@@ -202,7 +202,6 @@ a
Warnings:
Warning 1292 Incorrect date value: '0000-00-00' for column 'a' at row 1
Warning 1292 Incorrect date value: '0000-00-00' for column 'a' at row 1
-Warning 1292 Incorrect date value: '0000-00-00' for column 'a' at row 1
SELECT * FROM t2 WHERE a = '0000-00-00';
a
0000-00-00
@@ -214,4 +213,42 @@ INSERT INTO t1 VALUES ('0000-00-00');
ERROR 22007: Incorrect date value: '0000-00-00' for column 'a' at row 1
SET SQL_MODE=DEFAULT;
DROP TABLE t1,t2;
+CREATE TABLE t1 (a DATE);
+CREATE TABLE t2 (a DATE);
+CREATE INDEX i ON t1 (a);
+INSERT INTO t1 VALUES ('1000-00-00'),('1000-00-00');
+INSERT INTO t2 VALUES ('1000-00-00'),('1000-00-00');
+SELECT * FROM t1 WHERE a = '1000-00-00';
+a
+1000-00-00
+1000-00-00
+SELECT * FROM t2 WHERE a = '1000-00-00';
+a
+1000-00-00
+1000-00-00
+SET SQL_MODE=TRADITIONAL;
+EXPLAIN SELECT * FROM t1 WHERE a = '1000-00-00';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref i i 4 const 1 Using where; Using index
+Warnings:
+Warning 1292 Incorrect date value: '1000-00-00' for column 'a' at row 1
+Warning 1292 Incorrect date value: '1000-00-00' for column 'a' at row 1
+SELECT * FROM t1 WHERE a = '1000-00-00';
+a
+1000-00-00
+1000-00-00
+Warnings:
+Warning 1292 Incorrect date value: '1000-00-00' for column 'a' at row 1
+Warning 1292 Incorrect date value: '1000-00-00' for column 'a' at row 1
+SELECT * FROM t2 WHERE a = '1000-00-00';
+a
+1000-00-00
+1000-00-00
+Warnings:
+Warning 1292 Incorrect date value: '1000-00-00' for column 'a' at row 1
+Warning 1292 Incorrect date value: '1000-00-00' for column 'a' at row 1
+INSERT INTO t1 VALUES ('1000-00-00');
+ERROR 22007: Incorrect date value: '1000-00-00' for column 'a' at row 1
+SET SQL_MODE=DEFAULT;
+DROP TABLE t1,t2;
End of 5.0 tests
diff --git a/mysql-test/r/type_datetime.result b/mysql-test/r/type_datetime.result
index 73edfb75ff6..3814e2f8348 100644
--- a/mysql-test/r/type_datetime.result
+++ b/mysql-test/r/type_datetime.result
@@ -505,4 +505,59 @@ select sum(a) from t1 group by convert(a, datetime);
sum(a)
NULL
drop table t1;
+create table t1 (id int(10) not null, cur_date datetime not null);
+create table t2 (id int(10) not null, cur_date date not null);
+insert into t1 (id, cur_date) values (1, '2007-04-25 18:30:22');
+insert into t2 (id, cur_date) values (1, '2007-04-25');
+explain extended
+select * from t1
+where id in (select id from t1 as x1 where (t1.cur_date is null));
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+Warnings:
+Note 1276 Field or reference 'test.t1.cur_date' of SELECT #2 was resolved in SELECT #1
+Note 1003 select '1' AS `id`,'2007-04-25 18:30:22' AS `cur_date` from `test`.`t1` where <in_optimizer>('1',<exists>(select 1 AS `Not_used` from `test`.`t1` `x1` where 0))
+select * from t1
+where id in (select id from t1 as x1 where (t1.cur_date is null));
+id cur_date
+explain extended
+select * from t2
+where id in (select id from t2 as x1 where (t2.cur_date is null));
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+Warnings:
+Note 1276 Field or reference 'test.t2.cur_date' of SELECT #2 was resolved in SELECT #1
+Note 1003 select '1' AS `id`,'2007-04-25' AS `cur_date` from `test`.`t2` where <in_optimizer>('1',<exists>(select 1 AS `Not_used` from `test`.`t2` `x1` where 0))
+select * from t2
+where id in (select id from t2 as x1 where (t2.cur_date is null));
+id cur_date
+insert into t1 (id, cur_date) values (2, '2007-04-26 18:30:22');
+insert into t2 (id, cur_date) values (2, '2007-04-26');
+explain extended
+select * from t1
+where id in (select id from t1 as x1 where (t1.cur_date is null));
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
+2 DEPENDENT SUBQUERY x1 ALL NULL NULL NULL NULL 2 Using where
+Warnings:
+Note 1276 Field or reference 'test.t1.cur_date' of SELECT #2 was resolved in SELECT #1
+Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`cur_date` AS `cur_date` from `test`.`t1` where <in_optimizer>(`test`.`t1`.`id`,<exists>(select 1 AS `Not_used` from `test`.`t1` `x1` where ((`test`.`t1`.`cur_date` = 0) and (<cache>(`test`.`t1`.`id`) = `test`.`x1`.`id`))))
+select * from t1
+where id in (select id from t1 as x1 where (t1.cur_date is null));
+id cur_date
+explain extended
+select * from t2
+where id in (select id from t2 as x1 where (t2.cur_date is null));
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where
+2 DEPENDENT SUBQUERY x1 ALL NULL NULL NULL NULL 2 Using where
+Warnings:
+Note 1276 Field or reference 'test.t2.cur_date' of SELECT #2 was resolved in SELECT #1
+Note 1003 select `test`.`t2`.`id` AS `id`,`test`.`t2`.`cur_date` AS `cur_date` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`id`,<exists>(select 1 AS `Not_used` from `test`.`t2` `x1` where ((`test`.`t2`.`cur_date` = 0) and (<cache>(`test`.`t2`.`id`) = `test`.`x1`.`id`))))
+select * from t2
+where id in (select id from t2 as x1 where (t2.cur_date is null));
+id cur_date
+drop table t1,t2;
End of 5.0 tests
diff --git a/mysql-test/r/udf.result b/mysql-test/r/udf.result
index e6797796ea0..a79be1c3189 100644
--- a/mysql-test/r/udf.result
+++ b/mysql-test/r/udf.result
@@ -327,4 +327,31 @@ DROP FUNCTION check_const_len;
DROP PROCEDURE check_const_len_sp;
DROP TRIGGER check_const_len_trigger;
DROP TABLE const_len_bug;
+CREATE FUNCTION sequence RETURNS INTEGER SONAME "UDF_EXAMPLE_LIB";
+CREATE TABLE t1 (a INT);
+CREATE TABLE t2 (a INT PRIMARY KEY);
+INSERT INTO t1 VALUES (4),(3),(2),(1);
+INSERT INTO t2 SELECT * FROM t1;
+SELECT sequence() AS seq, a FROM t1 ORDER BY seq ASC;
+seq a
+1 4
+2 3
+3 2
+4 1
+SELECT sequence() AS seq, a FROM t1 ORDER BY seq DESC;
+seq a
+4 1
+3 2
+2 3
+1 4
+SELECT * FROM t1 WHERE a = sequence();
+a
+SELECT * FROM t2 WHERE a = sequence();
+a
+1
+2
+3
+4
+DROP FUNCTION sequence;
+DROP TABLE t1,t2;
End of 5.0 tests.
diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result
index 47cd96b90b7..9c360ef4ab3 100644
--- a/mysql-test/r/variables.result
+++ b/mysql-test/r/variables.result
@@ -214,6 +214,8 @@ net_read_timeout 600
net_retry_count 10
net_write_timeout 500
set net_buffer_length=1;
+Warnings:
+Warning 1292 Truncated incorrect net_buffer_length value: '1'
show variables like 'net_buffer_length';
Variable_name Value
net_buffer_length 1024
@@ -238,7 +240,7 @@ show variables like '%alloc%';
Variable_name Value
query_alloc_block_size 8192
query_prealloc_size 8192
-range_alloc_block_size 2048
+range_alloc_block_size 4096
transaction_alloc_block_size 8192
transaction_prealloc_size 4096
set @@range_alloc_block_size=1024*16;
@@ -263,7 +265,7 @@ show variables like '%alloc%';
Variable_name Value
query_alloc_block_size 8192
query_prealloc_size 8192
-range_alloc_block_size 2048
+range_alloc_block_size 4096
transaction_alloc_block_size 8192
transaction_prealloc_size 4096
SELECT @@version LIKE 'non-existent';
@@ -321,6 +323,8 @@ select @@autocommit, @@big_tables;
@@autocommit @@big_tables
1 1
set global binlog_cache_size=100;
+Warnings:
+Warning 1292 Truncated incorrect binlog_cache_size value: '100'
set bulk_insert_buffer_size=100;
set character set cp1251_koi8;
set character set default;
@@ -349,17 +353,27 @@ set global flush_time=100;
set insert_id=1;
set interactive_timeout=100;
set join_buffer_size=100;
+Warnings:
+Warning 1292 Truncated incorrect join_buffer_size value: '100'
set last_insert_id=1;
set global local_infile=1;
set long_query_time=100;
set low_priority_updates=1;
set max_allowed_packet=100;
+Warnings:
+Warning 1292 Truncated incorrect max_allowed_packet value: '100'
set global max_binlog_cache_size=100;
+Warnings:
+Warning 1292 Truncated incorrect max_binlog_cache_size value: '100'
set global max_binlog_size=100;
+Warnings:
+Warning 1292 Truncated incorrect max_binlog_size value: '100'
set global max_connect_errors=100;
set global max_connections=100;
set global max_delayed_threads=100;
set max_heap_table_size=100;
+Warnings:
+Warning 1292 Truncated incorrect max_heap_table_size value: '100'
set max_join_size=100;
set max_sort_length=100;
set max_tmp_tables=100;
@@ -370,17 +384,25 @@ select @@max_user_connections;
set global max_write_lock_count=100;
set myisam_sort_buffer_size=100;
set net_buffer_length=100;
+Warnings:
+Warning 1292 Truncated incorrect net_buffer_length value: '100'
set net_read_timeout=100;
set net_write_timeout=100;
set global query_cache_limit=100;
set global query_cache_size=100;
set global query_cache_type=demand;
set read_buffer_size=100;
+Warnings:
+Warning 1292 Truncated incorrect read_buffer_size value: '100'
set read_rnd_buffer_size=100;
+Warnings:
+Warning 1292 Truncated incorrect read_rnd_buffer_size value: '100'
set global rpl_recovery_rank=100;
set global server_id=100;
set global slow_launch_time=100;
set sort_buffer_size=100;
+Warnings:
+Warning 1292 Truncated incorrect sort_buffer_size value: '100'
set @@max_sp_recursion_depth=10;
select @@max_sp_recursion_depth;
@@max_sp_recursion_depth
@@ -420,6 +442,8 @@ set storage_engine=myisam;
set global thread_cache_size=100;
set timestamp=1, timestamp=default;
set tmp_table_size=100;
+Warnings:
+Warning 1292 Truncated incorrect tmp_table_size value: '100'
set tx_isolation="READ-COMMITTED";
set wait_timeout=100;
set log_warnings=1;
@@ -570,6 +594,8 @@ SHOW VARIABLES LIKE 'MYISAM_DATA_POINTER_SIZE';
Variable_name Value
myisam_data_pointer_size 7
SET GLOBAL table_cache=-1;
+Warnings:
+Warning 1292 Truncated incorrect table_cache value: '0'
SHOW VARIABLES LIKE 'table_cache';
Variable_name Value
table_cache 1
diff --git a/mysql-test/t/delete.test b/mysql-test/t/delete.test
index 602e30687c8..ec70587c9d1 100644
--- a/mysql-test/t/delete.test
+++ b/mysql-test/t/delete.test
@@ -235,50 +235,6 @@ DELETE FROM t1 ORDER BY (SELECT x);
DROP TABLE t1;
#
-# Bug #30234: Unexpected behavior using DELETE with AS and USING
-# '
-CREATE TABLE t1 (
- a INT
-);
-
-CREATE TABLE t2 (
- a INT
-);
-
-CREATE DATABASE db1;
-CREATE TABLE db1.t1 (
- a INT
-);
-INSERT INTO db1.t1 (a) SELECT * FROM t1;
-
-CREATE DATABASE db2;
-CREATE TABLE db2.t1 (
- a INT
-);
-INSERT INTO db2.t1 (a) SELECT * FROM t2;
-
---error ER_PARSE_ERROR
-DELETE FROM t1 alias USING t1, t2 alias WHERE t1.a = alias.a;
-DELETE FROM alias USING t1, t2 alias WHERE t1.a = alias.a;
-DELETE FROM t1, alias USING t1, t2 alias WHERE t1.a = alias.a;
---error ER_UNKNOWN_TABLE
-DELETE FROM t1, t2 USING t1, t2 alias WHERE t1.a = alias.a;
---error ER_PARSE_ERROR
-DELETE FROM db1.t1 alias USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a;
---error ER_UNKNOWN_TABLE
-DELETE FROM alias USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a;
-DELETE FROM db2.alias USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a;
-DELETE FROM t1 USING t1 WHERE a = 1;
-SELECT * FROM t1;
---error ER_PARSE_ERROR
-DELETE FROM t1 alias USING t1 alias WHERE a = 2;
-SELECT * FROM t1;
-
-DROP TABLE t1, t2;
-DROP DATABASE db1;
-DROP DATABASE db2;
-
-#
# Bug 31742: delete from ... order by function call that causes an error,
# asserts server
#
diff --git a/mysql-test/t/explain.test b/mysql-test/t/explain.test
index 04cf37f457a..c9ae8aceaf6 100644
--- a/mysql-test/t/explain.test
+++ b/mysql-test/t/explain.test
@@ -66,4 +66,32 @@ explain extended select * from t1 having 1;
drop view v1;
drop table t1;
+#
+# Bug #32241: memory corruption due to large index map in 'Range checked for
+# each record'
+#
+
+CREATE TABLE t1(c INT);
+INSERT INTO t1 VALUES (),();
+
+CREATE TABLE t2 (b INT,
+KEY(b),KEY(b),KEY(b),KEY(b),KEY(b),
+KEY(b),KEY(b),KEY(b),KEY(b),KEY(b),
+KEY(b),KEY(b),KEY(b),KEY(b),KEY(b),
+KEY(b),KEY(b),KEY(b),KEY(b),KEY(b),
+KEY(b),KEY(b),KEY(b),KEY(b),KEY(b),
+KEY(b),KEY(b),KEY(b),KEY(b),KEY(b),
+KEY(b),KEY(b),KEY(b),KEY(b),KEY(b),
+KEY(b),KEY(b),KEY(b),KEY(b),KEY(b));
+
+INSERT INTO t2 VALUES (),(),();
+
+# We only need to make sure that there is no buffer overrun and the index map
+# is displayed correctly
+--replace_column 1 X 2 X 3 X 4 X 5 X 6 X 7 X 8 X 9 X
+EXPLAIN SELECT 1 FROM
+ (SELECT 1 FROM t2,t1 WHERE b < c GROUP BY 1 LIMIT 1) AS d2;
+DROP TABLE t2;
+DROP TABLE t1;
+
# End of 5.0 tests.
diff --git a/mysql-test/t/federated.test b/mysql-test/t/federated.test
index cc66a6ab4bc..d4f22650a32 100644
--- a/mysql-test/t/federated.test
+++ b/mysql-test/t/federated.test
@@ -1686,4 +1686,35 @@ insert into federated.t1 (a) values (1);
select * from federated.t2;
drop table federated.t1, federated.t2;
+#
+# Bug #32374 crash with filesort when selecting from federated table and view
+#
+connection slave;
+create table t1 (a varchar(256));
+--disable_warnings
+drop view if exists v1;
+--enable_warnings
+create view v1 as select a from t1;
+--disable_query_log
+let $n= 100;
+while ($n)
+{
+ insert into t1 values (repeat('a',200));
+ dec $n;
+}
+--enable_query_log
+
+connection master;
+--replace_result $SLAVE_MYPORT SLAVE_PORT
+eval create table t1
+ (a varchar(256)) engine=federated
+ connection='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/v1';
+
+select 1 from t1 order by a;
+drop table t1;
+connection slave;
+drop table t1;
+drop view v1;
+
+
source include/federated_cleanup.inc;
diff --git a/mysql-test/t/func_misc.test b/mysql-test/t/func_misc.test
index 844e60ab7ae..82db9ddbd67 100644
--- a/mysql-test/t/func_misc.test
+++ b/mysql-test/t/func_misc.test
@@ -205,6 +205,21 @@ SELECT NAME_CONST('test', -1.0);
SELECT NAME_CONST('test', 'test');
#
+# Bug #27545: erroneous usage of NAME_CONST with a name as the first parameter
+# resolved against a column name of a derived table hangs the client
+#
+
+CREATE TABLE t1 (a int);
+INSERT INTO t1 VALUES (5), (2);
+
+--error ER_RESERVED_SYNTAX
+SELECT NAME_CONST(x,2) FROM (SELECT a x FROM t1) t;
+
+DROP TABLE t1;
+
+--echo End of 5.0 tests
+
+#
# Bug #32559: connection hangs on query with name_const
#
CREATE TABLE t1(a INT);
@@ -224,3 +239,4 @@ select min(a) from t1 group by inet_ntoa(a);
drop table t1;
--echo End of 5.0 tests
+
diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test
index c0a449ac3f4..f8249b7cf7c 100644
--- a/mysql-test/t/func_time.test
+++ b/mysql-test/t/func_time.test
@@ -787,4 +787,14 @@ select concat(a,ifnull(min(date_format(now(), '%Y-%m-%d')),' ull')) from t1;
set lc_time_names=en_US;
drop table t1;
+#
+# Bug#32180: DATE_ADD treats datetime numeric argument as DATE
+# instead of DATETIME
+#
+
+select DATE_ADD('20071108181000', INTERVAL 1 DAY);
+select DATE_ADD(20071108181000, INTERVAL 1 DAY);
+select DATE_ADD('20071108', INTERVAL 1 DAY);
+select DATE_ADD(20071108, INTERVAL 1 DAY);
+
--echo End of 5.0 tests
diff --git a/mysql-test/t/gis.test b/mysql-test/t/gis.test
index b7da7db1d76..cf2e4a21419 100644
--- a/mysql-test/t/gis.test
+++ b/mysql-test/t/gis.test
@@ -439,6 +439,48 @@ INSERT INTO `t1` VALUES ('','0000-00-00');
select geomfromtext(col9,col89) as a from t1;
DROP TABLE t1;
+#
+# Bug #31158 Spatial, Union, LONGBLOB vs BLOB bug (crops data)
+#
+
+CREATE TABLE t1 (
+ geomdata polygon NOT NULL,
+ SPATIAL KEY index_geom (geomdata)
+) ENGINE=MyISAM DEFAULT CHARSET=latin2 DELAY_KEY_WRITE=1 ROW_FORMAT=FIXED;
+
+CREATE TABLE t2 (
+ geomdata polygon NOT NULL,
+ SPATIAL KEY index_geom (geomdata)
+) ENGINE=MyISAM DEFAULT CHARSET=latin2 DELAY_KEY_WRITE=1 ROW_FORMAT=FIXED;
+
+CREATE TABLE t3
+select
+ aswkb(ws.geomdata) AS geomdatawkb
+ from
+ t1 ws
+union
+ select
+ aswkb(ws.geomdata) AS geomdatawkb
+ from
+ t2 ws;
+
+describe t3;
+
+drop table t1;
+drop table t2;
+drop table t3;
+
+#
+# Bug #30284 spatial key corruption
+#
+
+create table t1(col1 geometry default null,col15 geometrycollection not
+null,spatial index(col15),index(col1(15)))engine=myisam;
+insert into t1 set col15 = GeomFromText('POINT(6 5)');
+insert into t1 set col15 = GeomFromText('POINT(6 5)');
+check table t1 extended;
+drop table t1;
+
--echo End of 4.1 tests
#
@@ -600,4 +642,13 @@ SELECT 1;
-- source include/gis_keys.inc
+#
+# Bug #31155 gis types in union'd select cause crash
+#
+
+create table `t1` (`col002` point)engine=myisam;
+insert into t1 values (),(),();
+select min(`col002`) from t1 union select `col002` from t1;
+drop table t1;
+
--echo End of 5.0 tests
diff --git a/mysql-test/t/group_min_max.test b/mysql-test/t/group_min_max.test
index e1010c9fcfe..7f2607b513d 100644
--- a/mysql-test/t/group_min_max.test
+++ b/mysql-test/t/group_min_max.test
@@ -888,7 +888,31 @@ SELECT SQL_BIG_RESULT DISTINCT(a) FROM t1;
DROP TABLE t1;
+#
+# Bug #32268: Indexed queries give bogus MIN and MAX results
+#
+
+CREATE TABLE t1 (a INT, b INT);
+INSERT INTO t1 (a, b) VALUES (1,1), (1,2), (1,3);
+INSERT INTO t1 SELECT a + 1, b FROM t1;
+INSERT INTO t1 SELECT a + 2, b FROM t1;
+EXPLAIN
+SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC;
+SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC;
+CREATE INDEX break_it ON t1 (a, b);
+EXPLAIN
+SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a;
+SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a;
+EXPLAIN
+SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC;
+SELECT a, MIN(b), MAX(b) FROM t1 GROUP BY a ORDER BY a DESC;
+
+EXPLAIN
+SELECT a, MIN(b), MAX(b), AVG(b) FROM t1 GROUP BY a ORDER BY a DESC;
+SELECT a, MIN(b), MAX(b), AVG(b) FROM t1 GROUP BY a ORDER BY a DESC;
+
+DROP TABLE t1;
diff --git a/mysql-test/t/innodb_mysql.test b/mysql-test/t/innodb_mysql.test
index 13aa6afd701..020295684b0 100644
--- a/mysql-test/t/innodb_mysql.test
+++ b/mysql-test/t/innodb_mysql.test
@@ -961,6 +961,19 @@ SELECT * FROM t1 ORDER BY b DESC, a ASC;
DROP TABLE t1;
#
+# Bug #32815: query with ORDER BY and a possible ref_or_null access
+#
+
+CREATE TABLE t1 (id int, type char(6), d int, INDEX idx(id,d)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES
+ (191, 'member', 1), (NULL, 'member', 3), (NULL, 'member', 4), (201, 'member', 2);
+
+EXPLAIN SELECT * FROM t1 WHERE id=191 OR id IS NULL ORDER BY d;
+SELECT * FROM t1 WHERE id=191 OR id IS NULL ORDER BY d;
+
+DROP TABLE t1;
+
+
# Bug #31137: Assertion failed: primary_key_no == -1 || primary_key_no == 0
#
create table t1(a char(10) not null, unique key aa(a(1)),
diff --git a/mysql-test/t/merge.test b/mysql-test/t/merge.test
index b6debadcc94..35443987858 100644
--- a/mysql-test/t/merge.test
+++ b/mysql-test/t/merge.test
@@ -521,4 +521,26 @@ CREATE TABLE t2 (c1 INT) ENGINE=MERGE UNION=(t1) INSERT_METHOD=FIRST;
CREATE TABLE IF NOT EXISTS t1 SELECT * FROM t2;
DROP TABLE t1, t2;
+#
+# Bug #28837: MyISAM storage engine error (134) doing delete with self-join
+#
+
+CREATE TABLE t1 (id INT NOT NULL, ref INT NOT NULL, INDEX (id)) ENGINE=MyISAM;
+CREATE TABLE t2 LIKE t1;
+
+INSERT INTO t2 (id, ref) VALUES (1,3), (2,1), (3,2), (4,5), (4,4);
+INSERT INTO t1 SELECT * FROM t2;
+INSERT INTO t1 SELECT * FROM t2;
+
+CREATE TABLE t3 (id INT NOT NULL, ref INT NOT NULL, INDEX (id)) ENGINE=MERGE
+ UNION(t1);
+
+SELECT * FROM t3 AS a INNER JOIN t3 AS b USING (id) WHERE a.ref < b.ref;
+SELECT * FROM t3;
+DELETE FROM a USING t3 AS a INNER JOIN t3 AS b USING (id) WHERE a.ref < b.ref;
+SELECT * FROM t3;
+
+DROP TABLE t1, t2, t3;
+
+
--echo End of 5.0 tests
diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test
index 80c7a92c12f..90d4fc01afb 100644
--- a/mysql-test/t/myisam.test
+++ b/mysql-test/t/myisam.test
@@ -1193,4 +1193,21 @@ SET @@myisam_repair_threads=1;
CHECK TABLE t1 EXTENDED;
DROP TABLE t1;
+#
+# Bug#28837: MyISAM storage engine error (134) doing delete with self-join
+#
+
+CREATE TABLE t1 (id int NOT NULL, ref int NOT NULL, INDEX (id)) ENGINE=MyISAM;
+CREATE TABLE t2 LIKE t1;
+
+INSERT INTO t2 (id, ref) VALUES (1,3), (2,1), (3,2), (4,5), (4,4);
+INSERT INTO t1 SELECT * FROM t2;
+
+SELECT * FROM t1 AS a INNER JOIN t1 AS b USING (id) WHERE a.ref < b.ref;
+SELECT * FROM t1;
+DELETE FROM a USING t1 AS a INNER JOIN t1 AS b USING (id) WHERE a.ref < b.ref;
+SELECT * FROM t1;
+
+DROP TABLE t1, t2;
+
--echo End of 5.0 tests
diff --git a/mysql-test/t/outfile_loaddata.test b/mysql-test/t/outfile_loaddata.test
index 2f6ac998b3d..2a120871e7d 100644
--- a/mysql-test/t/outfile_loaddata.test
+++ b/mysql-test/t/outfile_loaddata.test
@@ -86,4 +86,28 @@ DROP TABLE t2;
DROP TABLE t1;
+--echo #
+--echo # Bug#32533: SELECT INTO OUTFILE never escapes multibyte character
+--echo #
+
+CREATE TABLE t1 (c1 VARCHAR(256));
+INSERT INTO t1 VALUES (0xC3);
+SELECT HEX(c1) FROM t1;
+
+--let $file=$MYSQLTEST_VARDIR/tmp/bug32533.txt
+
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--eval SELECT * INTO OUTFILE '$file' FIELDS ENCLOSED BY 0xC3 FROM t1
+TRUNCATE t1;
+
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--eval SELECT HEX(LOAD_FILE('$file'))
+
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--eval LOAD DATA INFILE '$file' INTO TABLE t1 FIELDS ENCLOSED BY 0xC3
+SELECT HEX(c1) FROM t1;
+
+--remove_file $file
+DROP TABLE t1;
+
--echo # End of 5.0 tests.
diff --git a/mysql-test/t/range.test b/mysql-test/t/range.test
index b8d4b91f03d..87ba3510326 100644
--- a/mysql-test/t/range.test
+++ b/mysql-test/t/range.test
@@ -935,4 +935,24 @@ SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00';
DROP TABLE t1;
+--echo
+--echo BUG#32198 "Comparison of DATE with DATETIME still not using indexes correctly"
+--echo
+CREATE TABLE t1 (
+ id int(11) NOT NULL auto_increment,
+ dateval date default NULL,
+ PRIMARY KEY (id),
+ KEY dateval (dateval)
+) AUTO_INCREMENT=173;
+
+INSERT INTO t1 VALUES
+(1,'2007-01-01'),(2,'2007-01-02'),(3,'2007-01-03'),(4,'2007-01-04'),
+(5,'2007-01-05'),(6,'2007-01-06'),(7,'2007-01-07'),(8,'2007-01-08'),
+(9,'2007-01-09'),(10,'2007-01-10'),(11,'2007-01-11');
+
+--echo This must use range access:
+explain select * from t1 where dateval >= '2007-01-01 00:00:00' and dateval <= '2007-01-02 23:59:59';
+
+drop table t1;
+
# End of 5.0 tests
diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test
index 31c8a3f7d11..c48f2771aa8 100644
--- a/mysql-test/t/select.test
+++ b/mysql-test/t/select.test
@@ -3661,4 +3661,15 @@ DROP TABLE t2;
###########################################################################
+#
+# Bug #32335: Error on BIGINT > NULL + 1
+#
+
+CREATE TABLE t1 (c1 BIGINT NOT NULL);
+INSERT INTO t1 (c1) VALUES (1);
+SELECT * FROM t1 WHERE c1 > NULL + 1;
+DROP TABLE t1;
+
+--echo
+
--echo End of 5.0 tests
diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test
index 06a64f518fb..ea080964058 100644
--- a/mysql-test/t/subselect.test
+++ b/mysql-test/t/subselect.test
@@ -32,7 +32,9 @@ SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a));
select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1));
-- error 1108
SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1));
+-- error ER_BAD_FIELD_ERROR
SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL;
+-- error ER_BAD_FIELD_ERROR
SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NOT NULL;
SELECT (SELECT 1,2,3) = ROW(1,2,3);
SELECT (SELECT 1,2,3) = ROW(1,2,1);
@@ -1346,17 +1348,20 @@ drop table t1,t2;
CREATE TABLE t1 ( a int, b int );
CREATE TABLE t2 ( c int, d int );
INSERT INTO t1 VALUES (1,2), (2,3), (3,4);
-SELECT a AS abc, b FROM t1 WHERE b = (SELECT MIN(b) FROM t1 WHERE a=abc);
-INSERT INTO t2 SELECT a AS abc, b FROM t1 WHERE b = (SELECT MIN(b) FROM t1 WHERE a=abc);
+SELECT a AS abc, b FROM t1 outr WHERE b =
+ (SELECT MIN(b) FROM t1 WHERE a=outr.a);
+INSERT INTO t2 SELECT a AS abc, b FROM t1 outr WHERE b =
+ (SELECT MIN(b) FROM t1 WHERE a=outr.a);
select * from t2;
-CREATE TABLE t3 SELECT a AS abc, b FROM t1 WHERE b = (SELECT MIN(b) FROM t1 WHERE a=abc);
+CREATE TABLE t3 SELECT a AS abc, b FROM t1 outr WHERE b =
+ (SELECT MIN(b) FROM t1 WHERE a=outr.a);
select * from t3;
-prepare stmt1 from "INSERT INTO t2 SELECT a AS abc, b FROM t1 WHERE b = (SELECT MIN(b) FROM t1 WHERE a=abc);";
+prepare stmt1 from "INSERT INTO t2 SELECT a AS abc, b FROM t1 outr WHERE b = (SELECT MIN(b) FROM t1 WHERE a=outr.a);";
execute stmt1;
deallocate prepare stmt1;
select * from t2;
drop table t3;
-prepare stmt1 from "CREATE TABLE t3 SELECT a AS abc, b FROM t1 WHERE b = (SELECT MIN(b) FROM t1 WHERE a=abc);";
+prepare stmt1 from "CREATE TABLE t3 SELECT a AS abc, b FROM t1 outr WHERE b = (SELECT MIN(b) FROM t1 WHERE a=outr.a);";
execute stmt1;
select * from t3;
deallocate prepare stmt1;
@@ -1529,7 +1534,9 @@ INSERT INTO t1 VALUES ('ASM','American Samoa','Oceania','Polynesia',199.00,0,680
INSERT INTO t1 VALUES ('ATF','French Southern territories','Antarctica','Antarctica',7780.00,0,0,NULL,0.00,NULL,'Terres australes françaises','Nonmetropolitan Territory of France','Jacques Chirac',NULL,'TF');
INSERT INTO t1 VALUES ('UMI','United States Minor Outlying Islands','Oceania','Micronesia/Caribbean',16.00,0,0,NULL,0.00,NULL,'United States Minor Outlying Islands','Dependent Territory of the US','George W. Bush',NULL,'UM');
/*!40000 ALTER TABLE t1 ENABLE KEYS */;
-SELECT DISTINCT Continent AS c FROM t1 WHERE Code <> SOME ( SELECT Code FROM t1 WHERE Continent = c AND Population < 200);
+SELECT DISTINCT Continent AS c FROM t1 outr WHERE
+ Code <> SOME ( SELECT Code FROM t1 WHERE Continent = outr.Continent AND
+ Population < 200);
drop table t1;
#
@@ -2448,12 +2455,16 @@ DROP TABLE t1, t2;
CREATE TABLE t1 (i INT);
(SELECT i FROM t1) UNION (SELECT i FROM t1);
+#TODO:not supported
+--error ER_PARSE_ERROR
SELECT sql_no_cache * FROM t1 WHERE NOT EXISTS
(
(SELECT i FROM t1) UNION
(SELECT i FROM t1)
);
+#TODO:not supported
+--error ER_PARSE_ERROR
SELECT * FROM t1
WHERE NOT EXISTS (((SELECT i FROM t1) UNION (SELECT i FROM t1)));
@@ -2461,7 +2472,9 @@ WHERE NOT EXISTS (((SELECT i FROM t1) UNION (SELECT i FROM t1)));
--error 1064
explain select ((select t11.i from t1 t11) union (select t12.i from t1 t12))
from t1;
-#supported
+
+#TODO:not supported
+--error ER_PARSE_ERROR
explain select * from t1 where not exists
((select t11.i from t1 t11) union (select t12.i from t1 t12));
@@ -2988,6 +3001,100 @@ SELECT (SELECT SUM(t1.a) FROM t2 WHERE a=1) FROM t1;
DROP TABLE t1,t2;
#
+# Bug31048: Many nested subqueries may cause server crash.
+#
+create table t1(a int,b int,key(a),key(b));
+insert into t1(a,b) values (1,2),(2,1),(2,3),(3,4),(5,4),(5,5),
+ (6,7),(7,4),(5,3);
+# test for the stack overflow bug
+select sum(a),a from t1 where a> (
+ select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+ select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+ select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+ select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+ select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+ select sum(a) from t1 where a> ( select sum(a) from t1
+ )group by b limit 1)group by b limit 1
+ )group by b limit 1)group by b limit 1)group by b limit 1
+ )group by b limit 1)group by b limit 1)group by b limit 1
+ )group by b limit 1)group by b limit 1)group by b limit 1)
+group by a;
+--replace_regex /overrun.*$/overrun detected/
+--error 1436
+select sum(a),a from t1 where a> (
+ select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+ select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+ select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+ select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+ select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+ select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+ select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+ select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+ select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+ select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+ select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+ select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+ select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+ select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+ select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+ select sum(a) from t1
+ )group by b limit 1)group by b limit 1)group by b limit 1
+ )group by b limit 1)group by b limit 1)group by b limit 1
+ )group by b limit 1)group by b limit 1)group by b limit 1
+ )group by b limit 1)group by b limit 1)group by b limit 1
+ )group by b limit 1)group by b limit 1)group by b limit 1
+ )group by b limit 1)group by b limit 1)group by b limit 1
+ )group by b limit 1)group by b limit 1)group by b limit 1
+ )group by b limit 1)group by b limit 1)group by b limit 1
+ )group by b limit 1)group by b limit 1)group by b limit 1
+ )group by b limit 1)group by b limit 1)group by b limit 1)
+group by a;
+# test for the memory consumption & subquery slowness bug
+explain select sum(a),a from t1 where a> (
+ select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+ select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+ select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+ select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+ select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+ select sum(a) from t1 where a> ( select sum(a) from t1
+ )group by b limit 1)group by b limit 1
+ )group by b limit 1)group by b limit 1)group by b limit 1
+ )group by b limit 1)group by b limit 1)group by b limit 1
+ )group by b limit 1)group by b limit 1)group by b limit 1)
+group by a;
+--replace_regex /overrun.*$/overrun detected/
+--error 1436
+explain select sum(a),a from t1 where a> (
+ select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+ select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+ select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+ select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+ select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+ select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+ select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+ select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+ select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+ select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+ select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+ select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+ select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+ select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+ select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
+ select sum(a) from t1
+ )group by b limit 1)group by b limit 1)group by b limit 1
+ )group by b limit 1)group by b limit 1)group by b limit 1
+ )group by b limit 1)group by b limit 1)group by b limit 1
+ )group by b limit 1)group by b limit 1)group by b limit 1
+ )group by b limit 1)group by b limit 1)group by b limit 1
+ )group by b limit 1)group by b limit 1)group by b limit 1
+ )group by b limit 1)group by b limit 1)group by b limit 1
+ )group by b limit 1)group by b limit 1)group by b limit 1
+ )group by b limit 1)group by b limit 1)group by b limit 1
+ )group by b limit 1)group by b limit 1)group by b limit 1)
+group by a;
+drop table t1;
+
+#
# Bug #31884: Assertion + crash in subquery in the SELECT clause.
#
@@ -3044,4 +3151,83 @@ SELECT LEFT(t1.a1,1) FROM t1,t3 WHERE t1.b1=t3.a3;
SELECT a2 FROM t2 WHERE t2.a2 IN (SELECT t1.a1 FROM t1,t3 WHERE t1.b1=t3.a3);
DROP TABLE t1, t2, t3;
+#
+# Bug #30788: Inconsistent retrieval of char/varchar
+#
+
+CREATE TABLE t1 (a CHAR(1), b VARCHAR(10));
+INSERT INTO t1 VALUES ('a', 'aa');
+INSERT INTO t1 VALUES ('a', 'aaa');
+SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1);
+CREATE INDEX I1 ON t1 (a);
+CREATE INDEX I2 ON t1 (b);
+EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1);
+SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1);
+
+CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10));
+INSERT INTO t2 SELECT * FROM t1;
+CREATE INDEX I1 ON t2 (a);
+CREATE INDEX I2 ON t2 (b);
+EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2);
+SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2);
+EXPLAIN
+SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500);
+SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500);
+
+DROP TABLE t1,t2;
+
+#
+# Bug #32400: Complex SELECT query returns correct result only on some
+# occasions
+#
+
+CREATE TABLE t1(a INT, b INT);
+INSERT INTO t1 VALUES (1,1), (1,2), (2,3), (2,4);
+
+--error ER_BAD_FIELD_ERROR
+EXPLAIN
+SELECT a AS out_a, MIN(b) FROM t1
+WHERE b > (SELECT MIN(b) FROM t1 WHERE a = out_a)
+GROUP BY a;
+
+--error ER_BAD_FIELD_ERROR
+SELECT a AS out_a, MIN(b) FROM t1
+WHERE b > (SELECT MIN(b) FROM t1 WHERE a = out_a)
+GROUP BY a;
+
+EXPLAIN
+SELECT a AS out_a, MIN(b) FROM t1 t1_outer
+WHERE b > (SELECT MIN(b) FROM t1 WHERE a = t1_outer.a)
+GROUP BY a;
+
+SELECT a AS out_a, MIN(b) FROM t1 t1_outer
+WHERE b > (SELECT MIN(b) FROM t1 WHERE a = t1_outer.a)
+GROUP BY a;
+
+DROP TABLE t1;
+
+#
+# Bug #32036: EXISTS within a WHERE clause with a UNION crashes MySQL 5.122
+#
+
+CREATE TABLE t1 (a INT);
+CREATE TABLE t2 (a INT);
+
+INSERT INTO t1 VALUES (1),(2);
+INSERT INTO t2 VALUES (1),(2);
+
+SELECT 2 FROM t1 WHERE EXISTS ((SELECT 1 FROM t2 WHERE t1.a=t2.a));
+EXPLAIN EXTENDED
+SELECT 2 FROM t1 WHERE EXISTS ((SELECT 1 FROM t2 WHERE t1.a=t2.a));
+
+
+#TODO:not supported
+--error ER_PARSE_ERROR
+EXPLAIN EXTENDED
+SELECT 2 FROM t1 WHERE EXISTS ((SELECT 1 FROM t2 WHERE t1.a=t2.a) UNION
+ (SELECT 1 FROM t2 WHERE t1.a = t2.a));
+
+DROP TABLE t1,t2;
+
+
--echo End of 5.0 tests.
diff --git a/mysql-test/t/type_bit.test b/mysql-test/t/type_bit.test
index 4978f55d776..3095311bfbc 100644
--- a/mysql-test/t/type_bit.test
+++ b/mysql-test/t/type_bit.test
@@ -318,4 +318,19 @@ INSERT INTO t2 VALUES (3, 2, 'two'), (2, 3, 'three'), (2, 0, 'zero'),
SELECT COUNT(DISTINCT b,c) FROM t2 GROUP BY a;
DROP TABLE t2;
+#
+# BUG#32556 assert in "using index for group-by" : is_last_prefix <= 0,
+# file .\opt_range.cc
+
+CREATE TABLE t1(a BIT(13), KEY(a));
+--disable_warnings
+INSERT INTO t1(a) VALUES
+(65535),(65525),(65535),(65535),(65535),(65535),(65535),(65535),(65535),(65535);
+--enable_warnings
+
+EXPLAIN SELECT 1 FROM t1 GROUP BY a;
+SELECT 1 FROM t1 GROUP BY a;
+
+DROP TABLE t1;
+
--echo End of 5.0 tests
diff --git a/mysql-test/t/type_blob.test b/mysql-test/t/type_blob.test
index ba9f374a24c..d79b749dd65 100644
--- a/mysql-test/t/type_blob.test
+++ b/mysql-test/t/type_blob.test
@@ -436,4 +436,15 @@ set @@sql_mode='TRADITIONAL';
create table t1 (a text default '');
set @@sql_mode='';
+#
+# Bug #32282: TEXT silently truncates when value is exactly 65536 bytes
+#
+
+CREATE TABLE t (c TEXT CHARSET ASCII);
+INSERT INTO t (c) VALUES (REPEAT('1',65537));
+INSERT INTO t (c) VALUES (REPEAT('2',65536));
+INSERT INTO t (c) VALUES (REPEAT('3',65535));
+SELECT LENGTH(c), CHAR_LENGTH(c) FROM t;
+DROP TABLE t;
+
--echo End of 5.0 tests
diff --git a/mysql-test/t/type_date.test b/mysql-test/t/type_date.test
index 507537457d3..885fad3b623 100644
--- a/mysql-test/t/type_date.test
+++ b/mysql-test/t/type_date.test
@@ -190,4 +190,24 @@ INSERT INTO t1 VALUES ('0000-00-00');
SET SQL_MODE=DEFAULT;
DROP TABLE t1,t2;
+#
+# Bug #31928: Search fails on '1000-00-00' date after sql_mode change
+#
+
+CREATE TABLE t1 (a DATE);
+CREATE TABLE t2 (a DATE);
+CREATE INDEX i ON t1 (a);
+INSERT INTO t1 VALUES ('1000-00-00'),('1000-00-00');
+INSERT INTO t2 VALUES ('1000-00-00'),('1000-00-00');
+SELECT * FROM t1 WHERE a = '1000-00-00';
+SELECT * FROM t2 WHERE a = '1000-00-00';
+SET SQL_MODE=TRADITIONAL;
+EXPLAIN SELECT * FROM t1 WHERE a = '1000-00-00';
+SELECT * FROM t1 WHERE a = '1000-00-00';
+SELECT * FROM t2 WHERE a = '1000-00-00';
+--error ER_TRUNCATED_WRONG_VALUE
+INSERT INTO t1 VALUES ('1000-00-00');
+SET SQL_MODE=DEFAULT;
+DROP TABLE t1,t2;
+
--echo End of 5.0 tests
diff --git a/mysql-test/t/type_datetime.test b/mysql-test/t/type_datetime.test
index 219af2336e1..722e4c082a7 100644
--- a/mysql-test/t/type_datetime.test
+++ b/mysql-test/t/type_datetime.test
@@ -351,4 +351,41 @@ insert into t1 values (), (), ();
select sum(a) from t1 group by convert(a, datetime);
drop table t1;
+#
+# Bug #32694: NOT NULL table field in a subquery produces invalid results
+#
+create table t1 (id int(10) not null, cur_date datetime not null);
+create table t2 (id int(10) not null, cur_date date not null);
+insert into t1 (id, cur_date) values (1, '2007-04-25 18:30:22');
+insert into t2 (id, cur_date) values (1, '2007-04-25');
+
+explain extended
+select * from t1
+where id in (select id from t1 as x1 where (t1.cur_date is null));
+select * from t1
+where id in (select id from t1 as x1 where (t1.cur_date is null));
+
+explain extended
+select * from t2
+where id in (select id from t2 as x1 where (t2.cur_date is null));
+select * from t2
+where id in (select id from t2 as x1 where (t2.cur_date is null));
+
+insert into t1 (id, cur_date) values (2, '2007-04-26 18:30:22');
+insert into t2 (id, cur_date) values (2, '2007-04-26');
+
+explain extended
+select * from t1
+where id in (select id from t1 as x1 where (t1.cur_date is null));
+select * from t1
+where id in (select id from t1 as x1 where (t1.cur_date is null));
+
+explain extended
+select * from t2
+where id in (select id from t2 as x1 where (t2.cur_date is null));
+select * from t2
+where id in (select id from t2 as x1 where (t2.cur_date is null));
+
+drop table t1,t2;
+
--echo End of 5.0 tests
diff --git a/mysql-test/t/udf.test b/mysql-test/t/udf.test
index 22b8ed10a49..648494b3df9 100644
--- a/mysql-test/t/udf.test
+++ b/mysql-test/t/udf.test
@@ -362,4 +362,25 @@ DROP PROCEDURE check_const_len_sp;
DROP TRIGGER check_const_len_trigger;
DROP TABLE const_len_bug;
+
+#
+# Bug #30355: Incorrect ordering of UDF results
+#
+
+--replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB
+eval CREATE FUNCTION sequence RETURNS INTEGER SONAME "$UDF_EXAMPLE_LIB";
+CREATE TABLE t1 (a INT);
+CREATE TABLE t2 (a INT PRIMARY KEY);
+INSERT INTO t1 VALUES (4),(3),(2),(1);
+INSERT INTO t2 SELECT * FROM t1;
+
+SELECT sequence() AS seq, a FROM t1 ORDER BY seq ASC;
+SELECT sequence() AS seq, a FROM t1 ORDER BY seq DESC;
+
+SELECT * FROM t1 WHERE a = sequence();
+SELECT * FROM t2 WHERE a = sequence();
+
+DROP FUNCTION sequence;
+DROP TABLE t1,t2;
+
--echo End of 5.0 tests.
diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test
index a8f0a3425df..c86e7dfa7f3 100644
--- a/mysql-test/t/variables.test
+++ b/mysql-test/t/variables.test
@@ -126,7 +126,7 @@ set GLOBAL query_cache_size=100000;
set GLOBAL myisam_max_sort_file_size=2000000;
show global variables like 'myisam_max_sort_file_size';
set GLOBAL myisam_max_sort_file_size=default;
---replace_result 2147483647 FILE_SIZE 9223372036854775807 FILE_SIZE
+--replace_result 9223372036853727232 FILE_SIZE 2146435072 FILE_SIZE
show variables like 'myisam_max_sort_file_size';
set global net_retry_count=10, session net_retry_count=10;
diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c
index 71630e1b4c2..3bb500616a1 100644
--- a/mysys/my_getopt.c
+++ b/mysys/my_getopt.c
@@ -31,6 +31,7 @@ my_bool getopt_compare_strings(const char *s,
const char *t,
uint length);
static longlong getopt_ll(char *arg, const struct my_option *optp, int *err);
+static longlong getopt_ll_limit_value(longlong, const struct my_option *);
static ulonglong getopt_ull(char *arg, const struct my_option *optp,
int *err);
static void init_variables(const struct my_option *options);
@@ -70,6 +71,7 @@ static void default_reporter(enum loglevel level,
fprintf(stderr, "%s", "Info: ");
vfprintf(stderr, format, args);
va_end(args);
+ fputc('\n', stderr);
fflush(stderr);
}
@@ -133,7 +135,7 @@ int handle_options(int *argc, char ***argv,
{
if (my_getopt_print_errors)
my_getopt_error_reporter(ERROR_LEVEL,
- "%s: Option '-O' requires an argument\n",
+ "%s: Option '-O' requires an argument",
my_progname);
return EXIT_ARGUMENT_REQUIRED;
}
@@ -151,7 +153,7 @@ int handle_options(int *argc, char ***argv,
{
if (my_getopt_print_errors)
my_getopt_error_reporter(ERROR_LEVEL,
- "%s: Option '--set-variable' requires an argument\n",
+ "%s: Option '--set-variable' requires an argument",
my_progname);
return EXIT_ARGUMENT_REQUIRED;
}
@@ -165,7 +167,7 @@ int handle_options(int *argc, char ***argv,
{
if (my_getopt_print_errors)
my_getopt_error_reporter(ERROR_LEVEL,
- "%s: Option '--set-variable' requires an argument\n",
+ "%s: Option '--set-variable' requires an argument",
my_progname);
return EXIT_ARGUMENT_REQUIRED;
}
@@ -228,7 +230,7 @@ int handle_options(int *argc, char ***argv,
{
if (my_getopt_print_errors)
my_getopt_error_reporter(ERROR_LEVEL,
- "%s: ambiguous option '--%s-%s' (--%s-%s)\n",
+ "%s: ambiguous option '--%s-%s' (--%s-%s)",
my_progname, special_opt_prefix[i],
cur_arg, special_opt_prefix[i],
prev_found);
@@ -265,7 +267,7 @@ int handle_options(int *argc, char ***argv,
if (my_getopt_print_errors)
my_getopt_error_reporter(option_is_loose ?
WARNING_LEVEL : ERROR_LEVEL,
- "%s: unknown variable '%s'\n",
+ "%s: unknown variable '%s'",
my_progname, cur_arg);
if (!option_is_loose)
return EXIT_UNKNOWN_VARIABLE;
@@ -273,9 +275,9 @@ int handle_options(int *argc, char ***argv,
else
{
if (my_getopt_print_errors)
- my_getopt_error_reporter(option_is_loose ?
+ my_getopt_error_reporter(option_is_loose ?
WARNING_LEVEL : ERROR_LEVEL,
- "%s: unknown option '--%s'\n",
+ "%s: unknown option '--%s'",
my_progname, cur_arg);
if (!option_is_loose)
return EXIT_UNKNOWN_OPTION;
@@ -293,7 +295,7 @@ int handle_options(int *argc, char ***argv,
{
if (my_getopt_print_errors)
my_getopt_error_reporter(ERROR_LEVEL,
- "%s: variable prefix '%s' is not unique\n",
+ "%s: variable prefix '%s' is not unique",
my_progname, opt_str);
return EXIT_VAR_PREFIX_NOT_UNIQUE;
}
@@ -301,7 +303,7 @@ int handle_options(int *argc, char ***argv,
{
if (my_getopt_print_errors)
my_getopt_error_reporter(ERROR_LEVEL,
- "%s: ambiguous option '--%s' (%s, %s)\n",
+ "%s: ambiguous option '--%s' (%s, %s)",
my_progname, opt_str, prev_found,
optp->name);
return EXIT_AMBIGUOUS_OPTION;
@@ -324,7 +326,7 @@ int handle_options(int *argc, char ***argv,
{
if (my_getopt_print_errors)
my_getopt_error_reporter(ERROR_LEVEL,
- "%s: option '%s' cannot take an argument\n",
+ "%s: option '%s' cannot take an argument",
my_progname, optp->name);
return EXIT_NO_ARGUMENT_ALLOWED;
}
@@ -337,7 +339,7 @@ int handle_options(int *argc, char ***argv,
{
if (my_getopt_print_errors)
my_getopt_error_reporter(ERROR_LEVEL,
- "%s: option '--%s' cannot take an argument\n",
+ "%s: option '--%s' cannot take an argument",
my_progname, optp->name);
return EXIT_NO_ARGUMENT_ALLOWED;
}
@@ -359,7 +361,7 @@ int handle_options(int *argc, char ***argv,
{
my_getopt_error_reporter(WARNING_LEVEL,
"%s: ignoring option '--%s' due to \
-invalid value '%s'\n",
+invalid value '%s'",
my_progname, optp->name, optend);
continue;
}
@@ -390,7 +392,7 @@ invalid value '%s'\n",
{
if (my_getopt_print_errors)
my_getopt_error_reporter(ERROR_LEVEL,
- "%s: option '--%s' requires an argument\n",
+ "%s: option '--%s' requires an argument",
my_progname, optp->name);
return EXIT_ARGUMENT_REQUIRED;
}
@@ -450,7 +452,7 @@ invalid value '%s'\n",
{
if (my_getopt_print_errors)
my_getopt_error_reporter(ERROR_LEVEL,
- "%s: option '-%c' requires an argument\n",
+ "%s: option '-%c' requires an argument",
my_progname, optp->id);
return EXIT_ARGUMENT_REQUIRED;
}
@@ -463,7 +465,7 @@ invalid value '%s'\n",
set_maximum_value)))
{
my_getopt_error_reporter(ERROR_LEVEL,
- "%s: Error while setting value '%s' to '%s'\n",
+ "%s: Error while setting value '%s' to '%s'",
my_progname, argument, optp->name);
return error;
}
@@ -475,7 +477,7 @@ invalid value '%s'\n",
{
if (my_getopt_print_errors)
my_getopt_error_reporter(ERROR_LEVEL,
- "%s: unknown option '-%c'\n",
+ "%s: unknown option '-%c'",
my_progname, *optend);
return EXIT_UNKNOWN_OPTION;
}
@@ -486,13 +488,13 @@ invalid value '%s'\n",
if ((error= setval(optp, value, argument, set_maximum_value)))
{
my_getopt_error_reporter(ERROR_LEVEL,
- "%s: Error while setting value '%s' to '%s'\n",
+ "%s: Error while setting value '%s' to '%s'",
my_progname, argument, optp->name);
return error;
}
get_one_option(optp->id, optp, argument);
- (*argc)--; /* option handled (short or long), decrease argument count */
+ (*argc)--; /* option handled (short or long), decrease argument count */
}
else /* non-option found */
(*argv)[argvpos++]= cur_arg;
@@ -575,13 +577,17 @@ static int setval(const struct my_option *opts, gptr *value, char *argument,
*((my_bool*) result_pos)= (my_bool) atoi(argument) != 0;
break;
case GET_INT:
- case GET_UINT: /* fall through */
*((int*) result_pos)= (int) getopt_ll(argument, opts, &err);
break;
+ case GET_UINT:
+ *((uint*) result_pos)= (uint) getopt_ull(argument, opts, &err);
+ break;
case GET_LONG:
- case GET_ULONG: /* fall through */
*((long*) result_pos)= (long) getopt_ll(argument, opts, &err);
break;
+ case GET_ULONG:
+ *((long*) result_pos)= (long) getopt_ull(argument, opts, &err);
+ break;
case GET_LL:
*((longlong*) result_pos)= getopt_ll(argument, opts, &err);
break;
@@ -733,23 +739,46 @@ static longlong eval_num_suffix (char *argument, int *error, char *option_name)
static longlong getopt_ll(char *arg, const struct my_option *optp, int *err)
{
- longlong num;
+ longlong num=eval_num_suffix(arg, err, (char*) optp->name);
+ return getopt_ll_limit_value(num, optp);
+}
+
+/*
+ function: getopt_ll_limit_value
+
+ Applies min/max/block_size to a numeric value of an option.
+ Returns "fixed" value.
+*/
+
+static longlong getopt_ll_limit_value(longlong num,
+ const struct my_option *optp)
+{
+ longlong old= num;
+ bool trunc= FALSE;
+ char buf1[255], buf2[255];
ulonglong block_size= (optp->block_size ? (ulonglong) optp->block_size : 1L);
-
- num= eval_num_suffix(arg, err, (char*) optp->name);
- if (num > 0 && (ulonglong) num > (ulonglong) optp->max_value &&
+
+ if (num > 0 && ((ulonglong) num > (ulonglong) optp->max_value) &&
optp->max_value) /* if max value is not set -> no upper limit */
{
- char buf[22];
- my_getopt_error_reporter(WARNING_LEVEL,
- "Truncated incorrect %s value: '%s'",
- optp->name, llstr(num, buf));
-
num= (ulonglong) optp->max_value;
+ trunc= TRUE;
}
+
num= ((num - optp->sub_size) / block_size);
num= (longlong) (num * block_size);
- return max(num, optp->min_value);
+
+ if (num < optp->min_value)
+ {
+ num= optp->min_value;
+ trunc= TRUE;
+ }
+
+ if (trunc)
+ my_getopt_error_reporter(WARNING_LEVEL,
+ "option '%s': signed value %s adjusted to %s",
+ optp->name, llstr(old, buf1), llstr(num, buf2));
+ return num;
}
/*
@@ -761,25 +790,67 @@ static longlong getopt_ll(char *arg, const struct my_option *optp, int *err)
static ulonglong getopt_ull(char *arg, const struct my_option *optp, int *err)
{
- ulonglong num;
-
- num= eval_num_suffix(arg, err, (char*) optp->name);
- return getopt_ull_limit_value(num, optp);
+ ulonglong num= eval_num_suffix(arg, err, (char*) optp->name);
+ return getopt_ull_limit_value(num, optp, NULL);
}
-ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp)
+ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp,
+ bool *fix)
{
+ bool adjusted= FALSE;
+ ulonglong old= num;
+ char buf1[255], buf2[255];
+
if ((ulonglong) num > (ulonglong) optp->max_value &&
optp->max_value) /* if max value is not set -> no upper limit */
+ {
num= (ulonglong) optp->max_value;
+ adjusted= TRUE;
+ }
+
+ switch ((optp->var_type & GET_TYPE_MASK)) {
+ case GET_UINT:
+ if (num > (ulonglong) UINT_MAX)
+ {
+ num= ((ulonglong) UINT_MAX);
+ adjusted= TRUE;
+ }
+ break;
+ case GET_ULONG:
+#if SIZEOF_LONG < SIZEOF_LONG_LONG
+ if (num > (ulonglong) ULONG_MAX)
+ {
+ num= ((ulonglong) ULONG_MAX);
+ adjusted= TRUE;
+ }
+#endif
+ break;
+ default:
+ DBUG_ASSERT((optp->var_type & GET_TYPE_MASK) == GET_ULL);
+ break;
+ }
+
if (optp->block_size > 1)
{
num/= (ulonglong) optp->block_size;
num*= (ulonglong) optp->block_size;
}
+
if (num < (ulonglong) optp->min_value)
+ {
num= (ulonglong) optp->min_value;
+ adjusted= TRUE;
+ }
+
+ if (adjusted)
+ my_getopt_error_reporter(WARNING_LEVEL,
+ "option '%s': unsigned value %s adjusted to %s",
+ optp->name, ullstr(old, buf1), ullstr(num, buf2));
+
+ if (fix)
+ *fix= adjusted;
+
return num;
}
@@ -789,38 +860,43 @@ ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp)
SYNOPSIS
init_one_value()
- option Option to initialize
- value Pointer to variable
+ optp Option to initialize
+ value Pointer to variable
*/
-static void init_one_value(const struct my_option *option, gptr *variable,
+static void init_one_value(const struct my_option *optp, gptr *variable,
longlong value)
{
- switch ((option->var_type & GET_TYPE_MASK)) {
+ DBUG_ENTER("init_one_value");
+
+ switch ((optp->var_type & GET_TYPE_MASK)) {
case GET_BOOL:
*((my_bool*) variable)= (my_bool) value;
break;
case GET_INT:
- *((int*) variable)= (int) value;
+ *((int*) variable)= (int) getopt_ll_limit_value(value, optp);
break;
case GET_UINT:
- *((uint*) variable)= (uint) value;
+ *((uint*) variable)= (uint) getopt_ull_limit_value(value, optp, NULL);
break;
case GET_LONG:
- *((long*) variable)= (long) value;
+ *((long*) variable)= (long) getopt_ll_limit_value(value, optp);
break;
case GET_ULONG:
- *((ulong*) variable)= (ulong) value;
+ *((ulong*) variable)= (ulong) getopt_ull_limit_value(value, optp, NULL);
break;
case GET_LL:
- *((longlong*) variable)= (longlong) value;
+ *((longlong*) variable)= (longlong) getopt_ll_limit_value(value, optp);
break;
case GET_ULL:
- *((ulonglong*) variable)= (ulonglong) value;
+ *((ulonglong*) variable)= (ulonglong) getopt_ull_limit_value(value, optp,
+ NULL);
break;
default: /* dummy default to avoid compiler warnings */
break;
}
+
+ DBUG_VOID_RETURN;
}
@@ -839,9 +915,11 @@ static void init_one_value(const struct my_option *option, gptr *variable,
static void init_variables(const struct my_option *options)
{
+ DBUG_ENTER("init_variables");
for (; options->name; options++)
{
gptr *variable;
+ DBUG_PRINT("options", ("name: '%s'", options->name));
/*
We must set u_max_value first as for some variables
options->u_max_value == options->value and in this case we want to
@@ -855,6 +933,7 @@ static void init_variables(const struct my_option *options)
(variable= (*getopt_get_addr)("", 0, options)))
init_one_value(options, variable, options->def_value);
}
+ DBUG_VOID_RETURN;
}
@@ -957,8 +1036,8 @@ void my_print_variables(const struct my_option *options)
(*getopt_get_addr)("", 0, optp) : optp->value);
if (value)
{
- printf("%s", optp->name);
- length= (uint) strlen(optp->name);
+ printf("%s ", optp->name);
+ length= (uint) strlen(optp->name)+1;
for (; length < name_space; length++)
putchar(' ');
switch ((optp->var_type & GET_TYPE_MASK)) {
@@ -977,7 +1056,7 @@ void my_print_variables(const struct my_option *options)
printf("%d\n", *((uint*) value));
break;
case GET_LONG:
- printf("%lu\n", *((long*) value));
+ printf("%ld\n", *((long*) value));
break;
case GET_ULONG:
printf("%lu\n", *((ulong*) value));
diff --git a/scripts/make_win_bin_dist b/scripts/make_win_bin_dist
index 849226c94ea..d065e171bb0 100755
--- a/scripts/make_win_bin_dist
+++ b/scripts/make_win_bin_dist
@@ -152,7 +152,6 @@ if [ x"$TARGET" != x"release" ] ; then
cp server-tools/instance-manager/$TARGET/*.pdb $DESTDIR/bin/
fi
cp tests/$TARGET/*.exe $DESTDIR/bin/
-cp libmysql/$TARGET/*.exe $DESTDIR/bin/
cp libmysql/$TARGET/libmysql.dll $DESTDIR/bin/
# FIXME really needed?!
diff --git a/sql-common/my_time.c b/sql-common/my_time.c
index 453c7b73008..ecc5aaf8af2 100644
--- a/sql-common/my_time.c
+++ b/sql-common/my_time.c
@@ -1108,9 +1108,14 @@ longlong number_to_datetime(longlong nr, MYSQL_TIME *time_res,
long part1,part2;
*was_cut= 0;
+ bzero((char*) time_res, sizeof(*time_res));
+ time_res->time_type=MYSQL_TIMESTAMP_DATE;
if (nr == LL(0) || nr >= LL(10000101000000))
+ {
+ time_res->time_type=MYSQL_TIMESTAMP_DATETIME;
goto ok;
+ }
if (nr < 101)
goto err;
if (nr <= (YY_PART_YEAR-1)*10000L+1231L)
@@ -1134,6 +1139,9 @@ longlong number_to_datetime(longlong nr, MYSQL_TIME *time_res,
}
if (nr < 101000000L)
goto err;
+
+ time_res->time_type=MYSQL_TIMESTAMP_DATETIME;
+
if (nr <= (YY_PART_YEAR-1)*LL(10000000000)+LL(1231235959))
{
nr= nr+LL(20000000000000); /* YYMMDDHHMMSS, 2000-2069 */
@@ -1147,7 +1155,6 @@ longlong number_to_datetime(longlong nr, MYSQL_TIME *time_res,
ok:
part1=(long) (nr/LL(1000000));
part2=(long) (nr - (longlong) part1*LL(1000000));
- bzero((char*) time_res, sizeof(*time_res));
time_res->year= (int) (part1/10000L); part1%=10000L;
time_res->month= (int) part1 / 100;
time_res->day= (int) part1 % 100;
diff --git a/sql/field.cc b/sql/field.cc
index 0a7c6a04f39..3f00b6750bc 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -5259,6 +5259,9 @@ void Field_date::sql_type(String &res) const
1 Value was cut during conversion
2 Wrong date string
3 Datetime value that was cut (warning level NOTE)
+ This is used by opt_range.cc:get_mm_leaf(). Note that there is a
+ nearly-identical class Field_date doesn't ever return 3 from its
+ store function.
*/
int Field_newdate::store(const char *from,uint len,CHARSET_INFO *cs)
diff --git a/sql/field.h b/sql/field.h
index 8c01931fa21..05c22092e53 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -25,6 +25,7 @@
#define NOT_FIXED_DEC 31
#define DATETIME_DEC 6
+const uint32 max_field_size= (uint32) 4294967295U;
class Send_field;
class Protocol;
diff --git a/sql/ha_blackhole.cc b/sql/ha_blackhole.cc
index 3f4285ec595..93d085bbc88 100644
--- a/sql/ha_blackhole.cc
+++ b/sql/ha_blackhole.cc
@@ -22,6 +22,14 @@
#ifdef HAVE_BLACKHOLE_DB
#include "ha_blackhole.h"
+/* Static declarations for shared structures */
+
+static pthread_mutex_t blackhole_mutex;
+static HASH blackhole_open_tables;
+static int blackhole_init= FALSE;
+
+static st_blackhole_share *get_share(const char *table_name);
+static void free_share(st_blackhole_share *share);
/* Blackhole storage engine handlerton */
@@ -30,7 +38,7 @@ handlerton blackhole_hton= {
SHOW_OPTION_YES,
"/dev/null storage engine (anything you write to it disappears)",
DB_TYPE_BLACKHOLE_DB,
- NULL,
+ blackhole_db_init,
0, /* slot */
0, /* savepoint size. */
NULL, /* close_connection */
@@ -70,15 +78,18 @@ const char **ha_blackhole::bas_ext() const
int ha_blackhole::open(const char *name, int mode, uint test_if_locked)
{
DBUG_ENTER("ha_blackhole::open");
- thr_lock_init(&thr_lock);
- thr_lock_data_init(&thr_lock,&lock,NULL);
+
+ if (!(share= get_share(name)))
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+
+ thr_lock_data_init(&share->lock, &lock, NULL);
DBUG_RETURN(0);
}
int ha_blackhole::close(void)
{
DBUG_ENTER("ha_blackhole::close");
- thr_lock_delete(&thr_lock);
+ free_share(share);
DBUG_RETURN(0);
}
@@ -161,17 +172,23 @@ int ha_blackhole::external_lock(THD *thd, int lock_type)
}
-uint ha_blackhole::lock_count(void) const
-{
- DBUG_ENTER("ha_blackhole::lock_count");
- DBUG_RETURN(0);
-}
-
THR_LOCK_DATA **ha_blackhole::store_lock(THD *thd,
THR_LOCK_DATA **to,
enum thr_lock_type lock_type)
{
DBUG_ENTER("ha_blackhole::store_lock");
+ if (lock_type != TL_IGNORE && lock.type == TL_UNLOCK)
+ {
+ if ((lock_type >= TL_WRITE_CONCURRENT_INSERT &&
+ lock_type <= TL_WRITE) && !thd->in_lock_tables)
+ lock_type = TL_WRITE_ALLOW_WRITE;
+
+ if (lock_type == TL_READ_NO_INSERT && !thd->in_lock_tables)
+ lock_type = TL_READ;
+
+ lock.type= lock_type;
+ }
+ *to++= &lock;
DBUG_RETURN(to);
}
@@ -226,4 +243,89 @@ int ha_blackhole::index_last(byte * buf)
DBUG_RETURN(HA_ERR_END_OF_FILE);
}
+
+static st_blackhole_share *get_share(const char *table_name)
+{
+ st_blackhole_share *share;
+ uint length;
+
+ length= (uint) strlen(table_name);
+ pthread_mutex_lock(&blackhole_mutex);
+
+ if (!(share= (st_blackhole_share*) hash_search(&blackhole_open_tables,
+ (byte*) table_name, length)))
+ {
+ if (!(share= (st_blackhole_share*) my_malloc(sizeof(st_blackhole_share) +
+ length,
+ MYF(MY_WME | MY_ZEROFILL))))
+ goto error;
+
+ share->table_name_length= length;
+ strmov(share->table_name, table_name);
+
+ if (my_hash_insert(&blackhole_open_tables, (byte*) share))
+ {
+ my_free((gptr) share, MYF(0));
+ share= NULL;
+ goto error;
+ }
+
+ thr_lock_init(&share->lock);
+ }
+ share->use_count++;
+
+error:
+ pthread_mutex_unlock(&blackhole_mutex);
+ return share;
+}
+
+static void free_share(st_blackhole_share *share)
+{
+ pthread_mutex_lock(&blackhole_mutex);
+ if (!--share->use_count)
+ hash_delete(&blackhole_open_tables, (byte*) share);
+ pthread_mutex_unlock(&blackhole_mutex);
+}
+
+
+static byte* blackhole_get_key(st_blackhole_share *share, uint *length,
+ my_bool not_used __attribute__((unused)))
+{
+ *length= share->table_name_length;
+ return (byte*) share->table_name;
+}
+
+
+bool blackhole_db_init()
+{
+ DBUG_ENTER("blackhole_db_init");
+ if (pthread_mutex_init(&blackhole_mutex, MY_MUTEX_INIT_FAST))
+ goto error;
+ if (hash_init(&blackhole_open_tables, &my_charset_bin, 32, 0, 0,
+ (hash_get_key) blackhole_get_key, 0, 0))
+ {
+ VOID(pthread_mutex_destroy(&blackhole_mutex));
+ }
+ else
+ {
+ blackhole_init= TRUE;
+ DBUG_RETURN(FALSE);
+ }
+error:
+ have_blackhole_db= SHOW_OPTION_DISABLED; // If we couldn't use handler
+ DBUG_RETURN(TRUE);
+}
+
+
+bool blackhole_db_end()
+{
+ if (blackhole_init)
+ {
+ hash_free(&blackhole_open_tables);
+ VOID(pthread_mutex_destroy(&blackhole_mutex));
+ }
+ blackhole_init= 0;
+ return FALSE;
+}
+
#endif /* HAVE_BLACKHOLE_DB */
diff --git a/sql/ha_blackhole.h b/sql/ha_blackhole.h
index 4dcb37c637d..45ed0351457 100644
--- a/sql/ha_blackhole.h
+++ b/sql/ha_blackhole.h
@@ -17,6 +17,18 @@
#pragma interface /* gcc class implementation */
#endif
+
+/*
+ Shared structure for correct LOCK operation
+*/
+struct st_blackhole_share {
+ THR_LOCK lock;
+ uint use_count;
+ uint table_name_length;
+ char table_name[1];
+};
+
+
/*
Class definition for the blackhole storage engine
"Dumbest named feature ever"
@@ -24,7 +36,7 @@
class ha_blackhole: public handler
{
THR_LOCK_DATA lock; /* MySQL lock */
- THR_LOCK thr_lock;
+ st_blackhole_share *share;
public:
ha_blackhole(TABLE *table_arg);
@@ -76,10 +88,12 @@ public:
void position(const byte *record);
int info(uint flag);
int external_lock(THD *thd, int lock_type);
- uint lock_count(void) const;
int create(const char *name, TABLE *table_arg,
HA_CREATE_INFO *create_info);
THR_LOCK_DATA **store_lock(THD *thd,
THR_LOCK_DATA **to,
enum thr_lock_type lock_type);
};
+
+bool blackhole_db_init(void);
+bool blackhole_db_end(void);
diff --git a/sql/ha_federated.cc b/sql/ha_federated.cc
index d7f2309657b..ac1e0962ffb 100644
--- a/sql/ha_federated.cc
+++ b/sql/ha_federated.cc
@@ -2166,6 +2166,24 @@ error:
}
+/*
+ This method is used exlusevely by filesort() to check if we
+ can create sorting buffers of necessary size.
+ If the handler returns more records that it declares
+ here server can just crash on filesort().
+ We cannot guarantee that's not going to happen with
+ the FEDERATED engine, as we have records==0 always if the
+ client is a VIEW, and for the table the number of
+ records can inpredictably change during execution.
+ So we return maximum possible value here.
+*/
+
+ha_rows ha_federated::estimate_rows_upper_bound()
+{
+ return HA_POS_ERROR;
+}
+
+
/* Initialized at each key walk (called multiple times unlike rnd_init()) */
int ha_federated::index_init(uint keynr)
diff --git a/sql/ha_federated.h b/sql/ha_federated.h
index dc4f976c578..349c596ae5a 100644
--- a/sql/ha_federated.h
+++ b/sql/ha_federated.h
@@ -277,6 +277,7 @@ public:
int update_row(const byte *old_data, byte *new_data);
int delete_row(const byte *buf);
int index_init(uint keynr);
+ ha_rows estimate_rows_upper_bound();
int index_read(byte *buf, const byte *key,
uint key_len, enum ha_rkey_function find_flag);
int index_read_idx(byte *buf, uint idx, const byte *key,
diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc
index a24486385fd..46afa7a8f45 100644
--- a/sql/ha_myisam.cc
+++ b/sql/ha_myisam.cc
@@ -1602,10 +1602,14 @@ int ha_myisam::index_next_same(byte * buf,
const byte *key __attribute__((unused)),
uint length __attribute__((unused)))
{
+ int error;
DBUG_ASSERT(inited==INDEX);
statistic_increment(table->in_use->status_var.ha_read_next_count,
- &LOCK_status);
- int error=mi_rnext_same(file,buf);
+ &LOCK_status);
+ do
+ {
+ error= mi_rnext_same(file,buf);
+ } while (error == HA_ERR_RECORD_DELETED);
table->status=error ? STATUS_NOT_FOUND: 0;
return error;
}
diff --git a/sql/ha_myisammrg.cc b/sql/ha_myisammrg.cc
index 60aa4bd6adc..78492d2843d 100644
--- a/sql/ha_myisammrg.cc
+++ b/sql/ha_myisammrg.cc
@@ -294,9 +294,13 @@ int ha_myisammrg::index_next_same(byte * buf,
const byte *key __attribute__((unused)),
uint length __attribute__((unused)))
{
+ int error;
statistic_increment(table->in_use->status_var.ha_read_next_count,
- &LOCK_status);
- int error=myrg_rnext_same(file,buf);
+ &LOCK_status);
+ do
+ {
+ error= myrg_rnext_same(file,buf);
+ } while (error == HA_ERR_RECORD_DELETED);
table->status=error ? STATUS_NOT_FOUND: 0;
return error;
}
diff --git a/sql/handler.cc b/sql/handler.cc
index bfb7e8c369f..27204ae725b 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -515,6 +515,10 @@ int ha_panic(enum ha_panic_function flag)
if (have_berkeley_db == SHOW_OPTION_YES)
error|=berkeley_end();
#endif
+#ifdef HAVE_BLACKHOLE_DB
+ if (have_blackhole_db == SHOW_OPTION_YES)
+ error|= blackhole_db_end();
+#endif
#ifdef HAVE_INNOBASE_DB
if (have_innodb == SHOW_OPTION_YES)
error|=innobase_end();
diff --git a/sql/item.cc b/sql/item.cc
index a75d0159848..975b517284f 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -1231,14 +1231,14 @@ bool Item_name_const::fix_fields(THD *thd, Item **ref)
s.length(0);
if (value_item->fix_fields(thd, &value_item) ||
- name_item->fix_fields(thd, &name_item))
- return TRUE;
- if (!(value_item->const_item() && name_item->const_item()))
+ name_item->fix_fields(thd, &name_item) ||
+ !value_item->const_item() ||
+ !name_item->const_item() ||
+ !(item_name= name_item->val_str(&s))) // Can't have a NULL name
+ {
+ my_error(ER_RESERVED_SYNTAX, MYF(0), "NAME_CONST");
return TRUE;
-
- if (!(item_name= name_item->val_str(&s)))
- return TRUE; /* Can't have a NULL name */
-
+ }
set_name(item_name->ptr(), (uint) item_name->length(), system_charset_info);
max_length= value_item->max_length;
decimals= value_item->decimals;
@@ -3651,7 +3651,7 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference)
}
/* Search in SELECT and GROUP lists of the outer select. */
- if (outer_context->resolve_in_select_list)
+ if (place != IN_WHERE && place != IN_ON)
{
if (!(ref= resolve_ref_in_select_and_group(thd, this, select)))
return -1; /* Some error occurred (e.g. ambiguous names). */
diff --git a/sql/item.h b/sql/item.h
index fbf4b94b276..5f511557f47 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -2454,8 +2454,18 @@ class Item_cache: public Item
protected:
Item *example;
table_map used_table_map;
+ /*
+ Field that this object will get value from. This is set/used by
+ index-based subquery engines to detect and remove the equality injected
+ by IN->EXISTS transformation.
+ For all other uses of Item_cache, cached_field doesn't matter.
+ */
+ Field *cached_field;
public:
- Item_cache(): example(0), used_table_map(0) {fixed= 1; null_value= 1;}
+ Item_cache(): example(0), used_table_map(0), cached_field(0)
+ {
+ fixed= 1; null_value= 1;
+ }
void set_used_tables(table_map map) { used_table_map= map; }
@@ -2467,6 +2477,8 @@ public:
decimals= item->decimals;
collation.set(item->collation);
unsigned_flag= item->unsigned_flag;
+ if (item->type() == FIELD_ITEM)
+ cached_field= ((Item_field *)item)->field;
return 0;
};
virtual void store(Item *)= 0;
@@ -2477,6 +2489,14 @@ public:
// to prevent drop fixed flag (no need parent cleanup call)
void cleanup() {}
void print(String *str);
+ bool eq_def(Field *field)
+ {
+ return cached_field ? cached_field->eq_def (field) : FALSE;
+ }
+ bool eq(const Item *item, bool binary_cmp) const
+ {
+ return this == item;
+ }
};
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index ee7a929024e..98bcb256138 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -24,7 +24,8 @@
#include <m_ctype.h>
#include "sql_select.h"
-static bool convert_constant_item(THD *thd, Field *field, Item **item);
+static bool convert_constant_item(THD *thd, Item_field *field_item,
+ Item **item);
static Item_result item_store_type(Item_result a, Item *item,
my_bool unsigned_flag)
@@ -317,7 +318,7 @@ longlong Item_func_nop_all::val_int()
SYNOPSIS
convert_constant_item()
thd thread handle
- field item will be converted using the type of this field
+ field_item item will be converted using the type of this field
item [in/out] reference to the item to convert
DESCRIPTION
@@ -340,29 +341,47 @@ longlong Item_func_nop_all::val_int()
1 Item was replaced with an integer version of the item
*/
-static bool convert_constant_item(THD *thd, Field *field, Item **item)
+static bool convert_constant_item(THD *thd, Item_field *field_item,
+ Item **item)
{
+ Field *field= field_item->field;
+ int result= 0;
+
if (!(*item)->with_subselect && (*item)->const_item())
{
/* For comparison purposes allow invalid dates like 2000-01-32 */
ulong orig_sql_mode= thd->variables.sql_mode;
enum_check_fields orig_count_cuted_fields= thd->count_cuted_fields;
+ ulonglong orig_field_val; /* original field value if valid */
+ LINT_INIT(orig_field_val);
thd->variables.sql_mode= (orig_sql_mode & ~MODE_NO_ZERO_DATE) |
MODE_INVALID_DATES;
thd->count_cuted_fields= CHECK_FIELD_IGNORE;
- if (!(*item)->save_in_field(field, 1) && !((*item)->null_value))
+ /*
+ Store the value of the field if it references an outer field because
+ the call to save_in_field below overrides that value.
+ */
+ if (field_item->depended_from)
+ orig_field_val= field->val_int();
+ if (!(*item)->is_null() && !(*item)->save_in_field(field, 1))
{
Item *tmp=new Item_int_with_ref(field->val_int(), *item,
test(field->flags & UNSIGNED_FLAG));
- thd->variables.sql_mode= orig_sql_mode;
if (tmp)
thd->change_item_tree(item, tmp);
- return 1; // Item was replaced
+ result= 1; // Item was replaced
+ }
+ /* Restore the original field value. */
+ if (field_item->depended_from)
+ {
+ result= field->store(orig_field_val, TRUE);
+ /* orig_field_val must be a valid value that can be restored back. */
+ DBUG_ASSERT(!result);
}
thd->variables.sql_mode= orig_sql_mode;
thd->count_cuted_fields= orig_count_cuted_fields;
}
- return 0;
+ return result;
}
@@ -410,15 +429,14 @@ void Item_bool_func2::fix_length_and_dec()
thd= current_thd;
if (!thd->is_context_analysis_only())
{
- Item *arg_real_item= args[0]->real_item();
- if (arg_real_item->type() == FIELD_ITEM)
+ if (args[0]->real_item()->type() == FIELD_ITEM)
{
- Field *field=((Item_field*) arg_real_item)->field;
- if (field->can_be_compared_as_longlong() &&
- !(arg_real_item->is_datetime() &&
+ Item_field *field_item= (Item_field*) (args[0]->real_item());
+ if (field_item->field->can_be_compared_as_longlong() &&
+ !(field_item->is_datetime() &&
args[1]->result_type() == STRING_RESULT))
{
- if (convert_constant_item(thd, field,&args[1]))
+ if (convert_constant_item(thd, field_item, &args[1]))
{
cmp.set_cmp_func(this, tmp_arg, tmp_arg+1,
INT_RESULT); // Works for all types.
@@ -427,15 +445,14 @@ void Item_bool_func2::fix_length_and_dec()
}
}
}
- arg_real_item= args[1]->real_item();
- if (arg_real_item->type() == FIELD_ITEM)
+ if (args[1]->real_item()->type() == FIELD_ITEM)
{
- Field *field=((Item_field*) arg_real_item)->field;
- if (field->can_be_compared_as_longlong() &&
- !(arg_real_item->is_datetime() &&
+ Item_field *field_item= (Item_field*) (args[1]->real_item());
+ if (field_item->field->can_be_compared_as_longlong() &&
+ !(field_item->is_datetime() &&
args[0]->result_type() == STRING_RESULT))
{
- if (convert_constant_item(thd, field,&args[0]))
+ if (convert_constant_item(thd, field_item, &args[0]))
{
cmp.set_cmp_func(this, tmp_arg, tmp_arg+1,
INT_RESULT); // Works for all types.
@@ -1901,16 +1918,16 @@ void Item_func_between::fix_length_and_dec()
thd->lex->sql_command != SQLCOM_CREATE_VIEW &&
thd->lex->sql_command != SQLCOM_SHOW_CREATE)
{
- Field *field=((Item_field*) (args[0]->real_item()))->field;
- if (field->can_be_compared_as_longlong())
+ Item_field *field_item= (Item_field*) (args[0]->real_item());
+ if (field_item->field->can_be_compared_as_longlong())
{
/*
The following can't be recoded with || as convert_constant_item
changes the argument
*/
- if (convert_constant_item(thd, field,&args[1]))
+ if (convert_constant_item(thd, field_item, &args[1]))
cmp_type=INT_RESULT; // Works for all types.
- if (convert_constant_item(thd, field,&args[2]))
+ if (convert_constant_item(thd, field_item, &args[2]))
cmp_type=INT_RESULT; // Works for all types.
}
}
@@ -3527,13 +3544,13 @@ void Item_func_in::fix_length_and_dec()
thd->lex->sql_command != SQLCOM_SHOW_CREATE &&
cmp_type != INT_RESULT)
{
- Field *field= ((Item_field*) (args[0]->real_item()))->field;
- if (field->can_be_compared_as_longlong())
+ Item_field *field_item= (Item_field*) (args[0]->real_item());
+ if (field_item->field->can_be_compared_as_longlong())
{
bool all_converted= TRUE;
for (arg=args+1, arg_end=args+arg_count; arg != arg_end ; arg++)
{
- if (!convert_constant_item (thd, field, &arg[0]))
+ if (!convert_constant_item (thd, field_item, &arg[0]))
all_converted= FALSE;
}
if (all_converted)
diff --git a/sql/item_func.cc b/sql/item_func.cc
index fa7821b589c..3a743037267 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -2968,6 +2968,12 @@ udf_handler::fix_fields(THD *thd, Item_result_field *func,
func->max_length=min(initid.max_length,MAX_BLOB_WIDTH);
func->maybe_null=initid.maybe_null;
const_item_cache=initid.const_item;
+ /*
+ Keep used_tables_cache in sync with const_item_cache.
+ See the comment in Item_udf_func::update_used tables.
+ */
+ if (!const_item_cache && !used_tables_cache)
+ used_tables_cache= RAND_TABLE_BIT;
func->decimals=min(initid.decimals,NOT_FIXED_DEC);
}
initialized=1;
@@ -4596,6 +4602,8 @@ void Item_func_get_user_var::fix_length_and_dec()
if (var_entry)
{
+ unsigned_flag= var_entry->unsigned_flag;
+
collation.set(var_entry->collation);
switch (var_entry->type) {
case REAL_RESULT:
diff --git a/sql/item_func.h b/sql/item_func.h
index a5e162f344f..940586fce01 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -1016,6 +1016,56 @@ public:
fixed= 1;
return res;
}
+ void update_used_tables()
+ {
+ /*
+ TODO: Make a member in UDF_INIT and return if a UDF is deterministic or
+ not.
+ Currently UDF_INIT has a member (const_item) that is an in/out
+ parameter to the init() call.
+ The code in udf_handler::fix_fields also duplicates the arguments
+ handling code in Item_func::fix_fields().
+
+ The lack of information if a UDF is deterministic makes writing
+ a correct update_used_tables() for UDFs impossible.
+ One solution to this would be :
+ - Add a is_deterministic member of UDF_INIT
+ - (optionally) deprecate the const_item member of UDF_INIT
+ - Take away the duplicate code from udf_handler::fix_fields() and
+ make Item_udf_func call Item_func::fix_fields() to process its
+ arguments as for any other function.
+ - Store the deterministic flag returned by <udf>_init into the
+ udf_handler.
+ - Don't implement Item_udf_func::fix_fields, implement
+ Item_udf_func::fix_length_and_dec() instead (similar to non-UDF
+ functions).
+ - Override Item_func::update_used_tables to call
+ Item_func::update_used_tables() and add a RAND_TABLE_BIT to the
+ result of Item_func::update_used_tables() if the UDF is
+ non-deterministic.
+ - (optionally) rename RAND_TABLE_BIT to NONDETERMINISTIC_BIT to
+ better describe its usage.
+
+ The above would require a change of the UDF API.
+ Until that change is done here's how the current code works:
+ We call Item_func::update_used_tables() only when we know that
+ the function depends on real non-const tables and is deterministic.
+ This can be done only because we know that the optimizer will
+ call update_used_tables() only when there's possibly a new const
+ table. So update_used_tables() can only make a Item_func more
+ constant than it is currently.
+ That's why we don't need to do anything if a function is guaranteed
+ to return non-constant (it's non-deterministic) or is already a
+ const.
+ */
+ if ((used_tables_cache & ~PSEUDO_TABLE_BITS) &&
+ !(used_tables_cache & RAND_TABLE_BIT))
+ {
+ Item_func::update_used_tables();
+ if (!const_item_cache && !used_tables_cache)
+ used_tables_cache= RAND_TABLE_BIT;
+ }
+ }
void cleanup();
Item_result result_type () const { return udf.result_type(); }
table_map not_null_tables() const { return 0; }
diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc
index 966cefea9fe..d088f68fc0c 100644
--- a/sql/item_geofunc.cc
+++ b/sql/item_geofunc.cc
@@ -34,7 +34,7 @@ void Item_geometry_func::fix_length_and_dec()
{
collation.set(&my_charset_bin);
decimals=0;
- max_length=MAX_BLOB_WIDTH;
+ max_length= max_field_size;
maybe_null= 1;
}
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index 57c3b391507..b3710841dfb 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -1800,7 +1800,9 @@ int subselect_single_select_engine::exec()
DBUG_RETURN(1);
}
}
- if (select_lex->uncacheable && executed)
+ if (select_lex->uncacheable &&
+ select_lex->uncacheable != UNCACHEABLE_EXPLAIN
+ && executed)
{
if (join->reinit())
{
diff --git a/sql/key.cc b/sql/key.cc
index 2bdde46b6b3..1c044f3dc7d 100644
--- a/sql/key.cc
+++ b/sql/key.cc
@@ -106,19 +106,6 @@ void key_copy(byte *to_key, byte *from_record, KEY *key_info, uint key_length)
key_part->null_bit);
key_length--;
}
- if (key_part->type == HA_KEYTYPE_BIT)
- {
- Field_bit *field= (Field_bit *) (key_part->field);
- if (field->bit_len)
- {
- uchar bits= get_rec_bits((uchar*) from_record +
- key_part->null_offset +
- (key_part->null_bit == 128),
- field->bit_ofs, field->bit_len);
- *to_key++= bits;
- key_length--;
- }
- }
if (key_part->key_part_flag & HA_BLOB_PART ||
key_part->key_part_flag & HA_VAR_LENGTH_PART)
{
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 47396748da6..4334dedfe4e 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -186,7 +186,7 @@ MY_LOCALE *my_locale_by_number(uint number);
#define QUERY_ALLOC_PREALLOC_SIZE 8192
#define TRANS_ALLOC_BLOCK_SIZE 4096
#define TRANS_ALLOC_PREALLOC_SIZE 4096
-#define RANGE_ALLOC_BLOCK_SIZE 2048
+#define RANGE_ALLOC_BLOCK_SIZE 4096
#define ACL_ALLOC_BLOCK_SIZE 1024
#define UDF_ALLOC_BLOCK_SIZE 1024
#define TABLE_ALLOC_BLOCK_SIZE 1024
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 2e1b56431a4..6a814219662 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -184,7 +184,7 @@ typedef fp_except fp_except_t;
this on freebsd
*/
-inline void reset_floating_point_exceptions()
+inline void set_proper_floating_point_mode()
{
/* Don't fall for overflow, underflow,divide-by-zero or loss of precision */
#if defined(__i386__)
@@ -195,8 +195,22 @@ inline void reset_floating_point_exceptions()
FP_X_IMP));
#endif
}
+#elif defined(__sgi)
+/* for IRIX to use set_fpc_csr() */
+#include <sys/fpu.h>
+
+inline void set_proper_floating_point_mode()
+{
+ /* Enable denormalized DOUBLE values support for IRIX */
+ {
+ union fpc_csr n;
+ n.fc_word = get_fpc_csr();
+ n.fc_struct.flush = 0;
+ set_fpc_csr(n.fc_word);
+ }
+}
#else
-#define reset_floating_point_exceptions()
+#define set_proper_floating_point_mode()
#endif /* __FreeBSD__ && HAVE_IEEEFP_H */
} /* cplusplus */
@@ -3129,7 +3143,7 @@ static int init_server_components()
query_cache_init();
query_cache_resize(query_cache_size);
randominit(&sql_rand,(ulong) server_start_time,(ulong) server_start_time/2);
- reset_floating_point_exceptions();
+ set_proper_floating_point_mode();
init_thr_lock();
#ifdef HAVE_REPLICATION
init_slave_list();
@@ -4967,7 +4981,7 @@ Disable with --skip-bdb (will save memory).",
{"concurrent-insert", OPT_CONCURRENT_INSERT,
"Use concurrent insert with MyISAM. Disable with --concurrent-insert=0",
(gptr*) &myisam_concurrent_insert, (gptr*) &myisam_concurrent_insert,
- 0, GET_LONG, OPT_ARG, 1, 0, 2, 0, 0, 0},
+ 0, GET_ULONG, OPT_ARG, 1, 0, 2, 0, 0, 0},
{"console", OPT_CONSOLE, "Write error output on screen; Don't remove the console window on windows.",
(gptr*) &opt_console, (gptr*) &opt_console, 0, GET_BOOL, NO_ARG, 0, 0, 0,
0, 0, 0},
@@ -5136,7 +5150,7 @@ Disable with --skip-innodb-doublewrite.", (gptr*) &innobase_use_doublewrite,
{"innodb_max_purge_lag", OPT_INNODB_MAX_PURGE_LAG,
"Desired maximum length of the purge queue (0 = no limit)",
(gptr*) &srv_max_purge_lag,
- (gptr*) &srv_max_purge_lag, 0, GET_LONG, REQUIRED_ARG, 0, 0, ~0L,
+ (gptr*) &srv_max_purge_lag, 0, GET_ULONG, REQUIRED_ARG, 0, 0, ULONG_MAX,
0, 1L, 0},
{"innodb_rollback_on_timeout", OPT_INNODB_ROLLBACK_ON_TIMEOUT,
"Roll back the complete transaction on lock wait timeout, for 4.x compatibility (disabled by default)",
@@ -5246,7 +5260,8 @@ Disable with --skip-innodb-doublewrite.", (gptr*) &innobase_use_doublewrite,
#ifdef HAVE_MMAP
{"log-tc-size", OPT_LOG_TC_SIZE, "Size of transaction coordinator log.",
(gptr*) &opt_tc_log_size, (gptr*) &opt_tc_log_size, 0, GET_ULONG,
- REQUIRED_ARG, TC_LOG_MIN_SIZE, TC_LOG_MIN_SIZE, ~0L, 0, TC_LOG_PAGE_SIZE, 0},
+ REQUIRED_ARG, TC_LOG_MIN_SIZE, TC_LOG_MIN_SIZE, ULONG_MAX, 0,
+ TC_LOG_PAGE_SIZE, 0},
#endif
{"log-update", OPT_UPDATE_LOG,
"The update log is deprecated since version 5.0, is replaced by the binary \
@@ -5669,8 +5684,8 @@ log and this option does nothing anymore.",
NO_ARG, 0, 0, 0, 0, 0, 0},
{"warnings", 'W', "Deprecated; use --log-warnings instead.",
(gptr*) &global_system_variables.log_warnings,
- (gptr*) &max_system_variables.log_warnings, 0, GET_ULONG, OPT_ARG, 1, 0, ~0L,
- 0, 0, 0},
+ (gptr*) &max_system_variables.log_warnings, 0, GET_ULONG, OPT_ARG,
+ 1, 0, ULONG_MAX, 0, 0, 0},
{ "back_log", OPT_BACK_LOG,
"The number of outstanding connection requests MySQL can have. This comes into play when the main MySQL thread gets very many connection requests in a very short time.",
(gptr*) &back_log, (gptr*) &back_log, 0, GET_ULONG,
@@ -5679,29 +5694,29 @@ log and this option does nothing anymore.",
{ "bdb_cache_size", OPT_BDB_CACHE_SIZE,
"The buffer that is allocated to cache index and rows for BDB tables.",
(gptr*) &berkeley_cache_size, (gptr*) &berkeley_cache_size, 0, GET_ULONG,
- REQUIRED_ARG, KEY_CACHE_SIZE, 20*1024, (long) ~0, 0, IO_SIZE, 0},
+ REQUIRED_ARG, KEY_CACHE_SIZE, 20*1024, ULONG_MAX, 0, IO_SIZE, 0},
/* QQ: The following should be removed soon! (bdb_max_lock preferred) */
{"bdb_lock_max", OPT_BDB_MAX_LOCK, "Synonym for bdb_max_lock.",
(gptr*) &berkeley_max_lock, (gptr*) &berkeley_max_lock, 0, GET_ULONG,
- REQUIRED_ARG, 10000, 0, (long) ~0, 0, 1, 0},
+ REQUIRED_ARG, 10000, 0, ULONG_MAX, 0, 1, 0},
{"bdb_log_buffer_size", OPT_BDB_LOG_BUFFER_SIZE,
"The buffer that is allocated to cache index and rows for BDB tables.",
(gptr*) &berkeley_log_buffer_size, (gptr*) &berkeley_log_buffer_size, 0,
- GET_ULONG, REQUIRED_ARG, 0, 256*1024L, ~0L, 0, 1024, 0},
+ GET_ULONG, REQUIRED_ARG, 256*1024L, 256*1024L, ULONG_MAX, 0, 1024, 0},
{"bdb_max_lock", OPT_BDB_MAX_LOCK,
"The maximum number of locks you can have active on a BDB table.",
(gptr*) &berkeley_max_lock, (gptr*) &berkeley_max_lock, 0, GET_ULONG,
- REQUIRED_ARG, 10000, 0, (long) ~0, 0, 1, 0},
+ REQUIRED_ARG, 10000, 0, ULONG_MAX, 0, 1, 0},
#endif /* HAVE_BERKELEY_DB */
{"binlog_cache_size", OPT_BINLOG_CACHE_SIZE,
"The size of the cache to hold the SQL statements for the binary log during a transaction. If you often use big, multi-statement transactions you can increase this to get more performance.",
(gptr*) &binlog_cache_size, (gptr*) &binlog_cache_size, 0, GET_ULONG,
- REQUIRED_ARG, 32*1024L, IO_SIZE, ~0L, 0, IO_SIZE, 0},
+ REQUIRED_ARG, 32*1024L, IO_SIZE, ULONG_MAX, 0, IO_SIZE, 0},
{"bulk_insert_buffer_size", OPT_BULK_INSERT_BUFFER_SIZE,
"Size of tree cache used in bulk insert optimisation. Note that this is a limit per thread!",
(gptr*) &global_system_variables.bulk_insert_buff_size,
(gptr*) &max_system_variables.bulk_insert_buff_size,
- 0, GET_ULONG, REQUIRED_ARG, 8192*1024, 0, ~0L, 0, 1, 0},
+ 0, GET_ULONG, REQUIRED_ARG, 8192*1024, 0, ULONG_MAX, 0, 1, 0},
{"connect_timeout", OPT_CONNECT_TIMEOUT,
"The number of seconds the mysqld server is waiting for a connect packet before responding with 'Bad handshake'.",
(gptr*) &connect_timeout, (gptr*) &connect_timeout,
@@ -5724,7 +5739,7 @@ log and this option does nothing anymore.",
{"delayed_insert_limit", OPT_DELAYED_INSERT_LIMIT,
"After inserting delayed_insert_limit rows, the INSERT DELAYED handler will check if there are any SELECT statements pending. If so, it allows these to execute before continuing.",
(gptr*) &delayed_insert_limit, (gptr*) &delayed_insert_limit, 0, GET_ULONG,
- REQUIRED_ARG, DELAYED_LIMIT, 1, ~0L, 0, 1, 0},
+ REQUIRED_ARG, DELAYED_LIMIT, 1, ULONG_MAX, 0, 1, 0},
{"delayed_insert_timeout", OPT_DELAYED_INSERT_TIMEOUT,
"How long a INSERT DELAYED thread should wait for INSERT statements before terminating.",
(gptr*) &delayed_insert_timeout, (gptr*) &delayed_insert_timeout, 0,
@@ -5732,7 +5747,7 @@ log and this option does nothing anymore.",
{ "delayed_queue_size", OPT_DELAYED_QUEUE_SIZE,
"What size queue (in rows) should be allocated for handling INSERT DELAYED. If the queue becomes full, any client that does INSERT DELAYED will wait until there is room in the queue again.",
(gptr*) &delayed_queue_size, (gptr*) &delayed_queue_size, 0, GET_ULONG,
- REQUIRED_ARG, DELAYED_QUEUE_SIZE, 1, ~0L, 0, 1, 0},
+ REQUIRED_ARG, DELAYED_QUEUE_SIZE, 1, ULONG_MAX, 0, 1, 0},
{"div_precision_increment", OPT_DIV_PRECINCREMENT,
"Precision of the result of '/' operator will be increased on that value.",
(gptr*) &global_system_variables.div_precincrement,
@@ -5769,16 +5784,16 @@ log and this option does nothing anymore.",
(gptr*) &ft_stopword_file, (gptr*) &ft_stopword_file, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{ "group_concat_max_len", OPT_GROUP_CONCAT_MAX_LEN,
- "The maximum length of the result of function group_concat.",
+ "The maximum length of the result of function group_concat.",
(gptr*) &global_system_variables.group_concat_max_len,
(gptr*) &max_system_variables.group_concat_max_len, 0, GET_ULONG,
- REQUIRED_ARG, 1024, 4, (long) ~0, 0, 1, 0},
+ REQUIRED_ARG, 1024, 4, ULONG_MAX, 0, 1, 0},
#ifdef HAVE_INNOBASE_DB
{"innodb_additional_mem_pool_size", OPT_INNODB_ADDITIONAL_MEM_POOL_SIZE,
"Size of a memory pool InnoDB uses to store data dictionary information and other internal data structures.",
(gptr*) &innobase_additional_mem_pool_size,
(gptr*) &innobase_additional_mem_pool_size, 0, GET_LONG, REQUIRED_ARG,
- 1*1024*1024L, 512*1024L, ~0L, 0, 1024, 0},
+ 1*1024*1024L, 512*1024L, LONG_MAX, 0, 1024, 0},
{"innodb_autoextend_increment", OPT_INNODB_AUTOEXTEND_INCREMENT,
"Data file autoextend increment in megabytes",
(gptr*) &srv_auto_extend_increment,
@@ -5802,7 +5817,7 @@ log and this option does nothing anymore.",
SQL query after it has once got the ticket",
(gptr*) &srv_n_free_tickets_to_enter,
(gptr*) &srv_n_free_tickets_to_enter,
- 0, GET_LONG, REQUIRED_ARG, 500L, 1L, ~0L, 0, 1L, 0},
+ 0, GET_ULONG, REQUIRED_ARG, 500L, 1L, ULONG_MAX, 0, 1L, 0},
{"innodb_file_io_threads", OPT_INNODB_FILE_IO_THREADS,
"Number of file I/O threads in InnoDB.", (gptr*) &innobase_file_io_threads,
(gptr*) &innobase_file_io_threads, 0, GET_LONG, REQUIRED_ARG, 4, 4, 64, 0,
@@ -5818,7 +5833,7 @@ log and this option does nothing anymore.",
{"innodb_log_buffer_size", OPT_INNODB_LOG_BUFFER_SIZE,
"The size of the buffer which InnoDB uses to write log to the log files on disk.",
(gptr*) &innobase_log_buffer_size, (gptr*) &innobase_log_buffer_size, 0,
- GET_LONG, REQUIRED_ARG, 1024*1024L, 256*1024L, ~0L, 0, 1024, 0},
+ GET_LONG, REQUIRED_ARG, 1024*1024L, 256*1024L, LONG_MAX, 0, 1024, 0},
{"innodb_log_file_size", OPT_INNODB_LOG_FILE_SIZE,
"Size of each log file in a log group.",
(gptr*) &innobase_log_file_size, (gptr*) &innobase_log_file_size, 0,
@@ -5836,24 +5851,24 @@ log and this option does nothing anymore.",
{"innodb_open_files", OPT_INNODB_OPEN_FILES,
"How many files at the maximum InnoDB keeps open at the same time.",
(gptr*) &innobase_open_files, (gptr*) &innobase_open_files, 0,
- GET_LONG, REQUIRED_ARG, 300L, 10L, ~0L, 0, 1L, 0},
+ GET_LONG, REQUIRED_ARG, 300L, 10L, LONG_MAX, 0, 1L, 0},
{"innodb_sync_spin_loops", OPT_INNODB_SYNC_SPIN_LOOPS,
"Count of spin-loop rounds in InnoDB mutexes",
(gptr*) &srv_n_spin_wait_rounds,
(gptr*) &srv_n_spin_wait_rounds,
- 0, GET_LONG, REQUIRED_ARG, 20L, 0L, ~0L, 0, 1L, 0},
+ 0, GET_ULONG, REQUIRED_ARG, 20L, 0L, ULONG_MAX, 0, 1L, 0},
{"innodb_thread_concurrency", OPT_INNODB_THREAD_CONCURRENCY,
"Helps in performance tuning in heavily concurrent environments. "
"Sets the maximum number of threads allowed inside InnoDB. Value 0"
" will disable the thread throttling.",
(gptr*) &srv_thread_concurrency, (gptr*) &srv_thread_concurrency,
- 0, GET_LONG, REQUIRED_ARG, 8, 0, 1000, 0, 1, 0},
+ 0, GET_ULONG, REQUIRED_ARG, 8, 0, 1000, 0, 1, 0},
{"innodb_thread_sleep_delay", OPT_INNODB_THREAD_SLEEP_DELAY,
"Time of innodb thread sleeping before joining InnoDB queue (usec). Value 0"
" disable a sleep",
(gptr*) &srv_thread_sleep_delay,
(gptr*) &srv_thread_sleep_delay,
- 0, GET_LONG, REQUIRED_ARG, 10000L, 0L, ~0L, 0, 1L, 0},
+ 0, GET_ULONG, REQUIRED_ARG, 10000L, 0L, ULONG_MAX, 0, 1L, 0},
#endif /* HAVE_INNOBASE_DB */
{"interactive_timeout", OPT_INTERACTIVE_TIMEOUT,
"The number of seconds the server waits for activity on an interactive connection before closing it.",
@@ -5883,7 +5898,7 @@ log and this option does nothing anymore.",
(gptr*) &dflt_key_cache_var.param_age_threshold,
(gptr*) 0,
0, (GET_ULONG | GET_ASK_ADDR), REQUIRED_ARG,
- 300, 100, ~0L, 0, 100, 0},
+ 300, 100, ULONG_MAX, 0, 100, 0},
{"key_cache_block_size", OPT_KEY_CACHE_BLOCK_SIZE,
"The default size of key cache blocks",
(gptr*) &dflt_key_cache_var.param_block_size,
@@ -5919,7 +5934,7 @@ log and this option does nothing anymore.",
{"max_binlog_cache_size", OPT_MAX_BINLOG_CACHE_SIZE,
"Can be used to restrict the total size used to cache a multi-transaction query.",
(gptr*) &max_binlog_cache_size, (gptr*) &max_binlog_cache_size, 0,
- GET_ULONG, REQUIRED_ARG, ~0L, IO_SIZE, ~0L, 0, IO_SIZE, 0},
+ GET_ULONG, REQUIRED_ARG, ULONG_MAX, IO_SIZE, ULONG_MAX, 0, IO_SIZE, 0},
{"max_binlog_size", OPT_MAX_BINLOG_SIZE,
"Binary log will be rotated automatically when the size exceeds this \
value. Will also apply to relay logs if max_relay_log_size is 0. \
@@ -5929,7 +5944,7 @@ The minimum value for this variable is 4096.",
{"max_connect_errors", OPT_MAX_CONNECT_ERRORS,
"If there is more than this number of interrupted connections from a host this host will be blocked from further connections.",
(gptr*) &max_connect_errors, (gptr*) &max_connect_errors, 0, GET_ULONG,
- REQUIRED_ARG, MAX_CONNECT_ERRORS, 1, ~0L, 0, 1, 0},
+ REQUIRED_ARG, MAX_CONNECT_ERRORS, 1, ULONG_MAX, 0, 1, 0},
{"max_connections", OPT_MAX_CONNECTIONS,
"The number of simultaneous clients allowed.", (gptr*) &max_connections,
(gptr*) &max_connections, 0, GET_ULONG, REQUIRED_ARG, 100, 1, 16384, 0, 1,
@@ -5972,7 +5987,7 @@ The minimum value for this variable is 4096.",
"Limit assumed max number of seeks when looking up rows based on a key",
(gptr*) &global_system_variables.max_seeks_for_key,
(gptr*) &max_system_variables.max_seeks_for_key, 0, GET_ULONG,
- REQUIRED_ARG, ~0L, 1, ~0L, 0, 1, 0 },
+ REQUIRED_ARG, ULONG_MAX, 1, ULONG_MAX, 0, 1, 0 },
{"max_sort_length", OPT_MAX_SORT_LENGTH,
"The number of bytes to use when sorting BLOB or TEXT values (only the first max_sort_length bytes of each value are used; the rest are ignored).",
(gptr*) &global_system_variables.max_sort_length,
@@ -5987,20 +6002,20 @@ The minimum value for this variable is 4096.",
"Maximum number of temporary tables a client can keep open at a time.",
(gptr*) &global_system_variables.max_tmp_tables,
(gptr*) &max_system_variables.max_tmp_tables, 0, GET_ULONG,
- REQUIRED_ARG, 32, 1, ~0L, 0, 1, 0},
+ REQUIRED_ARG, 32, 1, ULONG_MAX, 0, 1, 0},
{"max_user_connections", OPT_MAX_USER_CONNECTIONS,
"The maximum number of active connections for a single user (0 = no limit).",
(gptr*) &max_user_connections, (gptr*) &max_user_connections, 0, GET_UINT,
- REQUIRED_ARG, 0, 1, ~0, 0, 1, 0},
+ REQUIRED_ARG, 0, 0, (uint) ~0, 0, 1, 0},
{"max_write_lock_count", OPT_MAX_WRITE_LOCK_COUNT,
"After this many write locks, allow some read locks to run in between.",
(gptr*) &max_write_lock_count, (gptr*) &max_write_lock_count, 0, GET_ULONG,
- REQUIRED_ARG, ~0L, 1, ~0L, 0, 1, 0},
+ REQUIRED_ARG, ULONG_MAX, 1, ULONG_MAX, 0, 1, 0},
{"multi_range_count", OPT_MULTI_RANGE_COUNT,
"Number of key ranges to request at once.",
(gptr*) &global_system_variables.multi_range_count,
(gptr*) &max_system_variables.multi_range_count, 0,
- GET_ULONG, REQUIRED_ARG, 256, 1, ~0L, 0, 1, 0},
+ GET_ULONG, REQUIRED_ARG, 256, 1, ULONG_MAX, 0, 1, 0},
{"myisam_block_size", OPT_MYISAM_BLOCK_SIZE,
"Block size to be used for MyISAM index pages.",
(gptr*) &opt_myisam_block_size,
@@ -6028,7 +6043,7 @@ The minimum value for this variable is 4096.",
"Number of threads to use when repairing MyISAM tables. The value of 1 disables parallel repair.",
(gptr*) &global_system_variables.myisam_repair_threads,
(gptr*) &max_system_variables.myisam_repair_threads, 0,
- GET_ULONG, REQUIRED_ARG, 1, 1, ~0L, 0, 1, 0},
+ GET_ULONG, REQUIRED_ARG, 1, 1, ULONG_MAX, 0, 1, 0},
{"myisam_sort_buffer_size", OPT_MYISAM_SORT_BUFFER_SIZE,
"The buffer that is allocated when sorting the index when doing a REPAIR or when creating indexes with CREATE INDEX or ALTER TABLE.",
(gptr*) &global_system_variables.myisam_sort_buff_size,
@@ -6054,7 +6069,7 @@ The minimum value for this variable is 4096.",
"If a read on a communication port is interrupted, retry this many times before giving up.",
(gptr*) &global_system_variables.net_retry_count,
(gptr*) &max_system_variables.net_retry_count,0,
- GET_ULONG, REQUIRED_ARG, MYSQLD_NET_RETRY_COUNT, 1, ~0L, 0, 1, 0},
+ GET_ULONG, REQUIRED_ARG, MYSQLD_NET_RETRY_COUNT, 1, ULONG_MAX, 0, 1, 0},
{"net_write_timeout", OPT_NET_WRITE_TIMEOUT,
"Number of seconds to wait for a block to be written to a connection before aborting the write.",
(gptr*) &global_system_variables.net_write_timeout,
@@ -6083,7 +6098,7 @@ The minimum value for this variable is 4096.",
"Allocation block size for query parsing and execution",
(gptr*) &global_system_variables.query_alloc_block_size,
(gptr*) &max_system_variables.query_alloc_block_size, 0, GET_ULONG,
- REQUIRED_ARG, QUERY_ALLOC_BLOCK_SIZE, 1024, ~0L, 0, 1024, 0},
+ REQUIRED_ARG, QUERY_ALLOC_BLOCK_SIZE, 1024, ULONG_MAX, 0, 1024, 0},
#ifdef HAVE_QUERY_CACHE
{"query_cache_limit", OPT_QUERY_CACHE_LIMIT,
"Don't cache results that are bigger than this.",
@@ -6116,12 +6131,13 @@ The minimum value for this variable is 4096.",
(gptr*) &global_system_variables.query_prealloc_size,
(gptr*) &max_system_variables.query_prealloc_size, 0, GET_ULONG,
REQUIRED_ARG, QUERY_ALLOC_PREALLOC_SIZE, QUERY_ALLOC_PREALLOC_SIZE,
- ~0L, 0, 1024, 0},
+ ULONG_MAX, 0, 1024, 0},
{"range_alloc_block_size", OPT_RANGE_ALLOC_BLOCK_SIZE,
"Allocation block size for storing ranges during optimization",
(gptr*) &global_system_variables.range_alloc_block_size,
(gptr*) &max_system_variables.range_alloc_block_size, 0, GET_ULONG,
- REQUIRED_ARG, RANGE_ALLOC_BLOCK_SIZE, 4096, ~0L, 0, 1024, 0},
+ REQUIRED_ARG, RANGE_ALLOC_BLOCK_SIZE, RANGE_ALLOC_BLOCK_SIZE, ULONG_MAX,
+ 0, 1024, 0},
{"read_buffer_size", OPT_RECORD_BUFFER,
"Each thread that does a sequential scan allocates a buffer of this size for each table it scans. If you do many sequential scans, you may want to increase this value.",
(gptr*) &global_system_variables.read_buff_size,
@@ -6191,7 +6207,7 @@ The minimum value for this variable is 4096.",
"Synchronously flush binary log to disk after every #th event. "
"Use 0 (default) to disable synchronous flushing.",
(gptr*) &sync_binlog_period, (gptr*) &sync_binlog_period, 0, GET_ULONG,
- REQUIRED_ARG, 0, 0, ~0L, 0, 1, 0},
+ REQUIRED_ARG, 0, 0, ULONG_MAX, 0, 1, 0},
{"sync-frm", OPT_SYNC_FRM, "Sync .frm to disk on create. Enabled by default.",
(gptr*) &opt_sync_frm, (gptr*) &opt_sync_frm, 0, GET_BOOL, NO_ARG, 1, 0,
0, 0, 0, 0},
@@ -6215,7 +6231,7 @@ The minimum value for this variable is 4096.",
{"thread_stack", OPT_THREAD_STACK,
"The stack size for each thread.", (gptr*) &thread_stack,
(gptr*) &thread_stack, 0, GET_ULONG, REQUIRED_ARG,DEFAULT_THREAD_STACK,
- 1024L*128L, ~0L, 0, 1024, 0},
+ 1024L*128L, ULONG_MAX, 0, 1024, 0},
{ "time_format", OPT_TIME_FORMAT,
"The TIME format (for future).",
(gptr*) &opt_date_time_formats[MYSQL_TIMESTAMP_TIME],
@@ -6231,12 +6247,12 @@ The minimum value for this variable is 4096.",
"Allocation block size for various transaction-related structures",
(gptr*) &global_system_variables.trans_alloc_block_size,
(gptr*) &max_system_variables.trans_alloc_block_size, 0, GET_ULONG,
- REQUIRED_ARG, QUERY_ALLOC_BLOCK_SIZE, 1024, ~0L, 0, 1024, 0},
+ REQUIRED_ARG, QUERY_ALLOC_BLOCK_SIZE, 1024, ULONG_MAX, 0, 1024, 0},
{"transaction_prealloc_size", OPT_TRANS_PREALLOC_SIZE,
"Persistent buffer for various transaction-related structures",
(gptr*) &global_system_variables.trans_prealloc_size,
(gptr*) &max_system_variables.trans_prealloc_size, 0, GET_ULONG,
- REQUIRED_ARG, TRANS_ALLOC_PREALLOC_SIZE, 1024, ~0L, 0, 1024, 0},
+ REQUIRED_ARG, TRANS_ALLOC_PREALLOC_SIZE, 1024, ULONG_MAX, 0, 1024, 0},
{"updatable_views_with_limit", OPT_UPDATABLE_VIEWS_WITH_LIMIT,
"1 = YES = Don't issue an error message (warning only) if a VIEW without presence of a key of the underlying table is used in queries with a LIMIT clause for updating. 0 = NO = Prohibit update of a VIEW, which does not contain a key of the underlying table and the query uses a LIMIT clause (usually get from GUI tools).",
(gptr*) &global_system_variables.updatable_views_with_limit,
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index facc8e09c27..a8cf0f67635 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -250,6 +250,9 @@ public:
Field *field;
char *min_value,*max_value; // Pointer to range
+ /*
+ eq_tree() requires that left == right == 0 if the type is MAYBE_KEY.
+ */
SEL_ARG *left,*right; /* R-B tree children */
SEL_ARG *next,*prev; /* Links for bi-directional interval list */
SEL_ARG *parent; /* R-B tree parent */
@@ -265,7 +268,7 @@ public:
SEL_ARG(Field *field, uint8 part, char *min_value, char *max_value,
uint8 min_flag, uint8 max_flag, uint8 maybe_flag);
SEL_ARG(enum Type type_arg)
- :min_flag(0),elements(1),use_count(1),left(0),next_key_part(0),
+ :min_flag(0),elements(1),use_count(1),left(0),right(0),next_key_part(0),
color(BLACK), type(type_arg)
{}
inline bool is_same(SEL_ARG *arg)
@@ -1978,12 +1981,18 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use,
keys_to_use.intersect(head->keys_in_use_for_query);
if (!keys_to_use.is_clear_all())
{
+#ifndef EMBEDDED_LIBRARY // Avoid compiler warning
+ char buff[STACK_BUFF_ALLOC];
+#endif
MEM_ROOT alloc;
SEL_TREE *tree= NULL;
KEY_PART *key_parts;
KEY *key_info;
PARAM param;
+ if (check_stack_overrun(thd, 2*STACK_MIN_SIZE, buff))
+ DBUG_RETURN(0); // Fatal error flag is set
+
/* set up parameter that is passed to all functions */
param.thd= thd;
param.baseflag=head->file->table_flags();
@@ -4405,6 +4414,7 @@ get_mm_leaf(PARAM *param, COND *conf_func, Field *field, KEY_PART *key_part,
{
tree= new (alloc) SEL_ARG(field, 0, 0);
tree->type= SEL_ARG::IMPOSSIBLE;
+ goto end;
}
else
{
@@ -4413,8 +4423,32 @@ get_mm_leaf(PARAM *param, COND *conf_func, Field *field, KEY_PART *key_part,
for the cases like int_field > 999999999999999999999999 as well.
*/
tree= 0;
+ if (err == 3 && field->type() == FIELD_TYPE_DATE &&
+ (type == Item_func::GT_FUNC || type == Item_func::GE_FUNC ||
+ type == Item_func::LT_FUNC || type == Item_func::LE_FUNC) )
+ {
+ /*
+ We were saving DATETIME into a DATE column, the conversion went ok
+ but a non-zero time part was cut off.
+
+ In MySQL's SQL dialect, DATE and DATETIME are compared as datetime
+ values. Index over a DATE column uses DATE comparison. Changing
+ from one comparison to the other is possible:
+
+ datetime(date_col)< '2007-12-10 12:34:55' -> date_col<='2007-12-10'
+ datetime(date_col)<='2007-12-10 12:34:55' -> date_col<='2007-12-10'
+
+ datetime(date_col)> '2007-12-10 12:34:55' -> date_col>='2007-12-10'
+ datetime(date_col)>='2007-12-10 12:34:55' -> date_col>='2007-12-10'
+
+ but we'll need to convert '>' to '>=' and '<' to '<='. This will
+ be done together with other types at the end of this function
+ (grep for field_is_equal_to_item)
+ */
+ }
+ else
+ goto end;
}
- goto end;
}
if (err < 0)
{
diff --git a/sql/protocol.cc b/sql/protocol.cc
index 2bdbe83eea1..ff58d96f59b 100644
--- a/sql/protocol.cc
+++ b/sql/protocol.cc
@@ -110,13 +110,14 @@ void net_send_error(THD *thd, uint sql_errno, const char *err)
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, sql_errno, err);
}
+ /* Abort multi-result sets */
+ thd->server_status&= ~SERVER_MORE_RESULTS_EXISTS;
+
net_send_error_packet(thd, sql_errno, err);
thd->is_fatal_error=0; // Error message is given
thd->net.report_error= 0;
- /* Abort multi-result sets */
- thd->server_status&= ~SERVER_MORE_RESULTS_EXISTS;
DBUG_VOID_RETURN;
}
@@ -409,7 +410,10 @@ void net_send_error_packet(THD *thd, uint sql_errno, const char *err)
{
NET *net= &thd->net;
uint length;
- char buff[MYSQL_ERRMSG_SIZE+2], *pos;
+ /*
+ buff[]: sql_errno:2 + ('#':1 + SQLSTATE_LENGTH:5) + MYSQL_ERRMSG_SIZE:512
+ */
+ char buff[2+1+SQLSTATE_LENGTH+MYSQL_ERRMSG_SIZE], *pos;
DBUG_ENTER("send_error_packet");
diff --git a/sql/set_var.cc b/sql/set_var.cc
index 1f88509d1b6..d0362edaa29 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -113,6 +113,10 @@ static int check_max_delayed_threads(THD *thd, set_var *var);
static void fix_thd_mem_root(THD *thd, enum_var_type type);
static void fix_trans_mem_root(THD *thd, enum_var_type type);
static void fix_server_id(THD *thd, enum_var_type type);
+static ulonglong fix_unsigned(THD *thd, ulonglong num,
+ const struct my_option *option_limits);
+static bool get_unsigned(THD *thd, set_var *var);
+static void throw_bounds_warning(THD *thd, const char *name, ulonglong num);
static KEY_CACHE *create_key_cache(const char *name, uint length);
void fix_sql_mode_var(THD *thd, enum_var_type type);
static byte *get_error_count(THD *thd);
@@ -1448,6 +1452,39 @@ static void fix_server_id(THD *thd, enum_var_type type)
}
+static void throw_bounds_warning(THD *thd, const char *name, ulonglong num)
+{
+ char buf[22];
+ push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_TRUNCATED_WRONG_VALUE,
+ ER(ER_TRUNCATED_WRONG_VALUE), name,
+ ullstr(num, buf));
+}
+
+static ulonglong fix_unsigned(THD *thd, ulonglong num,
+ const struct my_option *option_limits)
+{
+ bool fixed= FALSE;
+ ulonglong out= getopt_ull_limit_value(num, option_limits, &fixed);
+
+ if (fixed)
+ throw_bounds_warning(thd, option_limits->name, num);
+ return out;
+}
+
+static bool get_unsigned(THD *thd, set_var *var)
+{
+ if (var->value->unsigned_flag)
+ var->save_result.ulonglong_value= (ulonglong) var->value->val_int();
+ else
+ {
+ longlong v= var->value->val_int();
+ var->save_result.ulonglong_value= (ulonglong) ((v < 0) ? 0 : v);
+ }
+ return 0;
+}
+
+
sys_var_long_ptr::
sys_var_long_ptr(const char *name_arg, ulong *value_ptr_arg,
sys_after_update_func after_update_arg)
@@ -1458,9 +1495,7 @@ sys_var_long_ptr(const char *name_arg, ulong *value_ptr_arg,
bool sys_var_long_ptr_global::check(THD *thd, set_var *var)
{
- longlong v= var->value->val_int();
- var->save_result.ulonglong_value= v < 0 ? 0 : v;
- return 0;
+ return get_unsigned(thd, var);
}
bool sys_var_long_ptr_global::update(THD *thd, set_var *var)
@@ -1468,9 +1503,20 @@ bool sys_var_long_ptr_global::update(THD *thd, set_var *var)
ulonglong tmp= var->save_result.ulonglong_value;
pthread_mutex_lock(guard);
if (option_limits)
- *value= (ulong) getopt_ull_limit_value(tmp, option_limits);
+ *value= (ulong) fix_unsigned(thd, tmp, option_limits);
else
+ {
+#if SIZEOF_LONG < SIZEOF_LONG_LONG
+ /* Avoid overflows on 32 bit systems */
+ if (tmp > ULONG_MAX)
+ {
+ tmp= ULONG_MAX;
+ throw_bounds_warning(thd, name, var->save_result.ulonglong_value);
+ }
+#endif
*value= (ulong) tmp;
+ }
+
pthread_mutex_unlock(guard);
return 0;
}
@@ -1489,7 +1535,7 @@ bool sys_var_ulonglong_ptr::update(THD *thd, set_var *var)
ulonglong tmp= var->save_result.ulonglong_value;
pthread_mutex_lock(&LOCK_global_system_variables);
if (option_limits)
- *value= (ulonglong) getopt_ull_limit_value(tmp, option_limits);
+ *value= (ulonglong) fix_unsigned(thd, tmp, option_limits);
else
*value= (ulonglong) tmp;
pthread_mutex_unlock(&LOCK_global_system_variables);
@@ -1532,45 +1578,36 @@ byte *sys_var_enum::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base)
bool sys_var_thd_ulong::check(THD *thd, set_var *var)
{
- return (sys_var_thd::check(thd, var) ||
+ return (get_unsigned(thd, var) ||
(check_func && (*check_func)(thd, var)));
}
bool sys_var_thd_ulong::update(THD *thd, set_var *var)
{
ulonglong tmp= var->save_result.ulonglong_value;
- char buf[22];
- bool truncated= false;
/* Don't use bigger value than given with --maximum-variable-name=.. */
if ((ulong) tmp > max_system_variables.*offset)
{
- truncated= true;
- llstr(tmp, buf);
+ throw_bounds_warning(thd, name, tmp);
tmp= max_system_variables.*offset;
}
-#if SIZEOF_LONG == 4
- /* Avoid overflows on 32 bit systems */
- if (tmp > (ulonglong) ~(ulong) 0)
+ if (option_limits)
+ tmp= (ulong) fix_unsigned(thd, tmp, option_limits);
+#if SIZEOF_LONG < SIZEOF_LONG_LONG
+ else if (tmp > ULONG_MAX)
{
- truncated= true;
- llstr(tmp, buf);
- tmp= ((ulonglong) ~(ulong) 0);
+ tmp= ULONG_MAX;
+ throw_bounds_warning(thd, name, var->save_result.ulonglong_value);
}
#endif
- if (truncated)
- push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
- ER_TRUNCATED_WRONG_VALUE,
- ER(ER_TRUNCATED_WRONG_VALUE), name,
- buf);
- if (option_limits)
- tmp= (ulong) getopt_ull_limit_value(tmp, option_limits);
if (var->type == OPT_GLOBAL)
global_system_variables.*offset= (ulong) tmp;
else
thd->variables.*offset= (ulong) tmp;
+
return 0;
}
@@ -1605,7 +1642,7 @@ bool sys_var_thd_ha_rows::update(THD *thd, set_var *var)
tmp= max_system_variables.*offset;
if (option_limits)
- tmp= (ha_rows) getopt_ull_limit_value(tmp, option_limits);
+ tmp= (ha_rows) fix_unsigned(thd, tmp, option_limits);
if (var->type == OPT_GLOBAL)
{
/* Lock is needed to make things safe on 32 bit systems */
@@ -1641,6 +1678,11 @@ byte *sys_var_thd_ha_rows::value_ptr(THD *thd, enum_var_type type,
return (byte*) &(thd->variables.*offset);
}
+bool sys_var_thd_ulonglong::check(THD *thd, set_var *var)
+{
+ return get_unsigned(thd, var);
+}
+
bool sys_var_thd_ulonglong::update(THD *thd, set_var *var)
{
ulonglong tmp= var->save_result.ulonglong_value;
@@ -1649,7 +1691,7 @@ bool sys_var_thd_ulonglong::update(THD *thd, set_var *var)
tmp= max_system_variables.*offset;
if (option_limits)
- tmp= getopt_ull_limit_value(tmp, option_limits);
+ tmp= fix_unsigned(thd, tmp, option_limits);
if (var->type == OPT_GLOBAL)
{
/* Lock is needed to make things safe on 32 bit systems */
@@ -2508,7 +2550,7 @@ bool sys_var_key_buffer_size::update(THD *thd, set_var *var)
}
key_cache->param_buff_size=
- (ulonglong) getopt_ull_limit_value(tmp, option_limits);
+ (ulonglong) fix_unsigned(thd, tmp, option_limits);
/* If key cache didn't existed initialize it, else resize it */
key_cache->in_init= 1;
@@ -2556,7 +2598,7 @@ bool sys_var_key_cache_long::update(THD *thd, set_var *var)
goto end;
*((ulong*) (((char*) key_cache) + offset))=
- (ulong) getopt_ull_limit_value(tmp, option_limits);
+ (ulong) fix_unsigned(thd, tmp, option_limits);
/*
Don't create a new key cache if it didn't exist
diff --git a/sql/set_var.h b/sql/set_var.h
index 99db38933c2..c37cc400e43 100644
--- a/sql/set_var.h
+++ b/sql/set_var.h
@@ -365,6 +365,7 @@ public:
void set_default(THD *thd, enum_var_type type);
SHOW_TYPE show_type() { return SHOW_LONGLONG; }
byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
+ bool check(THD *thd, set_var *var);
bool check_default(enum_var_type type)
{
return type == OPT_GLOBAL && !option_limits;
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index ef199b6f883..93f5a34d5c6 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -1219,16 +1219,18 @@ select_export::prepare(List<Item> &list, SELECT_LEX_UNIT *u)
}
}
field_term_length=exchange->field_term->length();
- field_term_char= field_term_length ? (*exchange->field_term)[0] : INT_MAX;
+ field_term_char= field_term_length ?
+ (int) (uchar) (*exchange->field_term)[0] : INT_MAX;
if (!exchange->line_term->length())
exchange->line_term=exchange->field_term; // Use this if it exists
- field_sep_char= (exchange->enclosed->length() ? (*exchange->enclosed)[0] :
- field_term_char);
- escape_char= (exchange->escaped->length() ? (*exchange->escaped)[0] : -1);
+ field_sep_char= (exchange->enclosed->length() ?
+ (int) (uchar) (*exchange->enclosed)[0] : field_term_char);
+ escape_char= (exchange->escaped->length() ?
+ (int) (uchar) (*exchange->escaped)[0] : -1);
is_ambiguous_field_sep= test(strchr(ESCAPE_CHARS, field_sep_char));
is_unsafe_field_sep= test(strchr(NUMERIC_CHARS, field_sep_char));
line_sep_char= (exchange->line_term->length() ?
- (*exchange->line_term)[0] : INT_MAX);
+ (int) (uchar) (*exchange->line_term)[0] : INT_MAX);
if (!field_term_length)
exchange->opt_enclosed=0;
if (!exchange->enclosed->length())
@@ -1385,10 +1387,11 @@ bool select_export::send_data(List<Item> &items)
Don't escape field_term_char by doubling - doubling is only
valid for ENCLOSED BY characters:
*/
- (enclosed || !is_ambiguous_field_term || *pos != field_term_char))
+ (enclosed || !is_ambiguous_field_term ||
+ (int) (uchar) *pos != field_term_char))
{
char tmp_buff[2];
- tmp_buff[0]= ((int) *pos == field_sep_char &&
+ tmp_buff[0]= ((int) (uchar) *pos == field_sep_char &&
is_ambiguous_field_sep) ?
field_sep_char : escape_char;
tmp_buff[1]= *pos ? *pos : '0';
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 9f294d09d5a..daeb16de7e0 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -2054,17 +2054,17 @@ class select_insert :public select_result_interceptor {
TABLE_LIST *table_list;
TABLE *table;
List<Item> *fields;
- ulonglong last_insert_id;
+ ulonglong autoinc_value_of_last_inserted_row; // not autogenerated
+ ulonglong autoinc_value_of_first_inserted_row; // autogenerated
COPY_INFO info;
bool insert_into_view;
- bool is_bulk_insert_mode;
select_insert(TABLE_LIST *table_list_par,
TABLE *table_par, List<Item> *fields_par,
List<Item> *update_fields, List<Item> *update_values,
enum_duplicates duplic, bool ignore);
~select_insert();
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
- int prepare2(void);
+ virtual int prepare2(void);
bool send_data(List<Item> &items);
virtual void store_values(List<Item> &values);
void send_error(uint errcode,const char *err);
@@ -2099,6 +2099,7 @@ public:
void send_error(uint errcode,const char *err);
bool send_eof();
void abort();
+ int prepare2(void) { return 0; }
};
#include <myisam.h>
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 7273fbf74e3..cf9e93b8518 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -2644,9 +2644,9 @@ select_insert::select_insert(TABLE_LIST *table_list_par, TABLE *table_par,
enum_duplicates duplic,
bool ignore_check_option_errors)
:table_list(table_list_par), table(table_par), fields(fields_par),
- last_insert_id(0),
- insert_into_view(table_list_par && table_list_par->view != 0),
- is_bulk_insert_mode(FALSE)
+ autoinc_value_of_last_inserted_row(0),
+ autoinc_value_of_first_inserted_row(0),
+ insert_into_view(table_list_par && table_list_par->view != 0)
{
bzero((char*) &info,sizeof(info));
info.handle_duplicates= duplic;
@@ -2755,14 +2755,14 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
Is table which we are changing used somewhere in other parts of
query
*/
- if (!(lex->current_select->options & OPTION_BUFFER_RESULT) &&
- unique_table(thd, table_list, table_list->next_global, 0))
+ if (unique_table(thd, table_list, table_list->next_global, 0))
{
/* Using same table for INSERT and SELECT */
lex->current_select->options|= OPTION_BUFFER_RESULT;
lex->current_select->join->select_options|= OPTION_BUFFER_RESULT;
}
- else if (!thd->prelocked_mode)
+ else if (!(lex->current_select->options & OPTION_BUFFER_RESULT) &&
+ !thd->prelocked_mode)
{
/*
We must not yet prepare the result table if it is the same as one of the
@@ -2831,11 +2831,8 @@ int select_insert::prepare2(void)
{
DBUG_ENTER("select_insert::prepare2");
if (thd->lex->current_select->options & OPTION_BUFFER_RESULT &&
- !thd->prelocked_mode && !is_bulk_insert_mode)
- {
+ !thd->prelocked_mode)
table->file->start_bulk_insert((ha_rows) 0);
- is_bulk_insert_mode= TRUE;
- }
DBUG_RETURN(0);
}
@@ -2902,14 +2899,24 @@ bool select_insert::send_data(List<Item> &values)
if (table->next_number_field)
{
/*
+ If no value has been autogenerated so far, we need to remember the
+ value we just saw, we may need to send it to client in the end.
+ */
+ if (!thd->insert_id_used)
+ autoinc_value_of_last_inserted_row= table->next_number_field->val_int();
+ /*
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->last_insert_id;
+ if (!autoinc_value_of_last_inserted_row && thd->insert_id_used)
+ autoinc_value_of_last_inserted_row= thd->last_insert_id;
}
}
+
+ if (thd->insert_id_used && !autoinc_value_of_first_inserted_row)
+ autoinc_value_of_first_inserted_row= thd->last_insert_id;
+
DBUG_RETURN(error);
}
@@ -2938,11 +2945,11 @@ bool select_insert::send_eof()
{
int error, error2;
bool changed, transactional_table= table->file->has_transactions();
+ ulonglong id;
THD::killed_state killed_status= thd->killed;
DBUG_ENTER("select_insert::send_eof");
error= (!thd->prelocked_mode) ? table->file->end_bulk_insert():0;
- is_bulk_insert_mode= FALSE;
table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
table->file->extra(HA_EXTRA_WRITE_CANNOT_REPLACE);
@@ -2960,8 +2967,17 @@ bool select_insert::send_eof()
DBUG_ASSERT(transactional_table || !changed ||
thd->transaction.stmt.modified_non_trans_table);
- if (last_insert_id)
- thd->insert_id(info.copied ? last_insert_id : 0); // For binary log
+ // For binary log
+ if (autoinc_value_of_last_inserted_row)
+ {
+ if (info.copied)
+ thd->insert_id(autoinc_value_of_last_inserted_row);
+ else
+ {
+ autoinc_value_of_first_inserted_row= 0;
+ thd->insert_id(0);
+ }
+ }
/* Write to binlog before commiting transaction */
if (mysql_bin_log.is_open())
{
@@ -2988,7 +3004,9 @@ bool select_insert::send_eof()
thd->row_count_func= info.copied + info.deleted +
((thd->client_capabilities & CLIENT_FOUND_ROWS) ?
info.touched : info.updated);
- ::send_ok(thd, (ulong) thd->row_count_func, last_insert_id, buff);
+ id= autoinc_value_of_first_inserted_row > 0 ?
+ autoinc_value_of_first_inserted_row : thd->last_insert_id;
+ ::send_ok(thd, (ulong) thd->row_count_func, id, buff);
DBUG_RETURN(0);
}
@@ -3017,8 +3035,17 @@ void select_insert::abort()
*/
if (thd->transaction.stmt.modified_non_trans_table)
{
- if (last_insert_id)
- thd->insert_id(last_insert_id); // For binary log
+ // For binary log
+ if (autoinc_value_of_last_inserted_row)
+ {
+ if (info.copied)
+ thd->insert_id(autoinc_value_of_last_inserted_row);
+ else
+ {
+ autoinc_value_of_first_inserted_row= 0;
+ thd->insert_id(0);
+ }
+ }
if (mysql_bin_log.is_open())
{
Query_log_event qinfo(thd, thd->query, thd->query_length,
@@ -3278,10 +3305,7 @@ select_create::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
if (info.handle_duplicates == DUP_UPDATE)
table->file->extra(HA_EXTRA_INSERT_WITH_UPDATE);
if (!thd->prelocked_mode)
- {
table->file->start_bulk_insert((ha_rows) 0);
- is_bulk_insert_mode= TRUE;
- }
thd->abort_on_warning= (!info.ignore &&
(thd->variables.sql_mode &
(MODE_STRICT_TRANS_TABLES |
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 5699f1d1868..d6cb072ce9b 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -217,6 +217,7 @@ static void select_describe(JOIN *join, bool need_tmp_table,bool need_order,
bool distinct, const char *message=NullS);
static Item *remove_additional_cond(Item* conds);
static void add_group_and_distinct_keys(JOIN *join, JOIN_TAB *join_tab);
+static bool test_if_ref(Item_field *left_item,Item *right_item);
/*
@@ -681,9 +682,6 @@ err:
without "checking NULL", remove the predicates that were pushed down
into the subquery.
- We can remove the equalities that will be guaranteed to be true by the
- fact that subquery engine will be using index lookup.
-
If the subquery compares scalar values, we can remove the condition that
was wrapped into trig_cond (it will be checked when needed by the subquery
engine)
@@ -693,6 +691,12 @@ err:
and non-NULL values, we'll do a full table scan and will rely on the
equalities corresponding to non-NULL parts of left tuple to filter out
non-matching records.
+
+ TODO: We can remove the equalities that will be guaranteed to be true by the
+ fact that subquery engine will be using index lookup. This must be done only
+ for cases where there are no conversion errors of significance, e.g. 257
+ that is searched in a byte. But this requires homogenization of the return
+ codes of all Field*::store() methods.
*/
void JOIN::remove_subq_pushed_predicates(Item **where)
@@ -700,17 +704,13 @@ void JOIN::remove_subq_pushed_predicates(Item **where)
if (conds->type() == Item::FUNC_ITEM &&
((Item_func *)this->conds)->functype() == Item_func::EQ_FUNC &&
((Item_func *)conds)->arguments()[0]->type() == Item::REF_ITEM &&
- ((Item_func *)conds)->arguments()[1]->type() == Item::FIELD_ITEM)
+ ((Item_func *)conds)->arguments()[1]->type() == Item::FIELD_ITEM &&
+ test_if_ref ((Item_field *)((Item_func *)conds)->arguments()[1],
+ ((Item_func *)conds)->arguments()[0]))
{
*where= 0;
return;
}
- if (conds->type() == Item::COND_ITEM &&
- ((class Item_func *)this->conds)->functype() ==
- Item_func::COND_AND_FUNC)
- {
- *where= remove_additional_cond(conds);
- }
}
@@ -1236,7 +1236,7 @@ JOIN::optimize()
{
if (!having)
{
- Item *where= 0;
+ Item *where= conds;
if (join_tab[0].type == JT_EQ_REF &&
join_tab[0].ref.items[0]->name == in_left_expr_name)
{
@@ -2332,6 +2332,11 @@ static ha_rows get_quick_record_count(THD *thd, SQL_SELECT *select,
{
int error;
DBUG_ENTER("get_quick_record_count");
+#ifndef EMBEDDED_LIBRARY // Avoid compiler warning
+ char buff[STACK_BUFF_ALLOC];
+#endif
+ if (check_stack_overrun(thd, STACK_MIN_SIZE, buff))
+ DBUG_RETURN(0); // Fatal error flag is set
if (select)
{
select->head=table;
@@ -3686,7 +3691,7 @@ update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab,
found_eq_constant=0;
for (i=0 ; i < keyuse->elements-1 ; i++,use++)
{
- if (!use->used_tables)
+ if (!use->used_tables && use->optimize != KEY_OPTIMIZE_REF_OR_NULL)
use->table->const_key_parts[use->key]|= use->keypart_map;
if (use->keypart != FT_KEYPART)
{
@@ -10302,7 +10307,8 @@ Next_select_func setup_end_select_func(JOIN *join)
/* Set up select_end */
if (table)
{
- if (table->group && tmp_tbl->sum_func_count)
+ if (table->group && tmp_tbl->sum_func_count &&
+ !tmp_tbl->precomputed_group_by)
{
if (table->s->keys)
{
@@ -11933,8 +11939,12 @@ static bool test_if_ref(Item_field *left_item,Item *right_item)
Item *ref_item=part_of_refkey(field->table,field);
if (ref_item && ref_item->eq(right_item,1))
{
+ right_item= right_item->real_item();
if (right_item->type() == Item::FIELD_ITEM)
return (field->eq_def(((Item_field *) right_item)->field));
+ /* remove equalities injected by IN->EXISTS transformation */
+ else if (right_item->type() == Item::CACHE_ITEM)
+ return ((Item_cache *)right_item)->eq_def (field);
if (right_item->const_item() && !(right_item->is_null()))
{
/*
@@ -15373,7 +15383,8 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
{
if (tab->use_quick == 2)
{
- char buf[MAX_KEY/8+1];
+ /* 4 bits per 1 hex digit + terminating '\0' */
+ char buf[MAX_KEY / 4 + 1];
extra.append(STRING_WITH_LEN("; Range checked for each "
"record (index map: 0x"));
extra.append(tab->keys.print(buf));
diff --git a/sql/sql_select.h b/sql/sql_select.h
index 4fc32e7fdb3..42be8d3ec68 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -548,14 +548,17 @@ public:
enum store_key_result copy()
{
enum store_key_result result;
- enum_check_fields saved_count_cuted_fields=
- to_field->table->in_use->count_cuted_fields;
+ THD *thd= to_field->table->in_use;
+ enum_check_fields saved_count_cuted_fields= thd->count_cuted_fields;
+ ulong sql_mode= thd->variables.sql_mode;
+ thd->variables.sql_mode&= ~(MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE);
- to_field->table->in_use->count_cuted_fields= CHECK_FIELD_IGNORE;
+ thd->count_cuted_fields= CHECK_FIELD_IGNORE;
result= copy_inner();
- to_field->table->in_use->count_cuted_fields= saved_count_cuted_fields;
+ thd->count_cuted_fields= saved_count_cuted_fields;
+ thd->variables.sql_mode= sql_mode;
return result;
}
diff --git a/sql/sql_string.cc b/sql/sql_string.cc
index 9d7df73cd7a..606a9ddb26d 100644
--- a/sql/sql_string.cc
+++ b/sql/sql_string.cc
@@ -858,7 +858,7 @@ outp:
with optional left padding (for binary -> UCS2 conversion)
SYNOPSIS
- well_formed_copy_nhars()
+ well_formed_copy_nchars()
to Store result here
to_length Maxinum length of "to" string
to_cs Character set of "to" string
@@ -997,7 +997,10 @@ outp:
goto outp;
}
else
+ {
+ from= from_prev;
break;
+ }
}
*from_end_pos= from;
res= to - to_start;
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 0f4abb48f33..9e1a8151e3a 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -2780,8 +2780,11 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, TABLE_LIST *src_table,
strxmov(src_path, (*tmp_table)->s->path, reg_ext, NullS);
else
{
- strxmov(src_path, mysql_data_home, "/", src_table->db, "/",
- src_table->table_name, reg_ext, NullS);
+ char *tablename_pos= strxmov(src_path, mysql_data_home, "/", NullS);
+ strxmov(tablename_pos, src_table->db, "/", src_table->table_name,
+ reg_ext, NullS);
+ if (lower_case_table_names)
+ my_casedn_str(files_charset_info, tablename_pos);
/* Resolve symlinks (for windows) */
fn_format(src_path, src_path, "", "", MYF(MY_UNPACK_FILENAME));
if (access(src_path, F_OK))
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 6e231ef2447..bd85ce55edb 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -1137,7 +1137,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%type <variable> internal_variable_name
-%type <select_lex> subselect subselect_init
+%type <select_lex> subselect take_first_select
get_select_lex
%type <boolfunc2creator> comp_op
@@ -1160,8 +1160,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
field_opt_list opt_binary table_lock_list table_lock
ref_list opt_on_delete opt_on_delete_list opt_on_delete_item use
opt_delete_options opt_delete_option varchar nchar nvarchar
- opt_outer table_list table_name table_alias_ref_list table_alias_ref
- opt_option opt_place
+ opt_outer table_list table_name opt_option opt_place
opt_attribute opt_attribute_list attribute column_list column_list_id
opt_column_list grant_privileges grant_ident grant_list grant_option
object_privilege object_privilege_list user_list rename_list
@@ -6563,20 +6562,6 @@ table_name:
}
;
-table_alias_ref_list:
- table_alias_ref
- | table_alias_ref_list ',' table_alias_ref;
-
-table_alias_ref:
- table_ident
- {
- if (!Select->add_table_to_list(YYTHD, $1, NULL,
- TL_OPTION_UPDATING | TL_OPTION_ALIAS,
- Lex->lock_option ))
- MYSQL_YYABORT;
- }
- ;
-
if_exists:
/* empty */ { $$= 0; }
| IF EXISTS { $$= 1; }
@@ -6847,7 +6832,7 @@ single_multi:
if (multi_delete_set_locks_and_link_aux_tables(Lex))
MYSQL_YYABORT;
}
- | FROM table_alias_ref_list
+ | FROM table_wild_list
{ mysql_init_multi_delete(Lex); }
USING join_table_list where_clause
{
@@ -9505,35 +9490,22 @@ union_option:
| ALL { $$=0; }
;
+take_first_select: /* empty */
+ {
+ $$= Lex->current_select->master_unit()->first_select();
+ };
+
subselect:
- SELECT_SYM subselect_start subselect_init subselect_end
+ SELECT_SYM subselect_start select_init2 take_first_select
+ subselect_end
{
- $$= $3;
+ $$= $4;
}
- | '(' subselect_start subselect ')'
- {
- THD *thd= YYTHD;
- /*
- note that a local variable can't be used for
- $3 as it's used in local variable construction
- and some compilers can't guarnatee the order
- in which the local variables are initialized.
- */
- List_iterator<Item> it($3->item_list);
- Item *item;
- /*
- we must fill the items list for the "derived table".
- */
- while ((item= it++))
- add_item_to_list(thd, item);
- }
- union_clause subselect_end { $$= $3; };
-
-subselect_init:
- select_init2
- {
- $$= Lex->current_select->master_unit()->first_select();
- };
+ | '(' subselect_start select_paren take_first_select
+ subselect_end ')'
+ {
+ $$= $4;
+ };
subselect_start:
{
diff --git a/sql/udf_example.c b/sql/udf_example.c
index df3a69755ad..4ca6133da03 100644
--- a/sql/udf_example.c
+++ b/sql/udf_example.c
@@ -648,13 +648,11 @@ my_bool sequence_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
return 1;
}
bzero(initid->ptr,sizeof(longlong));
- /*
- Fool MySQL to think that this function is a constant
- This will ensure that MySQL only evalutes the function
- when the rows are sent to the client and not before any ORDER BY
- clauses
+ /*
+ sequence() is a non-deterministic function : it has different value
+ even if called with the same arguments.
*/
- initid->const_item=1;
+ initid->const_item=0;
return 0;
}
diff --git a/strings/llstr.c b/strings/llstr.c
index 12aea63e014..643cf36a311 100644
--- a/strings/llstr.c
+++ b/strings/llstr.c
@@ -32,3 +32,9 @@ char *llstr(longlong value,char *buff)
longlong10_to_str(value,buff,-10);
return buff;
}
+
+char *ullstr(longlong value,char *buff)
+{
+ longlong10_to_str(value,buff,10);
+ return buff;
+}
diff --git a/tests/bug25714.c b/tests/bug25714.c
index e9b2be44209..88485aa1962 100644
--- a/tests/bug25714.c
+++ b/tests/bug25714.c
@@ -29,8 +29,12 @@ int main (int argc, char **argv)
MY_INIT(argv[0]);
- if (argc != 2)
+ if (argc != 2 || !strcmp(argv[1], "--help"))
+ {
+ fprintf(stderr, "This program is a part of the MySQL test suite. "
+ "It is not intended to be executed directly by a user.\n");
return -1;
+ }
mysql_init(&conn);
if (!mysql_real_connect(
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c
index 65e18da97f1..9cc2af25529 100644
--- a/tests/mysql_client_test.c
+++ b/tests/mysql_client_test.c
@@ -123,7 +123,7 @@ static void die(const char *file, int line, const char *expr)
fflush(stdout);
fprintf(stderr, "%s:%d: check failed: '%s'\n", file, line, expr);
fflush(stderr);
- abort();
+ exit(1);
}
@@ -5643,6 +5643,20 @@ DROP TABLE IF EXISTS test_multi_tab";
(void) my_process_result_set(result);
mysql_free_result(result);
+ /*
+ Check if errors in one of the queries handled properly.
+ */
+ rc= mysql_query(mysql_local, "select 1; select * from not_existing_table");
+ myquery(rc);
+ result= mysql_store_result(mysql_local);
+ mysql_free_result(result);
+
+ rc= mysql_next_result(mysql_local);
+ DIE_UNLESS(rc > 0);
+
+ rc= mysql_next_result(mysql_local);
+ DIE_UNLESS(rc < 0);
+
mysql_close(mysql_local);
}
@@ -9283,7 +9297,7 @@ static void test_subqueries_ref()
{
MYSQL_STMT *stmt;
int rc, i;
- const char *query= "SELECT a as ccc from t1 where a+1=(SELECT 1+ccc from t1 where ccc+1=a+1 and a=1)";
+ const char *query= "SELECT a as ccc from t1 outr where a+1=(SELECT 1+outr.a from t1 where outr.a+1=a+1 and a=1)";
myheader("test_subqueries_ref");
@@ -15200,6 +15214,187 @@ static void test_bug14169()
/*
+ Test that mysql_insert_id() behaves as documented in our manual
+*/
+
+static void test_mysql_insert_id()
+{
+ my_ulonglong res;
+ int rc;
+
+ myheader("test_mysql_insert_id");
+
+ rc= mysql_query(mysql, "drop table if exists t1");
+ myquery(rc);
+ /* table without auto_increment column */
+ rc= mysql_query(mysql, "create table t1 (f1 int, f2 varchar(255), key(f1))");
+ myquery(rc);
+ rc= mysql_query(mysql, "insert into t1 values (1,'a')");
+ myquery(rc);
+ res= mysql_insert_id(mysql);
+ DIE_UNLESS(res == 0);
+ rc= mysql_query(mysql, "insert into t1 values (null,'b')");
+ myquery(rc);
+ res= mysql_insert_id(mysql);
+ DIE_UNLESS(res == 0);
+ rc= mysql_query(mysql, "insert into t1 select 5,'c'");
+ myquery(rc);
+ res= mysql_insert_id(mysql);
+ DIE_UNLESS(res == 0);
+ rc= mysql_query(mysql, "insert into t1 select null,'d'");
+ myquery(rc);
+ res= mysql_insert_id(mysql);
+ DIE_UNLESS(res == 0);
+ rc= mysql_query(mysql, "insert into t1 values (null,last_insert_id(300))");
+ myquery(rc);
+ res= mysql_insert_id(mysql);
+ DIE_UNLESS(res == 300);
+ rc= mysql_query(mysql, "insert into t1 select null,last_insert_id(400)");
+ myquery(rc);
+ res= mysql_insert_id(mysql);
+ /*
+ Behaviour change: old code used to return 0; but 400 is consistent
+ with INSERT VALUES, and the manual's section of mysql_insert_id() does not
+ say INSERT SELECT should be different.
+ */
+ DIE_UNLESS(res == 400);
+
+ /* table with auto_increment column */
+ rc= mysql_query(mysql, "create table t2 (f1 int not null primary key auto_increment, f2 varchar(255))");
+ myquery(rc);
+ rc= mysql_query(mysql, "insert into t2 values (1,'a')");
+ myquery(rc);
+ res= mysql_insert_id(mysql);
+ DIE_UNLESS(res == 1);
+ /* this should not influence next INSERT if it doesn't have auto_inc */
+ rc= mysql_query(mysql, "insert into t1 values (10,'e')");
+ myquery(rc);
+ res= mysql_insert_id(mysql);
+ DIE_UNLESS(res == 0);
+
+ rc= mysql_query(mysql, "insert into t2 values (null,'b')");
+ myquery(rc);
+ res= mysql_insert_id(mysql);
+ DIE_UNLESS(res == 2);
+ rc= mysql_query(mysql, "insert into t2 select 5,'c'");
+ myquery(rc);
+ res= mysql_insert_id(mysql);
+ /*
+ Manual says that for multirow insert this should have been 5, but does not
+ say for INSERT SELECT. This is a behaviour change: old code used to return
+ 0. We try to be consistent with INSERT VALUES.
+ */
+ DIE_UNLESS(res == 5);
+ rc= mysql_query(mysql, "insert into t2 select null,'d'");
+ myquery(rc);
+ res= mysql_insert_id(mysql);
+ DIE_UNLESS(res == 6);
+ /* with more than one row */
+ rc= mysql_query(mysql, "insert into t2 values (10,'a'),(11,'b')");
+ myquery(rc);
+ res= mysql_insert_id(mysql);
+ DIE_UNLESS(res == 11);
+ rc= mysql_query(mysql, "insert into t2 select 12,'a' union select 13,'b'");
+ myquery(rc);
+ res= mysql_insert_id(mysql);
+ /*
+ Manual says that for multirow insert this should have been 13, but does
+ not say for INSERT SELECT. This is a behaviour change: old code used to
+ return 0. We try to be consistent with INSERT VALUES.
+ */
+ DIE_UNLESS(res == 13);
+ rc= mysql_query(mysql, "insert into t2 values (null,'a'),(null,'b')");
+ myquery(rc);
+ res= mysql_insert_id(mysql);
+ DIE_UNLESS(res == 14);
+ rc= mysql_query(mysql, "insert into t2 select null,'a' union select null,'b'");
+ myquery(rc);
+ res= mysql_insert_id(mysql);
+ DIE_UNLESS(res == 16);
+ rc= mysql_query(mysql, "insert into t2 select 12,'a' union select 13,'b'");
+ myquery_r(rc);
+ rc= mysql_query(mysql, "insert ignore into t2 select 12,'a' union select 13,'b'");
+ myquery(rc);
+ res= mysql_insert_id(mysql);
+ DIE_UNLESS(res == 0);
+ rc= mysql_query(mysql, "insert into t2 values (12,'a'),(13,'b')");
+ myquery_r(rc);
+ res= mysql_insert_id(mysql);
+ DIE_UNLESS(res == 0);
+ rc= mysql_query(mysql, "insert ignore into t2 values (12,'a'),(13,'b')");
+ myquery(rc);
+ res= mysql_insert_id(mysql);
+ DIE_UNLESS(res == 0);
+ /* mixing autogenerated and explicit values */
+ rc= mysql_query(mysql, "insert into t2 values (null,'e'),(12,'a'),(13,'b')");
+ myquery_r(rc);
+ rc= mysql_query(mysql, "insert into t2 values (null,'e'),(12,'a'),(13,'b'),(25,'g')");
+ myquery_r(rc);
+ rc= mysql_query(mysql, "insert into t2 values (null,last_insert_id(300))");
+ myquery(rc);
+ res= mysql_insert_id(mysql);
+ /*
+ according to the manual, this might be 20 or 300, but it looks like
+ auto_increment column takes priority over last_insert_id().
+ */
+ DIE_UNLESS(res == 20);
+ /* If first autogenerated number fails and 2nd works: */
+ rc= mysql_query(mysql, "drop table t2");
+ myquery(rc);
+ rc= mysql_query(mysql, "create table t2 (f1 int not null primary key "
+ "auto_increment, f2 varchar(255), unique (f2))");
+ myquery(rc);
+ rc= mysql_query(mysql, "insert into t2 values (null,'e')");
+ res= mysql_insert_id(mysql);
+ DIE_UNLESS(res == 1);
+ rc= mysql_query(mysql, "insert ignore into t2 values (null,'e'),(null,'a'),(null,'e')");
+ myquery(rc);
+ res= mysql_insert_id(mysql);
+ DIE_UNLESS(res == 2);
+ /* If autogenerated fails and explicit works: */
+ rc= mysql_query(mysql, "insert ignore into t2 values (null,'e'),(12,'c'),(null,'d')");
+ myquery(rc);
+ res= mysql_insert_id(mysql);
+ DIE_UNLESS(res == 3);
+ /* UPDATE may update mysql_insert_id() if it uses LAST_INSERT_ID(#) */
+ rc= mysql_query(mysql, "update t2 set f1=14 where f1=12");
+ myquery(rc);
+ res= mysql_insert_id(mysql);
+ DIE_UNLESS(res == 0);
+ rc= mysql_query(mysql, "update t2 set f1=NULL where f1=14");
+ myquery(rc);
+ res= mysql_insert_id(mysql);
+ DIE_UNLESS(res == 0);
+ rc= mysql_query(mysql, "update t2 set f2=last_insert_id(372) where f1=0");
+ myquery(rc);
+ res= mysql_insert_id(mysql);
+ DIE_UNLESS(res == 372);
+ /* check that LAST_INSERT_ID() does not update mysql_insert_id(): */
+ rc= mysql_query(mysql, "insert into t2 values (null,'g')");
+ myquery(rc);
+ res= mysql_insert_id(mysql);
+ DIE_UNLESS(res == 15);
+ rc= mysql_query(mysql, "update t2 set f2=(@li:=last_insert_id()) where f1=15");
+ myquery(rc);
+ res= mysql_insert_id(mysql);
+ DIE_UNLESS(res == 0);
+ /*
+ Behaviour change: now if ON DUPLICATE KEY UPDATE updates a row,
+ mysql_insert_id() returns the id of the row, instead of not being
+ affected.
+ */
+ rc= mysql_query(mysql, "insert into t2 values (null,@li) on duplicate key "
+ "update f2=concat('we updated ',f2)");
+ myquery(rc);
+ res= mysql_insert_id(mysql);
+ DIE_UNLESS(res == 15);
+
+ rc= mysql_query(mysql, "drop table t1,t2");
+ myquery(rc);
+}
+
+
+/*
Bug#20152: mysql_stmt_execute() writes to MYSQL_TYPE_DATE buffer
*/
@@ -16237,6 +16432,7 @@ static struct my_tests_st my_tests[]= {
{ "test_bug17667", test_bug17667 },
{ "test_bug19671", test_bug19671 },
{ "test_bug15752", test_bug15752 },
+ { "test_mysql_insert_id", test_mysql_insert_id },
{ "test_bug21206", test_bug21206 },
{ "test_bug21726", test_bug21726 },
{ "test_bug15518", test_bug15518 },