Repository: trafodion
Updated Branches:
  refs/heads/master 0f5f8a7a3 -> ed0daf50f


[TRAFODION-3088] Fix data conversion issue with INTERVAL literals


Project: http://git-wip-us.apache.org/repos/asf/trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafodion/commit/3662b90c
Tree: http://git-wip-us.apache.org/repos/asf/trafodion/tree/3662b90c
Diff: http://git-wip-us.apache.org/repos/asf/trafodion/diff/3662b90c

Branch: refs/heads/master
Commit: 3662b90c7a51513a6f5cf0bd31943fbf4c996cfe
Parents: b04bfda
Author: Dave Birdsall <[email protected]>
Authored: Tue May 29 20:32:37 2018 +0000
Committer: Dave Birdsall <[email protected]>
Committed: Tue May 29 20:32:37 2018 +0000

----------------------------------------------------------------------
 core/sql/optimizer/ValueDesc.cpp | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafodion/blob/3662b90c/core/sql/optimizer/ValueDesc.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/ValueDesc.cpp b/core/sql/optimizer/ValueDesc.cpp
index 45f92e1..e32b3d5 100644
--- a/core/sql/optimizer/ValueDesc.cpp
+++ b/core/sql/optimizer/ValueDesc.cpp
@@ -6382,7 +6382,32 @@ void ValueIdList::convertToTextKey(const ValueIdList& 
keyList, NAString& result)
         {
            short vLen = val.length();
 
-          if ((constType->getTypeQualifier()  == NA_NUMERIC_TYPE) &&
+          if (constType->getTypeQualifier() == NA_INTERVAL_TYPE)
+            {
+              // In some code paths, the text may have "INTERVAL 'xxx' 
<qualifier>"
+              // junk around it so we have to strip that off. (Example: An 
equality
+              // predicate when query caching has been turned off via 
+              // CQD QUERY_CACHE '0'. Another example happens with BETWEEN, 
whether 
+              // or not query caching is turned off. See JIRA TRAFODION-3088 
for
+              // that example.)
+              Lng32 start = val.index("'");
+              Lng32 minus = val.index("-");
+              if (start > 0)
+                {
+                  Lng32 end = val.index("'", start+1);
+                  if (end > 0)
+                    {
+                      val = val(start+1, (end-start-1));
+                      if (minus > 0)
+                        {
+                          // prepend '-' to the output
+                          val.prepend('-', 1);
+                        }
+                      vLen = val.length();                      
+                    }
+                }             
+            }
+          else if ((constType->getTypeQualifier()  == NA_NUMERIC_TYPE) &&
               (((NumericType*)constType)->isExact()) &&
                (NOT ((NumericType*)constType)->isBigNum()) &&
               (constType->getScale() > 0))

Reply via email to