Github user zellerh commented on a diff in the pull request:

    https://github.com/apache/trafodion/pull/1682#discussion_r213030480
  
    --- Diff: core/sql/sqludr/SqlUdrPredefLogReader.cpp ---
    @@ -1311,17 +1362,19 @@ bool ReadCppEventsUDFInterface::validateEvent(const 
UDRInvocationInfo &info,
         // All other comparisons are assumed to be string compares
         else
         {
    -      // convert predicate value
    +      // convert and trim predicate value
           temp = constStr;
           constStr.clear();
           for(size_t j = 0; j < temp.size(); ++j)
             constStr += (std::toupper(temp[j]));
    +      constStr.erase(constStr.find_last_not_of(" ")+1);
    --- End diff --
    
    That's a very good point. Actually, when I made the change I googled "trim 
string C++" and found something like this: 
https://stackoverflow.com/questions/216823/whats-the-best-way-to-trim-stdstring.
    
    Then I just copied the solution without thinking too much of it.
    
    When I debug it, it works fine and does not delete the entire string, but 
I'm not sure why. Adding 1 to string::npos clearly doesn't seem like a good 
idea.
    
    I'll change the code.


---

Reply via email to