diff options
| author | Ujp8LfXBJ6wCPR <github@lillecarl.com> | 2020-02-29 17:14:15 +0100 | 
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2021-12-22 20:29:49 +0100 | 
| commit | f871f0098e8953b2f585eacddaf7415c9ddc307a (patch) | |
| tree | 4adee9b00f6a903e03c1081e3b0eb398125206f2 /src/server/database/Database/PreparedStatement.h | |
| parent | e75750b867470076d419534f79ea14666dbe30fb (diff) | |
Replace MySQL prepared statement union with std::variant (#24158)
(cherry picked from commit 3ebcb71c3dc80e0bea9a36207401a033712bda88)
Diffstat (limited to 'src/server/database/Database/PreparedStatement.h')
| -rw-r--r-- | src/server/database/Database/PreparedStatement.h | 34 | 
1 files changed, 16 insertions, 18 deletions
diff --git a/src/server/database/Database/PreparedStatement.h b/src/server/database/Database/PreparedStatement.h index 7f20bb93adc..e11fcee5f85 100644 --- a/src/server/database/Database/PreparedStatement.h +++ b/src/server/database/Database/PreparedStatement.h @@ -22,27 +22,12 @@  #include "SQLOperation.h"  #include <future>  #include <vector> +#include <variant>  #ifdef __APPLE__  #undef TYPE_BOOL  #endif -//- Union for data buffer (upper-level bind -> queue -> lower-level bind) -union PreparedStatementDataUnion -{ -    bool boolean; -    uint8 ui8; -    int8 i8; -    uint16 ui16; -    int16 i16; -    uint32 ui32; -    int32 i32; -    uint64 ui64; -    int64 i64; -    float f; -    double d; -}; -  //- This enum helps us differ data held in above union  enum PreparedStatementValueType  { @@ -64,9 +49,22 @@ enum PreparedStatementValueType  struct PreparedStatementData  { -    PreparedStatementDataUnion data; +    std::variant< +    bool,               // TYPE_BOOL +    uint8,              // TYPE_UI8 +    uint16,             // TYPE_UI16 +    uint32,             // TYPE_UI32 +    uint64,             // TYPE_UI64 +    int8,               // TYPE_I8 +    int16,              // TYPE_I16 +    int32,              // TYPE_UI32 +    int64,              // TYPE_UI64 +    float,              // TYPE_FLOAT +    double,             // TYPE_DOUBLE +    std::string,        // TYPE_STRING +    std::vector<uint8>> // TYPE_BINARY +    data;      PreparedStatementValueType type; -    std::vector<uint8> binary;  };  //- Forward declare  | 
