diff options
author | Vladislav Vaintroub <wlad@montyprogram.com> | 2011-04-08 02:49:04 +0200 |
---|---|---|
committer | Vladislav Vaintroub <wlad@montyprogram.com> | 2011-04-08 02:49:04 +0200 |
commit | 2a60cc126d551375cb97559dc822a102910e3005 (patch) | |
tree | 28d33c38b5bf7e6f544faff27233ddc75a928426 /win | |
parent | ad7b636d7202302f8cd9cb8818d9ca2218c408a0 (diff) | |
download | mariadb-git-2a60cc126d551375cb97559dc822a102910e3005.tar.gz |
enable 'Optimized for transactions'configuration checkbox if innodb is compiled in
Diffstat (limited to 'win')
-rw-r--r-- | win/packaging/CMakeLists.txt | 3 | ||||
-rw-r--r-- | win/packaging/ca/CustomAction.cpp | 170 | ||||
-rw-r--r-- | win/packaging/ca/CustomAction.def | 1 | ||||
-rw-r--r-- | win/packaging/extra.wxs.in | 103 |
4 files changed, 257 insertions, 20 deletions
diff --git a/win/packaging/CMakeLists.txt b/win/packaging/CMakeLists.txt index c004ceaa884..02fba4ae16b 100644 --- a/win/packaging/CMakeLists.txt +++ b/win/packaging/CMakeLists.txt @@ -99,6 +99,9 @@ GET_TARGET_PROPERTY(upgrade_wizard_location mysql_upgrade_wizard LOCATION) IF(NOT upgrade_wizard_location) SET(EXTRA_WIX_PREPROCESSOR_FLAGS "-dHaveUpgradeWizard=0") ENDIF() +IF(WITH_INNOBASE_STORAGE_ENGINE OR WITH_INNODB_STORAGE_ENGINE OR WITH_XTRADB_STORAGE_ENGINE) + SET(EXTRA_WIX_PREPROCESSOR_FLAGS ${EXTRA_WIX_PREPROCESSOR_FLAGS} "-dHaveInnodb=1") +ENDIF() IF(NOT CPACK_WIX_UI) SET(CPACK_WIX_UI "MyWixUI_Mondo") diff --git a/win/packaging/ca/CustomAction.cpp b/win/packaging/ca/CustomAction.cpp index b856bc5f651..81c9f7eea92 100644 --- a/win/packaging/ca/CustomAction.cpp +++ b/win/packaging/ca/CustomAction.cpp @@ -29,6 +29,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <winservice.h> +#define ONE_MB 1048576 UINT ExecRemoveDataDirectory(wchar_t *dir) { /* Strip stray backslash */ @@ -436,16 +437,49 @@ LExit: return WcaFinalize(er); } - - +/* + Get maximum size of the buffer process can allocate. + this is calculated as min(RAM,virtualmemorylimit) + For 32bit processes, virtual address memory is 2GB (x86 OS) + or 4GB(x64 OS). + + Fragmentation due to loaded modules, heap and stack + limit maximum size of continous memory block further, + so that limit for 32 bit process is about 1200 on 32 bit OS + or 2000 MB on 64 bit OS(found experimentally). +*/ +unsigned long long GetMaxBufferSize(unsigned long long totalPhys) +{ +#ifdef _M_IX86 + BOOL wow64; + if (IsWow64Process(GetCurrentProcess(), &wow64)) + return min(totalPhys, 2000ULL*ONE_MB); + else + return min(totalPhys, 1200ULL*ONE_MB); +#else + return totalPhys; +#endif +} +/* + Checks SERVICENAME, PORT and BUFFERSIZE parameters +*/ extern "C" UINT __stdcall CheckDatabaseProperties (MSIHANDLE hInstall) { wchar_t ServiceName[MAX_PATH]={0}; wchar_t SkipNetworking[MAX_PATH]={0}; + wchar_t QuickConfig[MAX_PATH]={0}; wchar_t Port[6]; + wchar_t BufferPoolSize[16]; DWORD PortLen=6; bool haveInvalidPort=false; const wchar_t *ErrorMsg=0; + HRESULT hr= S_OK; + UINT er= ERROR_SUCCESS; + + + hr = WcaInitialize(hInstall, __FUNCTION__); + ExitOnFailure(hr, "Failed to initialize"); + WcaLog(LOGMSG_STANDARD, "Initialized."); DWORD ServiceNameLen = MAX_PATH; MsiGetPropertyW (hInstall, L"SERVICENAME", ServiceName, &ServiceNameLen); @@ -454,7 +488,7 @@ extern "C" UINT __stdcall CheckDatabaseProperties (MSIHANDLE hInstall) if(ServiceNameLen > 256) { ErrorMsg= L"Invalid service name. The maximum length is 256 characters."; - goto err; + goto LExit; } for(DWORD i=0; i< ServiceNameLen;i++) { @@ -464,7 +498,7 @@ extern "C" UINT __stdcall CheckDatabaseProperties (MSIHANDLE hInstall) ErrorMsg = L"Invalid service name. Forward slash and back slash are forbidden." L"Single and double quotes are also not permitted."; - goto err; + goto LExit; } } if(CheckServiceExists(ServiceName)) @@ -472,7 +506,7 @@ extern "C" UINT __stdcall CheckDatabaseProperties (MSIHANDLE hInstall) ErrorMsg= L"A service with the same name already exists. " L"Please use a different name."; - goto err; + goto LExit; } } @@ -508,7 +542,7 @@ extern "C" UINT __stdcall CheckDatabaseProperties (MSIHANDLE hInstall) { ErrorMsg = L"Invalid port number. Please use a number between 1025 and 65535."; - goto err; + goto LExit; } short port = (short)_wtoi(Port); @@ -517,15 +551,133 @@ extern "C" UINT __stdcall CheckDatabaseProperties (MSIHANDLE hInstall) ErrorMsg = L"The TCP Port you selected is already in use. " L"Please choose a different port."; - goto err; + goto LExit; } } + + + DWORD QuickConfigLen = MAX_PATH; + MsiGetPropertyW (hInstall, L"STDCONFIG", QuickConfig, &QuickConfigLen); + if(QuickConfig[0] !=0) + { + MEMORYSTATUSEX memstatus; + memstatus.dwLength =sizeof(memstatus); + wchar_t invalidValueMsg[256]; -err: + if (!GlobalMemoryStatusEx(&memstatus)) + { + WcaLog(LOGMSG_STANDARD, "Error %u from GlobalMemoryStatusEx", + GetLastError()); + er= ERROR_INSTALL_FAILURE; + goto LExit; + } + DWORD BufferPoolSizeLen= 16; + MsiGetPropertyW(hInstall, L"BUFFERPOOLSIZE", BufferPoolSize, &BufferPoolSizeLen); + /* Strip spaces */ + for(DWORD i=BufferPoolSizeLen-1; i > 0; i--) + { + if(BufferPoolSize[i]== ' ') + BufferPoolSize[i] = 0; + } + unsigned long long availableMemory= + GetMaxBufferSize(memstatus.ullTotalPhys)/ONE_MB; + swprintf_s(invalidValueMsg, + L"Invalid buffer pool size. Please use a number between 1 and %llu", + availableMemory); + if(BufferPoolSizeLen == 0 || BufferPoolSizeLen > 15) + { + ErrorMsg= invalidValueMsg; + goto LExit; + } + for (DWORD i=0; i < BufferPoolSizeLen && BufferPoolSize[BufferPoolSizeLen]; + i++) + { + if(BufferPoolSize[i]< '0' || BufferPoolSize[i] > '9') + { + ErrorMsg= invalidValueMsg; + goto LExit; + } + } + BufferPoolSize[BufferPoolSizeLen]=0; + MsiSetPropertyW(hInstall, L"BUFFERPOOLSIZE", BufferPoolSize); + long long sz = _wtoi64(BufferPoolSize); + if(sz <= 0 || sz > (long long)availableMemory) + { + if(sz > 0) + { + swprintf_s(invalidValueMsg, + L"Value for buffer pool size is too large." + L"Only approximately %llu MB is available for allocation." + L"Please use a number between 1 and %llu.", + availableMemory, availableMemory); + } + ErrorMsg= invalidValueMsg; + goto LExit; + } + } +LExit: MsiSetPropertyW (hInstall, L"WarningText", ErrorMsg); - return ERROR_SUCCESS; + return WcaFinalize(er); } +/* + Sets Innodb buffer pool size (1/8 of RAM by default), if not already specified + via command line. + Calculates innodb log file size as min(50, innodb buffer pool size/8) +*/ +extern "C" UINT __stdcall PresetDatabaseProperties(MSIHANDLE hInstall) +{ + unsigned long long InnodbBufferPoolSize= 256; + unsigned long long InnodbLogFileSize= 50; + wchar_t buff[MAX_PATH]; + UINT er = ERROR_SUCCESS; + HRESULT hr= S_OK; + MEMORYSTATUSEX memstatus; + hr = WcaInitialize(hInstall, __FUNCTION__); + ExitOnFailure(hr, "Failed to initialize"); + WcaLog(LOGMSG_STANDARD, "Initialized."); + + /* Check if bufferpoolsize parameter was given on the command line*/ + DWORD BufferPoolsizeParamLen = MAX_PATH; + MsiGetPropertyW(hInstall, L"BUFFERPOOLSIZE", buff, &BufferPoolsizeParamLen); + + if (BufferPoolsizeParamLen && buff[0]) + { + WcaLog(LOGMSG_STANDARD, "BUFFERPOOLSIZE=%s, len=%u",buff, BufferPoolsizeParamLen); + InnodbBufferPoolSize= _wtoi64(buff); + } + else + { + memstatus.dwLength = sizeof(memstatus); + if (!GlobalMemoryStatusEx(&memstatus)) + { + WcaLog(LOGMSG_STANDARD, "Error %u from GlobalMemoryStatusEx", + GetLastError()); + er= ERROR_INSTALL_FAILURE; + goto LExit; + } + unsigned long long totalPhys= memstatus.ullTotalPhys; + /* Give innodb 12.5% of available physical memory. */ + InnodbBufferPoolSize= totalPhys/ONE_MB/8; + #ifdef _M_IX86 + /* + For 32 bit processes, take virtual address space limitation into account. + Do not try to use more than 3/4 of virtual address space, even if there + is plenty of physical memory. + */ + InnodbBufferPoolSize= min(GetMaxBufferSize(totalPhys)/ONE_MB*3/4, + InnodbBufferPoolSize); + #endif + swprintf_s(buff, L"%llu",InnodbBufferPoolSize); + MsiSetPropertyW(hInstall, L"BUFFERPOOLSIZE", buff); + } + InnodbLogFileSize = min(50, InnodbBufferPoolSize); + swprintf_s(buff, L"%llu",InnodbLogFileSize); + MsiSetPropertyW(hInstall, L"LOGFILESIZE", buff); + +LExit: + return WcaFinalize(er); +} /* Remove service and data directory created by CreateDatabase operation */ extern "C" UINT __stdcall CreateDatabaseRollback(MSIHANDLE hInstall) { diff --git a/win/packaging/ca/CustomAction.def b/win/packaging/ca/CustomAction.def index f625d48ae2c..0be77a97a08 100644 --- a/win/packaging/ca/CustomAction.def +++ b/win/packaging/ca/CustomAction.def @@ -1,6 +1,7 @@ LIBRARY "wixca" VERSION 1.0 EXPORTS +PresetDatabaseProperties RemoveDataDirectory CreateDatabaseRollback CheckDatabaseProperties diff --git a/win/packaging/extra.wxs.in b/win/packaging/extra.wxs.in index cb3c6eb864b..456b833cf4f 100644 --- a/win/packaging/extra.wxs.in +++ b/win/packaging/extra.wxs.in @@ -1,8 +1,24 @@ <?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<Fragment>
- <Property Id="PortTemplate" Value="#####" />
+ <!--
+ Check, if upgrade wizard was built
+ It currently requires MFC, which is not in SDK
+ neither in express edÃtions of VS.
+ -->
+ <?ifndef HaveUpgradeWizard ?>
+ <?define HaveUpgradeWizard="1"?>
+ <?endif?>
+ <!-- If Innodb is compiled in, enable "optimize for transactions" checkbox -->
+ <?ifndef HaveInnodb ?>
+ <?define HaveInnodb="0"?>
+ <?endif?>
+
+ <Property Id="PortTemplate" Value="#####" />
+ <?if $(var.HaveInnodb) = "1" ?>
+ <Property Id="BufferPoolSizeTemplate" Value="#######" />
+ <?endif?>
<!--
Installation parameters that can be passed via msiexec command line
For "booleans" (like skip networking), just providing any value means property set to "yes".
@@ -30,15 +46,14 @@ <Property Id="CLEANUPDATA" Secure="yes" Value="1"/>
<!-- Force per machine installation -->
<Property Id="ALLUSERS" Secure="yes" Value="1"/>
- <!--
- Check, if upgrade wizard was built
- It currently requires MFC, which is not in SDK
- neither in express edÃtions of VS.
- -->
- <?ifndef HaveUpgradeWizard ?>
- <?define HaveUpgradeWizard="1"?>
+ <?if $(var.HaveInnodb) = "1" ?>
+ <!-- Quick configuration : set default storage engine to innodb, use strict sql_mode -->
+ <Property Id="STDCONFIG" Secure="yes" Value="1"/>
<?endif?>
-
+ <!-- Innodb Buffer pool size in MB-->
+ <Property Id="BUFFERPOOLSIZE" Secure="yes"/>
+
+
<!--
User interface dialogs
-->
@@ -142,6 +157,8 @@ <!-- Error popup dialog -->
<Dialog Id="WarningDlg" Width="320" Height="85" Title="[ProductName] Setup" NoMinimize="yes">
+ <Control Id="Icon" Type="Icon" X="15" Y="15" Width="24" Height="24"
+ ToolTip="Information icon" FixedSize="yes" IconSize="32" Text="WixUI_Ico_Info" />
<Control Id="Ok" Type="PushButton" X="132" Y="57" Width="56" Height="17"
Default="yes" Cancel="yes" Text="OK">
<Publish Property="WarningText">1</Publish>
@@ -261,6 +278,31 @@ <Condition Action="enable" >EnableNetworking</Condition>
<Condition Action="disable">Not EnableNetworking</Condition>
</Control>
+
+ <?if $(var.HaveInnodb) = "1" ?>
+ <Control Id="CheckBoxStandardConfig" Type="CheckBox" Height="18" Width="220" X="9" Y="171" Property="STDCONFIG" CheckBoxValue="1">
+ <Text>{\Font1}Optimize for transactions</Text>
+ </Control>
+
+ <Control Id="StandardConfigExplain" Type="Text" X="25" Y="190" Width="270" Height="14" TabSkip="yes">
+ <Text>(Uses transactional storage engine and "strict" SQL mode)</Text>
+ <Condition Action="enable" >STDCONFIG</Condition>
+ <Condition Action="disable">Not STDCONFIG</Condition>
+ </Control>
+ <Control Id="LabelInnodbBufferpool" Type="Text" Height="17" Width="77" X="25" Y="210" Text="Buffer pool size:" >
+ <Condition Action="enable" >STDCONFIG</Condition>
+ <Condition Action="disable">Not STDCONFIG</Condition>
+ </Control>
+ <Control Id="BPSize" Type="MaskedEdit" X="104" Y="208" Width="40" Height="15" Property="BUFFERPOOLSIZE" Sunken="yes" Text="[BufferPoolSizeTemplate]">
+ <Condition Action="enable" >STDCONFIG</Condition>
+ <Condition Action="disable">Not STDCONFIG</Condition>
+ </Control>
+ <Control Id="LabelMB" Type="Text" Height="17" Width="15" X="150" Y="210" Text="MB" >
+ <Condition Action="enable" >STDCONFIG</Condition>
+ <Condition Action="disable">Not STDCONFIG</Condition>
+ </Control>
+ <?endif?>
+
<!-- Navigation buttons-->
<Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="&Back">
<Publish Event="NewDialog" Value="UserSettingsDlg">1</Publish>
@@ -379,7 +421,42 @@ <ServiceControl Id='DBInstanceServiceStop' Name='[SERVICENAME]' Stop='both' Remove='uninstall' Wait='yes'/>
<ServiceControl Id='DBInstanceServiceStart' Name='[SERVICENAME]' Start='install' Wait='yes'/>
</Component>
-
+ <?if $(var.HaveInnodb) = "1" ?>
+ <Component Id="C.myiniconfig" Guid="*" Directory="DATADIR">
+ <Condition>STDCONFIG</Condition>
+ <RegistryValue Root='HKLM'
+ Key='SOFTWARE\@MANUFACTURER@\@CPACK_WIX_PACKAGE_NAME@'
+ Name='STDCONFIG' Value='1' Type='string' KeyPath='yes'/>
+ <IniFile Id="Ini1"
+ Action="createLine"
+ Directory="DATADIR"
+ Section="mysqld"
+ Name="my.ini"
+ Key="sql_mode"
+ Value=""STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION"" />
+ <IniFile Id="Ini2"
+ Action="createLine"
+ Directory="DATADIR"
+ Section="mysqld"
+ Name="my.ini"
+ Key="default_storage_engine"
+ Value="innodb" />
+ <IniFile Id="Ini3"
+ Action="createLine"
+ Directory="DATADIR"
+ Section="mysqld"
+ Name="my.ini"
+ Key="innodb_buffer_pool_size"
+ Value="[BUFFERPOOLSIZE]M" />
+ <IniFile Id="Ini4"
+ Action="createLine"
+ Directory="DATADIR"
+ Section="mysqld"
+ Name="my.ini"
+ Key="innodb_log_file_size"
+ Value="[LOGFILESIZE]M" />
+ </Component>
+ <?endif?>
<!--- Grant service account permission to the database folder (Windows 7 and later) -->
<Component Id="C.serviceaccount.permission" Guid="*" Directory='DATADIR' Transitive='yes'>
<Condition><![CDATA[SERVICENAME AND (VersionNT > 600)]]></Condition>
@@ -484,7 +561,8 @@ Name="Upgrade Wizard (@CPACK_WIX_PACKAGE_NAME@)"
Target="[INSTALLDIR]bin\mysql_upgrade_wizard.exe"
Directory="ShortcutFolder"
- Description="Upgrades older instances of MariaDB/MySQL services to version @MAJOR_VERSION@.@MINOR_VERSION@" />
+ Description="Upgrades older instances of MariaDB/MySQL services to version @MAJOR_VERSION@.@MINOR_VERSION@"
+ Advertise="no"/>
</Component>
<?endif?>
</Feature>
@@ -494,6 +572,7 @@ <SetProperty Sequence='execute' Before='CreateDatabaseCommand' Id="ALLOWREMOTEROOTACCESS" Value="--allow-remote-root-access">ALLOWREMOTEROOTACCESS</SetProperty>
<SetProperty Sequence='execute' Before='CreateDatabaseCommand' Id="DEFAULTUSER" Value="--default-user">DEFAULTUSER</SetProperty>
<CustomAction Id='CheckDatabaseProperties' BinaryKey='wixca.dll' DllEntry='CheckDatabaseProperties' />
+ <CustomAction Id='PresetDatabaseProperties' BinaryKey='wixca.dll' DllEntry='PresetDatabaseProperties' />
<CustomAction Id="CreateDatabaseCommand" Property="CreateDatabase"
Value=
""[#F.bin.mysql_install_db.exe]" "--service=[SERVICENAME]" --port=[PORT] "--password=[PASSWORD]" "--datadir=[DATADIR]\" [SKIPNETWORKING] [ALLOWREMOTEROOTACCESS] [DEFAULTUSER]"
@@ -576,9 +655,11 @@ BinaryKey="wixca.dll" DllEntry="CheckDBInUse" Execute="firstSequence"/>
<InstallExecuteSequence>
<Custom Action="CheckDBInUse" Before="LaunchConditions">Installed</Custom>
+ <Custom Action="PresetDatabaseProperties" After="CheckDBInUse"></Custom>
</InstallExecuteSequence>
<InstallUISequence>
<Custom Action="CheckDBInUse" Before="LaunchConditions">Installed</Custom>
+ <Custom Action="PresetDatabaseProperties" After="CheckDBInUse"></Custom>
</InstallUISequence>
<!-- Store some properties persistently in registry, mainly for upgrades -->
|