From 2bdcb159eddcf7eacdac88c0351cdf8209bd0ef2 Mon Sep 17 00:00:00 2001 From: David Hall Date: Tue, 30 Jan 2018 16:07:51 -0600 Subject: [PATCH 1/4] MCOL-962 change mcssystemreadonly to a tri state return flag. Test for 0 to see if the system is in a writable state, --- dbcon/mysql/ha_calpont_impl.cpp | 48 ++++--------------------- dbcon/mysql/install_calpont_mysql.sh | 1 - utils/winport/win_setup_mysql_part2.sql | 1 - 3 files changed, 6 insertions(+), 44 deletions(-) diff --git a/dbcon/mysql/ha_calpont_impl.cpp b/dbcon/mysql/ha_calpont_impl.cpp index 3b3a5f00b..6f5204308 100755 --- a/dbcon/mysql/ha_calpont_impl.cpp +++ b/dbcon/mysql/ha_calpont_impl.cpp @@ -1866,7 +1866,7 @@ void mcssystemready_deinit(UDF_INIT* initid) #ifdef _MSC_VER __declspec(dllexport) #endif -// Return 1 if system is read only; 0 if writeable +// Return non-zero if system is read only; 0 if writeable long long mcssystemreadonly(UDF_INIT* initid, UDF_ARGS* args, char* is_null, char* error) { @@ -1875,9 +1875,13 @@ long long mcssystemreadonly(UDF_INIT* initid, UDF_ARGS* args, try { + if (dbrm.getSystemSuspended()) + { + rtn = 1; + } if (dbrm.isReadWrite()) // Returns 0 for writable, 5 for read only { - rtn = 1; + rtn = 2; } } catch (...) @@ -1903,46 +1907,6 @@ void mcssystemreadonly_deinit(UDF_INIT* initid) { } -#ifdef _MSC_VER -__declspec(dllexport) -#endif -// Return 1 if system is read only; 0 if writeable -long long mcswritessuspended(UDF_INIT* initid, UDF_ARGS* args, - char* is_null, char* error) -{ - long long rtn = 0; - DBRM dbrm(true); - - try - { - if (dbrm.getSystemSuspended()) - { - rtn = 1; - } - } - catch (...) - { - *error = 1; - rtn = 1; - } - return rtn; -} - -#ifdef _MSC_VER -__declspec(dllexport) -#endif -my_bool mcswritessuspended_init(UDF_INIT* initid, UDF_ARGS* args, char* message) -{ - return 0; -} - -#ifdef _MSC_VER -__declspec(dllexport) -#endif -void mcswritessuspended_deinit(UDF_INIT* initid) -{ -} - #define MAXSTRINGLENGTH 50 const char* PmSmallSideMaxMemory = "pmmaxmemorysmallside"; diff --git a/dbcon/mysql/install_calpont_mysql.sh b/dbcon/mysql/install_calpont_mysql.sh index 17c6e1817..e8eb5b2b0 100755 --- a/dbcon/mysql/install_calpont_mysql.sh +++ b/dbcon/mysql/install_calpont_mysql.sh @@ -84,7 +84,6 @@ CREATE FUNCTION idbpartition RETURNS STRING soname 'libcalmysql.so'; CREATE FUNCTION idblocalpm RETURNS INTEGER soname 'libcalmysql.so'; CREATE FUNCTION mcssystemready RETURNS INTEGER soname 'libcalmysql.so'; CREATE FUNCTION mcssystemreadonly RETURNS INTEGER soname 'libcalmysql.so'; -CREATE FUNCTION mcswritessuspended RETURNS INTEGER soname 'libcalmysql.so'; CREATE DATABASE IF NOT EXISTS infinidb_vtable; CREATE DATABASE IF NOT EXISTS infinidb_querystats; diff --git a/utils/winport/win_setup_mysql_part2.sql b/utils/winport/win_setup_mysql_part2.sql index 0a2a972fb..3ac04dcad 100644 --- a/utils/winport/win_setup_mysql_part2.sql +++ b/utils/winport/win_setup_mysql_part2.sql @@ -11,7 +11,6 @@ CREATE FUNCTION calcleartablelock RETURNS STRING SONAME 'libcalmysql.dll'; CREATE FUNCTION calgetsqlcount RETURNS STRING SONAME 'libcalmysql.dll'; CREATE FUNCTION mcssystemready RETURNS INTEGER SONAME 'libcalmysql.dll'; CREATE FUNCTION mcssystemreadonly RETURNS INTEGER SONAME 'libcalmysql.dll'; -CREATE FUNCTION mcswritessuspended RETURNS INTEGER SONAME 'libcalmysql.dll'; create database if not exists calpontsys; use calpontsys; From 43f322ea2fc1f34208e403da1a7702fc5dcb7fd6 Mon Sep 17 00:00:00 2001 From: David Hall Date: Tue, 30 Jan 2018 16:19:17 -0600 Subject: [PATCH 2/4] MCOL-962 formating --- dbcon/mysql/ha_calpont_impl.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/dbcon/mysql/ha_calpont_impl.cpp b/dbcon/mysql/ha_calpont_impl.cpp index 6f5204308..3eb5a20ab 100755 --- a/dbcon/mysql/ha_calpont_impl.cpp +++ b/dbcon/mysql/ha_calpont_impl.cpp @@ -1824,7 +1824,7 @@ __declspec(dllexport) #endif // Return 1 if system is ready for reads or 0 if not. long long mcssystemready(UDF_INIT* initid, UDF_ARGS* args, - char* is_null, char* error) + char* is_null, char* error) { long long rtn = 0; Oam oam; @@ -1853,7 +1853,7 @@ __declspec(dllexport) #endif my_bool mcssystemready_init(UDF_INIT* initid, UDF_ARGS* args, char* message) { - return 0; + return 0; } #ifdef _MSC_VER @@ -1868,17 +1868,17 @@ __declspec(dllexport) #endif // Return non-zero if system is read only; 0 if writeable long long mcssystemreadonly(UDF_INIT* initid, UDF_ARGS* args, - char* is_null, char* error) + char* is_null, char* error) { long long rtn = 0; DBRM dbrm(true); try { - if (dbrm.getSystemSuspended()) - { - rtn = 1; - } + if (dbrm.getSystemSuspended()) + { + rtn = 1; + } if (dbrm.isReadWrite()) // Returns 0 for writable, 5 for read only { rtn = 2; @@ -1897,7 +1897,7 @@ __declspec(dllexport) #endif my_bool mcssystemreadonly_init(UDF_INIT* initid, UDF_ARGS* args, char* message) { - return 0; + return 0; } #ifdef _MSC_VER From 243e9e9fb89f23fc72232b2d78ab14c37ba54751 Mon Sep 17 00:00:00 2001 From: David Hall Date: Tue, 30 Jan 2018 16:21:47 -0600 Subject: [PATCH 3/4] MCOL-962 format --- dbcon/mysql/ha_calpont_impl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dbcon/mysql/ha_calpont_impl.cpp b/dbcon/mysql/ha_calpont_impl.cpp index 3eb5a20ab..5ca18e212 100755 --- a/dbcon/mysql/ha_calpont_impl.cpp +++ b/dbcon/mysql/ha_calpont_impl.cpp @@ -1824,7 +1824,7 @@ __declspec(dllexport) #endif // Return 1 if system is ready for reads or 0 if not. long long mcssystemready(UDF_INIT* initid, UDF_ARGS* args, - char* is_null, char* error) + char* is_null, char* error) { long long rtn = 0; Oam oam; @@ -1868,7 +1868,7 @@ __declspec(dllexport) #endif // Return non-zero if system is read only; 0 if writeable long long mcssystemreadonly(UDF_INIT* initid, UDF_ARGS* args, - char* is_null, char* error) + char* is_null, char* error) { long long rtn = 0; DBRM dbrm(true); From 59f7e142309c50f4c796ea7e7314f20943f3ffc6 Mon Sep 17 00:00:00 2001 From: David Hall Date: Tue, 30 Jan 2018 16:25:15 -0600 Subject: [PATCH 4/4] MCOL-962 returned wrong value. --- dbcon/mysql/ha_calpont_impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbcon/mysql/ha_calpont_impl.cpp b/dbcon/mysql/ha_calpont_impl.cpp index 5ca18e212..196ca2202 100755 --- a/dbcon/mysql/ha_calpont_impl.cpp +++ b/dbcon/mysql/ha_calpont_impl.cpp @@ -1879,7 +1879,7 @@ long long mcssystemreadonly(UDF_INIT* initid, UDF_ARGS* args, { rtn = 1; } - if (dbrm.isReadWrite()) // Returns 0 for writable, 5 for read only + if (dbrm.isReadWrite() > 0) // Returns 0 for writable, 5 for read only { rtn = 2; }