diff options
-rw-r--r-- | cmake/options.cmake | 1 | ||||
-rw-r--r-- | cmake/showoptions.cmake | 11 | ||||
-rw-r--r-- | src/server/database/Database/Field.cpp | 22 |
3 files changed, 22 insertions, 12 deletions
diff --git a/cmake/options.cmake b/cmake/options.cmake index e99372b715a..44cb2531adb 100644 --- a/cmake/options.cmake +++ b/cmake/options.cmake @@ -48,6 +48,7 @@ else() endif() option(WITH_WARNINGS "Show all warnings during compile" 0) option(WITH_COREDEBUG "Include additional debug-code in core" 0) +option(WITH_STRICT_DATABASE_TYPE_CHECKS "Enable strict checking of database field value accessors" 0) set(WITH_SOURCE_TREE "hierarchical" CACHE STRING "Build the source tree for IDE's.") set_property(CACHE WITH_SOURCE_TREE PROPERTY STRINGS no flat hierarchical hierarchical-folders) option(WITHOUT_GIT "Disable the GIT testing routines" 0) diff --git a/cmake/showoptions.cmake b/cmake/showoptions.cmake index a4ed07dcaa8..07c78a06b6e 100644 --- a/cmake/showoptions.cmake +++ b/cmake/showoptions.cmake @@ -59,7 +59,7 @@ if( WITH_COREDEBUG ) message(" *** additional core debug logs have been enabled!") message(" *** this setting doesn't help to get better crash logs!") message(" *** in case you are searching for better crash logs use") - message(" *** -DCMAKE_BUILD_TYPE=RelWithDebug") + message(" *** -DCMAKE_BUILD_TYPE=RelWithDebInfo") message(" *** DO NOT ENABLE IT UNLESS YOU KNOW WHAT YOU'RE DOING!") message("* Use coreside debug : Yes") add_definitions(-DTRINITY_DEBUG) @@ -111,6 +111,15 @@ if ( PERFORMANCE_PROFILING ) add_definitions(-DPERFORMANCE_PROFILING) endif() +if( WITH_STRICT_DATABASE_TYPE_CHECKS ) + message("") + message(" *** WITH_STRICT_DATABASE_TYPE_CHECKS - WARNING!") + message(" *** Validates uses of database Get***() functions from Field class") + message(" *** invalid calls will result in returning value 0") + message(" *** NOT COMPATIBLE WITH MARIADB!") + add_definitions(-DTRINITY_STRICT_DATABASE_TYPE_CHECKS) +endif() + if (BUILD_SHARED_LIBS) message("") message(" *** WITH_DYNAMIC_LINKING - INFO!") diff --git a/src/server/database/Database/Field.cpp b/src/server/database/Database/Field.cpp index 4504587521c..b9d25b3da1b 100644 --- a/src/server/database/Database/Field.cpp +++ b/src/server/database/Database/Field.cpp @@ -35,7 +35,7 @@ uint8 Field::GetUInt8() const if (!data.value) return 0; -#ifdef TRINITY_DEBUG +#ifdef TRINITY_STRICT_DATABASE_TYPE_CHECKS if (!IsType(DatabaseFieldTypes::Int8)) { LogWrongType(__FUNCTION__); @@ -53,7 +53,7 @@ int8 Field::GetInt8() const if (!data.value) return 0; -#ifdef TRINITY_DEBUG +#ifdef TRINITY_STRICT_DATABASE_TYPE_CHECKS if (!IsType(DatabaseFieldTypes::Int8)) { LogWrongType(__FUNCTION__); @@ -71,7 +71,7 @@ uint16 Field::GetUInt16() const if (!data.value) return 0; -#ifdef TRINITY_DEBUG +#ifdef TRINITY_STRICT_DATABASE_TYPE_CHECKS if (!IsType(DatabaseFieldTypes::Int16)) { LogWrongType(__FUNCTION__); @@ -89,7 +89,7 @@ int16 Field::GetInt16() const if (!data.value) return 0; -#ifdef TRINITY_DEBUG +#ifdef TRINITY_STRICT_DATABASE_TYPE_CHECKS if (!IsType(DatabaseFieldTypes::Int16)) { LogWrongType(__FUNCTION__); @@ -107,7 +107,7 @@ uint32 Field::GetUInt32() const if (!data.value) return 0; -#ifdef TRINITY_DEBUG +#ifdef TRINITY_STRICT_DATABASE_TYPE_CHECKS if (!IsType(DatabaseFieldTypes::Int32)) { LogWrongType(__FUNCTION__); @@ -125,7 +125,7 @@ int32 Field::GetInt32() const if (!data.value) return 0; -#ifdef TRINITY_DEBUG +#ifdef TRINITY_STRICT_DATABASE_TYPE_CHECKS if (!IsType(DatabaseFieldTypes::Int32)) { LogWrongType(__FUNCTION__); @@ -143,7 +143,7 @@ uint64 Field::GetUInt64() const if (!data.value) return 0; -#ifdef TRINITY_DEBUG +#ifdef TRINITY_STRICT_DATABASE_TYPE_CHECKS if (!IsType(DatabaseFieldTypes::Int64)) { LogWrongType(__FUNCTION__); @@ -161,7 +161,7 @@ int64 Field::GetInt64() const if (!data.value) return 0; -#ifdef TRINITY_DEBUG +#ifdef TRINITY_STRICT_DATABASE_TYPE_CHECKS if (!IsType(DatabaseFieldTypes::Int64)) { LogWrongType(__FUNCTION__); @@ -179,7 +179,7 @@ float Field::GetFloat() const if (!data.value) return 0.0f; -#ifdef TRINITY_DEBUG +#ifdef TRINITY_STRICT_DATABASE_TYPE_CHECKS if (!IsType(DatabaseFieldTypes::Float)) { LogWrongType(__FUNCTION__); @@ -197,7 +197,7 @@ double Field::GetDouble() const if (!data.value) return 0.0f; -#ifdef TRINITY_DEBUG +#ifdef TRINITY_STRICT_DATABASE_TYPE_CHECKS if (!IsType(DatabaseFieldTypes::Double) && !IsType(DatabaseFieldTypes::Decimal)) { LogWrongType(__FUNCTION__); @@ -215,7 +215,7 @@ char const* Field::GetCString() const if (!data.value) return nullptr; -#ifdef TRINITY_DEBUG +#ifdef TRINITY_STRICT_DATABASE_TYPE_CHECKS if (IsNumeric() && data.raw) { LogWrongType(__FUNCTION__); |