diff --git a/sql/mysql_install_db.cc b/sql/mysql_install_db.cc index adaf9401567..086dc292dec 100644 --- a/sql/mysql_install_db.cc +++ b/sql/mysql_install_db.cc @@ -114,13 +114,13 @@ static void die(const char *fmt, ...) fprintf(stderr, "FATAL ERROR: "); vfprintf(stderr, fmt, args); fputc('\n', stderr); - if (verbose_errors) - { - fprintf(stderr, - "http://kb.askmonty.org/v/installation-issues-on-windows contains some help\n" - "for solving the most common problems. If this doesn't help you, please\n" - "leave a comment in the knowledge base or file a bug report at\n" - "https://bugs.launchpad.net/maria"); + if (verbose_errors) + { + fprintf(stderr, + "http://kb.askmonty.org/v/installation-issues-on-windows contains some help\n" + "for solving the most common problems. If this doesn't help you, please\n" + "leave a comment in the knowledge base or file a bug report at\n" + "https://bugs.launchpad.net/maria"); } fflush(stderr); va_end(args); @@ -205,15 +205,15 @@ int main(int argc, char **argv) static void convert_slashes(char *s) { - for (; *s ; s++) - if (*s == '\\') + for (; *s ; s++) + if (*s == '\\') *s= '/'; } /** Calculate basedir from mysqld.exe path. - Basedir assumed to be is one level up from the mysqld.exe directory location. + Basedir assumed to be is one level up from the mysqld.exe directory location. E.g basedir for C:\my\bin\mysqld.exe would be C:\my */ @@ -322,7 +322,7 @@ static const char update_root_passwd_part2[]= static const char remove_default_user_cmd[]= "DELETE FROM mysql.user where User='';\n"; static const char allow_remote_root_access_cmd[]= - "CREATE TEMPORARY TABLE tmp_user LIKE user engine=memory;\n" + "CREATE TEMPORARY TABLE tmp_user LIKE user;\n" "INSERT INTO tmp_user SELECT * from user where user='root' " " AND host='localhost';\n" "UPDATE tmp_user SET host='%';\n" @@ -377,7 +377,7 @@ static int register_service() static void clean_directory(const char *dir) { char dir2[MAX_PATH+2]; - *(strmake(dir2, dir, MAX_PATH+1)+1)= 0; + *(strmake(dir2, dir, MAX_PATH+1)+1)= 0; SHFILEOPSTRUCT fileop; fileop.hwnd= NULL; /* no status display */ 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 +#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 @@ - + + + + + + + + + + + + + - - - + + + - + + + + @@ -142,6 +157,8 @@ + 1 @@ -261,6 +278,31 @@ EnableNetworking Not EnableNetworking + + + + {\Font1}Optimize for transactions + + + + (Uses transactional storage engine and "strict" SQL mode) + STDCONFIG + Not STDCONFIG + + + STDCONFIG + Not STDCONFIG + + + STDCONFIG + Not STDCONFIG + + + STDCONFIG + Not STDCONFIG + + + 1 @@ -379,7 +421,42 @@ - + + + STDCONFIG + + + + + + + 600)]]> @@ -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"/> @@ -494,6 +572,7 @@ ALLOWREMOTEROOTACCESS DEFAULTUSER + Installed + Installed +