From b747e9ab9216fe3b449dca12f7fe1082d9bbd02e Mon Sep 17 00:00:00 2001 From: David Hall Date: Mon, 7 Oct 2019 09:21:09 -0500 Subject: [PATCH 1/9] MCOL-3536 use Locale for compare of strings in ORDER BY --- dbcon/joblist/limitedorderby.h | 5 ++--- utils/funcexp/utils_utf8.h | 2 +- utils/rowgroup/rowgroup.h | 12 ++++++++++++ utils/windowfunction/idborderby.cpp | 12 +++++------- 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/dbcon/joblist/limitedorderby.h b/dbcon/joblist/limitedorderby.h index 3ff266aa3..5b1a02acc 100644 --- a/dbcon/joblist/limitedorderby.h +++ b/dbcon/joblist/limitedorderby.h @@ -54,11 +54,10 @@ public: void finalize(); protected: - uint64_t fStart; - uint64_t fCount; + uint64_t fStart; + uint64_t fCount; }; - } #endif // LIMITED_ORDER_BY_H diff --git a/utils/funcexp/utils_utf8.h b/utils/funcexp/utils_utf8.h index 23d41ce7e..cca738ef0 100644 --- a/utils/funcexp/utils_utf8.h +++ b/utils/funcexp/utils_utf8.h @@ -53,7 +53,7 @@ extern std::locale loc; // Is there a way to construct a global reference to a facet? // const std::collate& coll = std::use_facet >(loc); -//Infinidb version of strlocale BUG 5362 +//Columnstore version of strlocale BUG 5362 //set System Locale "C" by default //return the system Locale currently set in from Columnstore.xml inline diff --git a/utils/rowgroup/rowgroup.h b/utils/rowgroup/rowgroup.h index 373269e13..c4b419393 100644 --- a/utils/rowgroup/rowgroup.h +++ b/utils/rowgroup/rowgroup.h @@ -375,6 +375,7 @@ public: inline std::string getStringField(uint32_t colIndex) const; inline const uint8_t* getStringPointer(uint32_t colIndex) const; inline uint32_t getStringLength(uint32_t colIndex) const; + inline const char* getCharPtrField(uint32_t colIndex, int& len) const; void setStringField(const std::string& val, uint32_t colIndex); inline void setStringField(const uint8_t*, uint32_t len, uint32_t colIndex); @@ -774,6 +775,17 @@ inline std::string Row::getStringField(uint32_t colIndex) const strnlen((char*) &data[offsets[colIndex]], getColumnWidth(colIndex))); } +// Return a char* to the string field with len +inline const char* Row::getCharPtrField(uint32_t colIndex, int& len) const +{ + len = getStringLength(colIndex); + if (inStringTable(colIndex)) + { + return (const char*)strings->getPointer(*((uint64_t*) &data[offsets[colIndex]])); + } + return (char*)&data[offsets[colIndex]]; +} + inline std::string Row::getVarBinaryStringField(uint32_t colIndex) const { if (inStringTable(colIndex)) diff --git a/utils/windowfunction/idborderby.cpp b/utils/windowfunction/idborderby.cpp index 8e5a63e1f..e7f8dbaf3 100644 --- a/utils/windowfunction/idborderby.cpp +++ b/utils/windowfunction/idborderby.cpp @@ -130,13 +130,11 @@ int StringCompare::operator()(IdbCompare* l, Row::Pointer r1, Row::Pointer r2) } else { - string v1 = l->row1().getStringField(fSpec.fIndex); - string v2 = l->row2().getStringField(fSpec.fIndex); - - if (v1 > v2) - ret = fSpec.fAsc; - else if (v1 < v2) - ret = -fSpec.fAsc; + int len1, len2; + const char* s1 = l->row1().getCharPtrField(fSpec.fIndex, len1); + const char* s2 = l->row2().getCharPtrField(fSpec.fIndex, len2); + const std::collate& coll = std::use_facet >(loc); + ret = fSpec.fAsc * coll.compare(s1, s1+len1, s2, s2+len2); } return ret; From 78c96fc65b9f080a2a157c3bb412cf787bea0b62 Mon Sep 17 00:00:00 2001 From: David Hall Date: Tue, 8 Oct 2019 12:01:15 -0500 Subject: [PATCH 2/9] MCOL-3536 Add collation stuff to IDBSortSpec --- utils/windowfunction/idborderby.h | 92 ++++++++++++++++++++++++++++++- 1 file changed, 91 insertions(+), 1 deletion(-) diff --git a/utils/windowfunction/idborderby.h b/utils/windowfunction/idborderby.h index 4453828ba..37c69c859 100644 --- a/utils/windowfunction/idborderby.h +++ b/utils/windowfunction/idborderby.h @@ -63,6 +63,7 @@ struct IdbSortSpec // TODO There are three ordering specs since 10.2 int fAsc; // ::= ASC | DESC int fNf; // ::= NULLS FIRST | NULLS LAST + std::string fLocale; IdbSortSpec() : fIndex(-1), fAsc(1), fNf(1) {} IdbSortSpec(int i, bool b) : fIndex(i), fAsc(b ? 1 : -1), fNf(fAsc) {} @@ -75,13 +76,42 @@ struct IdbSortSpec class Compare { public: - Compare(const IdbSortSpec& spec) : fSpec(spec) {} + Compare(const IdbSortSpec& spec) : fSpec(spec) + { + // Save off the current Locale in case something goes wrong. + std::string curLocale = setlocale(LC_COLLATE, NULL); + if (spec.fLocale.length() > 0) + { + fLocale = spec.fLocale; + } + else + { + fLocale = curLocale; + } + + try + { + std::locale localloc(fLocale.c_str()); + loc = localloc; + } + catch(...) + { + fLocale = curLocale; + std::locale localloc(fLocale.c_str()); + loc = localloc; + } + if (fLocale.find("ja_JP") != std::string::npos) + JPcodePoint = true; + } virtual ~Compare() {} virtual int operator()(IdbCompare*, rowgroup::Row::Pointer, rowgroup::Row::Pointer) = 0; protected: IdbSortSpec fSpec; + std::string fLocale; + std::locale loc; + bool JPcodePoint; // code point ordering (Japanese UTF) flag }; @@ -291,9 +321,69 @@ protected: uint64_t fErrorCode; joblist::ResourceManager* fRm; boost::shared_ptr fSessionMemLimit; + std::string fLocale; + bool JPcodePoint; }; +// Set the locale based on the passed in string. If NULL, +// use the value from system config with a default of "C" +#if 0 +inline +std::string IdbOrderBy::setlocale() +{ + // get and set locale language + std::string systemLang("C"); + oam::Oam oam; + if (fLocale.length() == 0) + { + return; + } + + char* pLoc = setlocale(LC_ALL, fLocale.c_str()); + + if (pLoc == NULL) + { + try + { + //send alarm + alarmmanager::ALARMManager alarmMgr; + std::string alarmItem = "system"; + alarmMgr.sendAlarmReport(alarmItem.c_str(), oam::INVALID_LOCALE, alarmmanager::SET); + printf("Failed to set locale : %s, Critical alarm generated\n", systemLang.c_str()); + } + catch (...) + { + // Ignoring for time being. + } + } + else + { + try + { + //send alarm + alarmmanager::ALARMManager alarmMgr; + std::string alarmItem = "system"; + alarmMgr.sendAlarmReport(alarmItem.c_str(), oam::INVALID_LOCALE, alarmmanager::CLEAR); + } + catch (...) + { + // Ignoring for time being. + } + + } + + printf ("Locale is : %s\n", systemLang.c_str() ); + + //BUG 2991 + setlocale(LC_NUMERIC, "C"); + + if (systemLang.find("ja_JP") != std::string::npos) + JPcodePoint = true; + + return systemLang; +} +#endif } #endif // IDB_ORDER_BY_H From 8f1cc7ad65f359234e9b2f2ff1f5dbb4b042b540 Mon Sep 17 00:00:00 2001 From: David Hall Date: Wed, 9 Oct 2019 09:04:10 -0500 Subject: [PATCH 3/9] MCOL-3536 Use already existing Row:getStringPointer() --- utils/rowgroup/rowgroup.h | 12 ------------ utils/windowfunction/idborderby.cpp | 7 ++++--- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/utils/rowgroup/rowgroup.h b/utils/rowgroup/rowgroup.h index c4b419393..373269e13 100644 --- a/utils/rowgroup/rowgroup.h +++ b/utils/rowgroup/rowgroup.h @@ -375,7 +375,6 @@ public: inline std::string getStringField(uint32_t colIndex) const; inline const uint8_t* getStringPointer(uint32_t colIndex) const; inline uint32_t getStringLength(uint32_t colIndex) const; - inline const char* getCharPtrField(uint32_t colIndex, int& len) const; void setStringField(const std::string& val, uint32_t colIndex); inline void setStringField(const uint8_t*, uint32_t len, uint32_t colIndex); @@ -775,17 +774,6 @@ inline std::string Row::getStringField(uint32_t colIndex) const strnlen((char*) &data[offsets[colIndex]], getColumnWidth(colIndex))); } -// Return a char* to the string field with len -inline const char* Row::getCharPtrField(uint32_t colIndex, int& len) const -{ - len = getStringLength(colIndex); - if (inStringTable(colIndex)) - { - return (const char*)strings->getPointer(*((uint64_t*) &data[offsets[colIndex]])); - } - return (char*)&data[offsets[colIndex]]; -} - inline std::string Row::getVarBinaryStringField(uint32_t colIndex) const { if (inStringTable(colIndex)) diff --git a/utils/windowfunction/idborderby.cpp b/utils/windowfunction/idborderby.cpp index 1f87a33e9..437f56bf4 100644 --- a/utils/windowfunction/idborderby.cpp +++ b/utils/windowfunction/idborderby.cpp @@ -130,9 +130,10 @@ int StringCompare::operator()(IdbCompare* l, Row::Pointer r1, Row::Pointer r2) } else { - int len1, len2; - const char* s1 = l->row1().getCharPtrField(fSpec.fIndex, len1); - const char* s2 = l->row2().getCharPtrField(fSpec.fIndex, len2); + int len1 = l->row1().getStringLength(fSpec.fIndex); + int len2 = l->row2().getStringLength(fSpec.fIndex); + const char* s1 = (const char*)l->row1().getStringPointer(fSpec.fIndex); + const char* s2 = (const char*)l->row2().getStringPointer(fSpec.fIndex); const std::collate& coll = std::use_facet >(loc); ret = fSpec.fAsc * coll.compare(s1, s1+len1, s2, s2+len2); } From c5cc5f20c969b957f48f0a1420d5bab216c62c1f Mon Sep 17 00:00:00 2001 From: David Hall Date: Wed, 16 Oct 2019 09:42:25 -0500 Subject: [PATCH 4/9] MCOL-3518 Set number of decimals for regr_avgx and regr_avgy in init. --- utils/regr/regrmysql.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/utils/regr/regrmysql.cpp b/utils/regr/regrmysql.cpp index 2570163f1..a27d94a67 100644 --- a/utils/regr/regrmysql.cpp +++ b/utils/regr/regrmysql.cpp @@ -167,14 +167,10 @@ extern "C" strcpy(message,"regr_avgx() with a non-numeric independant (second) argument"); return 1; } - if (args->arg_type[1] == DECIMAL_RESULT && initid->decimals != DECIMAL_NOT_SPECIFIED) + if (initid->decimals != DECIMAL_NOT_SPECIFIED) { initid->decimals += 4; } - else - { - initid->decimals = DECIMAL_NOT_SPECIFIED; - } if (!(data = (struct regr_avgx_data*) malloc(sizeof(struct regr_avgx_data)))) { @@ -275,14 +271,10 @@ extern "C" return 1; } - if (args->arg_type[0] == DECIMAL_RESULT && initid->decimals != DECIMAL_NOT_SPECIFIED) + if (initid->decimals != DECIMAL_NOT_SPECIFIED) { initid->decimals += 4; } - else - { - initid->decimals = DECIMAL_NOT_SPECIFIED; - } if (!(data = (struct regr_avgy_data*) malloc(sizeof(struct regr_avgy_data)))) { From 9c97a794f2949e471eb06b23ad553aef2bd80fd4 Mon Sep 17 00:00:00 2001 From: David Hall Date: Wed, 16 Oct 2019 10:08:12 -0500 Subject: [PATCH 5/9] Revert "MCOL-3536 Add collation stuff to IDBSortSpec" This reverts commit 78c96fc65b9f080a2a157c3bb412cf787bea0b62. --- utils/windowfunction/idborderby.h | 92 +------------------------------ 1 file changed, 1 insertion(+), 91 deletions(-) diff --git a/utils/windowfunction/idborderby.h b/utils/windowfunction/idborderby.h index d02b4870f..b11b9c44e 100644 --- a/utils/windowfunction/idborderby.h +++ b/utils/windowfunction/idborderby.h @@ -63,7 +63,6 @@ struct IdbSortSpec // TODO There are three ordering specs since 10.2 int fAsc; // ::= ASC | DESC int fNf; // ::= NULLS FIRST | NULLS LAST - std::string fLocale; IdbSortSpec() : fIndex(-1), fAsc(1), fNf(1) {} IdbSortSpec(int i, bool b) : fIndex(i), fAsc(b ? 1 : -1), fNf(fAsc) {} @@ -76,42 +75,13 @@ struct IdbSortSpec class Compare { public: - Compare(const IdbSortSpec& spec) : fSpec(spec) - { - // Save off the current Locale in case something goes wrong. - std::string curLocale = setlocale(LC_COLLATE, NULL); - if (spec.fLocale.length() > 0) - { - fLocale = spec.fLocale; - } - else - { - fLocale = curLocale; - } - - try - { - std::locale localloc(fLocale.c_str()); - loc = localloc; - } - catch(...) - { - fLocale = curLocale; - std::locale localloc(fLocale.c_str()); - loc = localloc; - } - if (fLocale.find("ja_JP") != std::string::npos) - JPcodePoint = true; - } + Compare(const IdbSortSpec& spec) : fSpec(spec) {} virtual ~Compare() {} virtual int operator()(IdbCompare*, rowgroup::Row::Pointer, rowgroup::Row::Pointer) = 0; protected: IdbSortSpec fSpec; - std::string fLocale; - std::locale loc; - bool JPcodePoint; // code point ordering (Japanese UTF) flag }; @@ -330,69 +300,9 @@ protected: uint64_t fErrorCode; joblist::ResourceManager* fRm; boost::shared_ptr fSessionMemLimit; - std::string fLocale; - bool JPcodePoint; }; -// Set the locale based on the passed in string. If NULL, -// use the value from system config with a default of "C" -#if 0 -inline -std::string IdbOrderBy::setlocale() -{ - // get and set locale language - std::string systemLang("C"); - oam::Oam oam; - if (fLocale.length() == 0) - { - return; - } - - char* pLoc = setlocale(LC_ALL, fLocale.c_str()); - - if (pLoc == NULL) - { - try - { - //send alarm - alarmmanager::ALARMManager alarmMgr; - std::string alarmItem = "system"; - alarmMgr.sendAlarmReport(alarmItem.c_str(), oam::INVALID_LOCALE, alarmmanager::SET); - printf("Failed to set locale : %s, Critical alarm generated\n", systemLang.c_str()); - } - catch (...) - { - // Ignoring for time being. - } - } - else - { - try - { - //send alarm - alarmmanager::ALARMManager alarmMgr; - std::string alarmItem = "system"; - alarmMgr.sendAlarmReport(alarmItem.c_str(), oam::INVALID_LOCALE, alarmmanager::CLEAR); - } - catch (...) - { - // Ignoring for time being. - } - - } - - printf ("Locale is : %s\n", systemLang.c_str() ); - - //BUG 2991 - setlocale(LC_NUMERIC, "C"); - - if (systemLang.find("ja_JP") != std::string::npos) - JPcodePoint = true; - - return systemLang; -} -#endif } #endif // IDB_ORDER_BY_H From d0bb6fddbcb50fd0e9cc49a4784b386a117a405a Mon Sep 17 00:00:00 2001 From: David Hall Date: Wed, 16 Oct 2019 10:08:47 -0500 Subject: [PATCH 6/9] Revert "MCOL-3518 Set number of decimals for regr_avgx and regr_avgy in init." This reverts commit c5cc5f20c969b957f48f0a1420d5bab216c62c1f. --- utils/regr/regrmysql.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/utils/regr/regrmysql.cpp b/utils/regr/regrmysql.cpp index a27d94a67..2570163f1 100644 --- a/utils/regr/regrmysql.cpp +++ b/utils/regr/regrmysql.cpp @@ -167,10 +167,14 @@ extern "C" strcpy(message,"regr_avgx() with a non-numeric independant (second) argument"); return 1; } - if (initid->decimals != DECIMAL_NOT_SPECIFIED) + if (args->arg_type[1] == DECIMAL_RESULT && initid->decimals != DECIMAL_NOT_SPECIFIED) { initid->decimals += 4; } + else + { + initid->decimals = DECIMAL_NOT_SPECIFIED; + } if (!(data = (struct regr_avgx_data*) malloc(sizeof(struct regr_avgx_data)))) { @@ -271,10 +275,14 @@ extern "C" return 1; } - if (initid->decimals != DECIMAL_NOT_SPECIFIED) + if (args->arg_type[0] == DECIMAL_RESULT && initid->decimals != DECIMAL_NOT_SPECIFIED) { initid->decimals += 4; } + else + { + initid->decimals = DECIMAL_NOT_SPECIFIED; + } if (!(data = (struct regr_avgy_data*) malloc(sizeof(struct regr_avgy_data)))) { From df47f0f32da4fe1a4ad0f316bede84f999295047 Mon Sep 17 00:00:00 2001 From: David Hall Date: Wed, 16 Oct 2019 10:14:10 -0500 Subject: [PATCH 7/9] Revert "MCOL-3536 Use already existing Row:getStringPointer()" This reverts commit 8f1cc7ad65f359234e9b2f2ff1f5dbb4b042b540. --- utils/rowgroup/rowgroup.h | 12 ++++++++++++ utils/windowfunction/idborderby.cpp | 7 +++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/utils/rowgroup/rowgroup.h b/utils/rowgroup/rowgroup.h index 373269e13..c4b419393 100644 --- a/utils/rowgroup/rowgroup.h +++ b/utils/rowgroup/rowgroup.h @@ -375,6 +375,7 @@ public: inline std::string getStringField(uint32_t colIndex) const; inline const uint8_t* getStringPointer(uint32_t colIndex) const; inline uint32_t getStringLength(uint32_t colIndex) const; + inline const char* getCharPtrField(uint32_t colIndex, int& len) const; void setStringField(const std::string& val, uint32_t colIndex); inline void setStringField(const uint8_t*, uint32_t len, uint32_t colIndex); @@ -774,6 +775,17 @@ inline std::string Row::getStringField(uint32_t colIndex) const strnlen((char*) &data[offsets[colIndex]], getColumnWidth(colIndex))); } +// Return a char* to the string field with len +inline const char* Row::getCharPtrField(uint32_t colIndex, int& len) const +{ + len = getStringLength(colIndex); + if (inStringTable(colIndex)) + { + return (const char*)strings->getPointer(*((uint64_t*) &data[offsets[colIndex]])); + } + return (char*)&data[offsets[colIndex]]; +} + inline std::string Row::getVarBinaryStringField(uint32_t colIndex) const { if (inStringTable(colIndex)) diff --git a/utils/windowfunction/idborderby.cpp b/utils/windowfunction/idborderby.cpp index 703008183..7fb415353 100644 --- a/utils/windowfunction/idborderby.cpp +++ b/utils/windowfunction/idborderby.cpp @@ -130,10 +130,9 @@ int StringCompare::operator()(IdbCompare* l, Row::Pointer r1, Row::Pointer r2) } else { - int len1 = l->row1().getStringLength(fSpec.fIndex); - int len2 = l->row2().getStringLength(fSpec.fIndex); - const char* s1 = (const char*)l->row1().getStringPointer(fSpec.fIndex); - const char* s2 = (const char*)l->row2().getStringPointer(fSpec.fIndex); + int len1, len2; + const char* s1 = l->row1().getCharPtrField(fSpec.fIndex, len1); + const char* s2 = l->row2().getCharPtrField(fSpec.fIndex, len2); const std::collate& coll = std::use_facet >(loc); ret = fSpec.fAsc * coll.compare(s1, s1+len1, s2, s2+len2); } From 788d5b4abc989db307e4b79bc2fcb2427ace613a Mon Sep 17 00:00:00 2001 From: David Hall Date: Wed, 16 Oct 2019 10:16:42 -0500 Subject: [PATCH 8/9] Revert "Revert "MCOL-3518 Set number of decimals for regr_avgx and regr_avgy in init."" This reverts commit d0bb6fddbcb50fd0e9cc49a4784b386a117a405a. --- utils/regr/regrmysql.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/utils/regr/regrmysql.cpp b/utils/regr/regrmysql.cpp index 2570163f1..a27d94a67 100644 --- a/utils/regr/regrmysql.cpp +++ b/utils/regr/regrmysql.cpp @@ -167,14 +167,10 @@ extern "C" strcpy(message,"regr_avgx() with a non-numeric independant (second) argument"); return 1; } - if (args->arg_type[1] == DECIMAL_RESULT && initid->decimals != DECIMAL_NOT_SPECIFIED) + if (initid->decimals != DECIMAL_NOT_SPECIFIED) { initid->decimals += 4; } - else - { - initid->decimals = DECIMAL_NOT_SPECIFIED; - } if (!(data = (struct regr_avgx_data*) malloc(sizeof(struct regr_avgx_data)))) { @@ -275,14 +271,10 @@ extern "C" return 1; } - if (args->arg_type[0] == DECIMAL_RESULT && initid->decimals != DECIMAL_NOT_SPECIFIED) + if (initid->decimals != DECIMAL_NOT_SPECIFIED) { initid->decimals += 4; } - else - { - initid->decimals = DECIMAL_NOT_SPECIFIED; - } if (!(data = (struct regr_avgy_data*) malloc(sizeof(struct regr_avgy_data)))) { From 6630df3cb22142cf577b529027c0e168c9c6641f Mon Sep 17 00:00:00 2001 From: David Hall Date: Wed, 16 Oct 2019 10:20:18 -0500 Subject: [PATCH 9/9] Revert "MCOL-3536 use Locale for compare of strings in ORDER BY" This reverts commit b747e9ab9216fe3b449dca12f7fe1082d9bbd02e. --- dbcon/joblist/limitedorderby.h | 5 +++-- utils/funcexp/utils_utf8.h | 2 +- utils/rowgroup/rowgroup.h | 12 ------------ utils/windowfunction/idborderby.cpp | 12 +++++++----- 4 files changed, 11 insertions(+), 20 deletions(-) diff --git a/dbcon/joblist/limitedorderby.h b/dbcon/joblist/limitedorderby.h index 5b1a02acc..3ff266aa3 100644 --- a/dbcon/joblist/limitedorderby.h +++ b/dbcon/joblist/limitedorderby.h @@ -54,10 +54,11 @@ public: void finalize(); protected: - uint64_t fStart; - uint64_t fCount; + uint64_t fStart; + uint64_t fCount; }; + } #endif // LIMITED_ORDER_BY_H diff --git a/utils/funcexp/utils_utf8.h b/utils/funcexp/utils_utf8.h index cca738ef0..23d41ce7e 100644 --- a/utils/funcexp/utils_utf8.h +++ b/utils/funcexp/utils_utf8.h @@ -53,7 +53,7 @@ extern std::locale loc; // Is there a way to construct a global reference to a facet? // const std::collate& coll = std::use_facet >(loc); -//Columnstore version of strlocale BUG 5362 +//Infinidb version of strlocale BUG 5362 //set System Locale "C" by default //return the system Locale currently set in from Columnstore.xml inline diff --git a/utils/rowgroup/rowgroup.h b/utils/rowgroup/rowgroup.h index c4b419393..373269e13 100644 --- a/utils/rowgroup/rowgroup.h +++ b/utils/rowgroup/rowgroup.h @@ -375,7 +375,6 @@ public: inline std::string getStringField(uint32_t colIndex) const; inline const uint8_t* getStringPointer(uint32_t colIndex) const; inline uint32_t getStringLength(uint32_t colIndex) const; - inline const char* getCharPtrField(uint32_t colIndex, int& len) const; void setStringField(const std::string& val, uint32_t colIndex); inline void setStringField(const uint8_t*, uint32_t len, uint32_t colIndex); @@ -775,17 +774,6 @@ inline std::string Row::getStringField(uint32_t colIndex) const strnlen((char*) &data[offsets[colIndex]], getColumnWidth(colIndex))); } -// Return a char* to the string field with len -inline const char* Row::getCharPtrField(uint32_t colIndex, int& len) const -{ - len = getStringLength(colIndex); - if (inStringTable(colIndex)) - { - return (const char*)strings->getPointer(*((uint64_t*) &data[offsets[colIndex]])); - } - return (char*)&data[offsets[colIndex]]; -} - inline std::string Row::getVarBinaryStringField(uint32_t colIndex) const { if (inStringTable(colIndex)) diff --git a/utils/windowfunction/idborderby.cpp b/utils/windowfunction/idborderby.cpp index 7fb415353..f6e88bd7e 100644 --- a/utils/windowfunction/idborderby.cpp +++ b/utils/windowfunction/idborderby.cpp @@ -130,11 +130,13 @@ int StringCompare::operator()(IdbCompare* l, Row::Pointer r1, Row::Pointer r2) } else { - int len1, len2; - const char* s1 = l->row1().getCharPtrField(fSpec.fIndex, len1); - const char* s2 = l->row2().getCharPtrField(fSpec.fIndex, len2); - const std::collate& coll = std::use_facet >(loc); - ret = fSpec.fAsc * coll.compare(s1, s1+len1, s2, s2+len2); + string v1 = l->row1().getStringField(fSpec.fIndex); + string v2 = l->row2().getStringField(fSpec.fIndex); + + if (v1 > v2) + ret = fSpec.fAsc; + else if (v1 < v2) + ret = -fSpec.fAsc; } return ret;