Fix default collation for UTF16 strings

Fix our default collation which we install when an unknown collation is
requested to (more or less) support UTF16 strings as well. Before this
UTF16 strings wouldn't compare correctly because they might contain null
bytes which would lead to only the first (few) byte(s) getting compared.

See issue #1172.
This commit is contained in:
Martin Kleusberg
2017-10-19 14:54:30 +02:00
parent 32da4de94d
commit 4ae601dafd
2 changed files with 2 additions and 5 deletions

View File

@@ -29,11 +29,8 @@ template <typename Ret, typename... Params>
std::function<Ret(Params...)> Callback<Ret(Params...)>::func;
// collation callbacks
int collCompare(void* /*pArg*/, int /*eTextRepA*/, const void* sA, int /*eTextRepB*/, const void* sB)
int collCompare(void* /*pArg*/, int sizeA, const void* sA, int sizeB, const void* sB)
{
size_t sizeA = strlen((const char*)sA);
size_t sizeB = strlen((const char*)sB);
if(sizeA == sizeB)
return memcmp(sA, sB, sizeA);
return sizeA - sizeB;

View File

@@ -19,7 +19,7 @@ enum
typedef QMultiMap<QString, sqlb::ObjectPtr> objectMap; // Maps from object type (table, index, view, trigger) to a pointer to the object representation
typedef QMap<QString, objectMap> schemaMap; // Maps from the schema name (main, temp, attached schemas) to the object map for that schema
int collCompare(void* pArg, int eTextRepA, const void* sA, int eTextRepB, const void* sB);
int collCompare(void* pArg, int sizeA, const void* sA, int sizeB, const void* sB);
class DBBrowserDB : public QObject
{