[TRAFODION-3087] Add Considerations for *CREATE INDEX Statement* in *Trafodion SQL Reference Manual* and Fix Typos
diff --git a/core/conn/odbc/src/odbc/nsksrvrcore/srvrothers.cpp b/core/conn/odbc/src/odbc/nsksrvrcore/srvrothers.cpp
index 423b0a6..b4ca5c4 100644
--- a/core/conn/odbc/src/odbc/nsksrvrcore/srvrothers.cpp
+++ b/core/conn/odbc/src/odbc/nsksrvrcore/srvrothers.cpp
@@ -5242,6 +5242,8 @@
                  if (retcode == SQL_ERROR)
                  {
                     ERROR_DESC_def *p_buffer = QryCatalogSrvrStmt->sqlError.errorList._buffer;
+                    char             errNumStr[128] = {0};
+                    sprintf(errNumStr, "%d", (int)p_buffer->sqlcode);
                     strncpy(RequestError, p_buffer->errorText,sizeof(RequestError) -1);
                     RequestError[sizeof(RequestError) - 1] = '\0';
 
@@ -5251,7 +5253,7 @@
                                  ODBCMX_SERVER,
                                  srvrGlobal->srvrObjRef,
                                  2,
-                                 p_buffer->sqlcode,
+                                 errNumStr,
                                  RequestError);
 
                     exception_->exception_nr = odbc_SQLSvc_GetSQLCatalogs_ParamError_exn_;
@@ -6533,6 +6535,8 @@
         if (retcode == SQL_ERROR)
         {
             ERROR_DESC_def *p_buffer = QryLobExtractSrvrStmt->sqlError.errorList._buffer;
+            char            errNumStr[128] = {0};
+            sprintf(errNumStr, "%d", (int)p_buffer->sqlcode);
             strncpy(RequestError, p_buffer->errorText, sizeof(RequestError) - 1);
 
             SendEventMsg(MSG_SQL_ERROR,
@@ -6541,7 +6545,7 @@
                          ODBCMX_SERVER,
                          srvrGlobal->srvrObjRef,
                          2,
-                         p_buffer->sqlcode,
+                         errNumStr,
                          RequestError);
 
             exception_->exception_nr = odbc_SQLsrvr_ExtractLob_ParamError_exn_;
@@ -6616,6 +6620,9 @@
         if (retcode == SQL_ERROR)
         {
             ERROR_DESC_def * p_buffer = QryLobUpdateSrvrStmt->sqlError.errorList._buffer;
+            char             errNumStr[128] = {0};
+            sprintf(errNumStr, "%d", (int)p_buffer->sqlcode);
+
             strncpy(RequestError, p_buffer->errorText, sizeof(RequestError) - 1);
 
             SendEventMsg(MSG_SQL_ERROR,
@@ -6624,7 +6631,7 @@
                          ODBCMX_SERVER,
                          srvrGlobal->srvrObjRef,
                          2,
-                         p_buffer->sqlcode,
+                         errNumStr,
                          RequestError);
             exception_->exception_nr = odbc_SQLSvc_UpdateLob_ParamError_exn_;
             exception_->u.SQLError.errorList._length = QryLobUpdateSrvrStmt->sqlError.errorList._length;
diff --git a/core/sql/optimizer/BindItemExpr.cpp b/core/sql/optimizer/BindItemExpr.cpp
index 9e84ac4..67c7471 100644
--- a/core/sql/optimizer/BindItemExpr.cpp
+++ b/core/sql/optimizer/BindItemExpr.cpp
@@ -8622,7 +8622,12 @@
 ItemExpr *Parameter::bindNode(BindWA *bindWA)
 {
   if (nodeIsBound())
+  {
+    OperatorTypeEnum opTyp = getOperatorType();
+    // All user inputs are treated as outer references in the current scope.
+    bindWA->getCurrentScope()->addOuterRef(getValueId());
     return getValueId().getItemExpr();
+  }
   if (bindWA->getCurrentScope()->context()->inTDFunction())
   {
     //Paramaters and outer references are not supported with rank function.
diff --git a/core/sql/optimizer/ItemExpr.cpp b/core/sql/optimizer/ItemExpr.cpp
index 920d2f4..ace5a84 100644
--- a/core/sql/optimizer/ItemExpr.cpp
+++ b/core/sql/optimizer/ItemExpr.cpp
@@ -3886,23 +3886,7 @@
 
 ItemExpr * DynamicParam::copyTopNode(ItemExpr *derivedNode, CollHeap* outHeap)
 {
-  ItemExpr *result;
-
-  if (derivedNode == NULL) {
-    result = new (outHeap) DynamicParam(paramName_, indicatorName_, outHeap);
-    ((DynamicParam *) result)->setRowsetSize(rowsetSize_);
-    ((DynamicParam *) result)->setRowsetInfo(rowsetInfo_);
-    ((DynamicParam *) result)->setParamHeading(heading_);
-    ((DynamicParam *) result)->setParamTablename(tablename_);
-    // we remember our original dynamic parameter because we
-    // must use their valueid at dynamicparam::codegen time
-    ((DynamicParam *) result)->setOriginal(this);
-  }
-
-  else
-    result = derivedNode;
-
-  return Parameter::copyTopNode(result, outHeap);
+  return this;
 }
 
 const NAType * DynamicParam::pushDownType(NAType& desiredType,
diff --git a/core/sql/optimizer/ValueDesc.cpp b/core/sql/optimizer/ValueDesc.cpp
index 45f92e1..0e12ffb 100644
--- a/core/sql/optimizer/ValueDesc.cpp
+++ b/core/sql/optimizer/ValueDesc.cpp
@@ -6382,7 +6382,32 @@
 	 {
            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) && (minus < start))  // '-' before the string part
+	                 {
+	                   // 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))