trafodion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dbirds...@apache.org
Subject [2/3] incubator-trafodion git commit: Rework to support delimited identifiers
Date Mon, 10 Oct 2016 16:29:50 GMT
Rework to support delimited identifiers


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

Branch: refs/heads/master
Commit: 4ac56f58e20ba1a277308a9ed5184f164a5e0701
Parents: 8a7fe53
Author: Dave Birdsall <dbirdsall@apache.org>
Authored: Wed Oct 5 18:32:42 2016 +0000
Committer: Dave Birdsall <dbirdsall@apache.org>
Committed: Wed Oct 5 18:32:42 2016 +0000

----------------------------------------------------------------------
 core/sql/ustat/hs_cli.cpp     | 6 +++---
 core/sql/ustat/hs_globals.cpp | 9 +++++++++
 core/sql/ustat/hs_globals.h   | 2 ++
 core/sql/ustat/hs_la.cpp      | 3 +++
 core/sql/ustat/hs_update.cpp  | 6 ++++++
 5 files changed, 23 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4ac56f58/core/sql/ustat/hs_cli.cpp
----------------------------------------------------------------------
diff --git a/core/sql/ustat/hs_cli.cpp b/core/sql/ustat/hs_cli.cpp
index 878e5a2..1a5d277 100644
--- a/core/sql/ustat/hs_cli.cpp
+++ b/core/sql/ustat/hs_cli.cpp
@@ -5473,16 +5473,16 @@ void HSSample::addTruncatedColumnReference(NAString & qry,HSColumnStruct
& colIn
     if (isOverSized)
       {
         qry += "SUBSTRING(";
-        qry += colInfo.colname->data();
+        qry += colInfo.externalColumnName->data();
         qry += " FOR ";
         
         char temp[20];  // big enough for "nnnnnn) AS "
         sprintf(temp,"%d) AS ", maxLengthInBytes / CharInfo::maxBytesPerChar(colInfo.charset));
         qry += temp;
-        qry += colInfo.colname->data();
+        qry += colInfo.externalColumnName->data();
       }
     else
-      qry += colInfo.colname->data();
+      qry += colInfo.externalColumnName->data();
   }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4ac56f58/core/sql/ustat/hs_globals.cpp
----------------------------------------------------------------------
diff --git a/core/sql/ustat/hs_globals.cpp b/core/sql/ustat/hs_globals.cpp
index 00a15db..5038b2f 100644
--- a/core/sql/ustat/hs_globals.cpp
+++ b/core/sql/ustat/hs_globals.cpp
@@ -1643,6 +1643,7 @@ void HSColGroupStruct::freeISMemory(NABoolean freeStrData, NABoolean
freeMCData)
 HSColumnStruct::HSColumnStruct(const HSColumnStruct &src, NAMemory *h)
   {
     colname         = new (h) NAString(src.colname->data(), h);
+    externalColumnName = new (h) NAString(src.externalColumnName->data(), h);
     colnum          = src.colnum;
     position        = src.position;
     datatype        = src.datatype;
@@ -1663,6 +1664,11 @@ HSColumnStruct::~HSColumnStruct()
         delete colname;
         colname = NULL;
       }
+    if (externalColumnName != NULL)
+      {
+        delete externalColumnName;
+        externalColumnName = NULL;
+      }
   }
 
 // Assignment operator
@@ -1677,6 +1683,7 @@ HSColumnStruct& HSColumnStruct::operator=(const HSColumnStruct&
rhs)
     // already deleted; colname is on the STMTHEAP and will be destructed at the
     // end of the statement. [SOL 10-070822-6995]
     colname         = new (STMTHEAP) NAString(rhs.colname->data(), STMTHEAP);
+    externalColumnName = new (STMTHEAP) NAString(rhs.externalColumnName->data(), STMTHEAP);
     colnum          = rhs.colnum;
     position        = rhs.position;
     datatype        = rhs.datatype;
@@ -4602,6 +4609,8 @@ static void mapInternalSortTypes(HSColGroupStruct *groupList, NABoolean
forHive
      else
        columnName=dblQuote+group->colNames->data()+dblQuote;
 
+     *(col.externalColumnName) = columnName;
+
      switch (col.datatype)
      {
       case REC_DECIMAL_LSE:

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4ac56f58/core/sql/ustat/hs_globals.h
----------------------------------------------------------------------
diff --git a/core/sql/ustat/hs_globals.h b/core/sql/ustat/hs_globals.h
index ae47a8f..b372bee 100644
--- a/core/sql/ustat/hs_globals.h
+++ b/core/sql/ustat/hs_globals.h
@@ -1011,6 +1011,7 @@ class MCWrapper
 struct HSColumnStruct : public NABasicObject
   {
     NAString         *colname;        /* column name              */
+    NAString         *externalColumnName;  /* column name to use in SQL (e.g. with delimiters)
*/
     Lng32              colnum;         /* column position in table */
     Lng32              position;       /* position in grouplist    */
     Lng32              datatype;
@@ -1026,6 +1027,7 @@ struct HSColumnStruct : public NABasicObject
 
     HSColumnStruct()
       : colname(new(STMTHEAP) NAString(STMTHEAP)),
+        externalColumnName(new(STMTHEAP) NAString(STMTHEAP)),
         colnum(-1), position(0), datatype(-1), nullflag(-1),
         charset(CharInfo::UnknownCharSet),
         length(-1), precision(-1), scale(-1),

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4ac56f58/core/sql/ustat/hs_la.cpp
----------------------------------------------------------------------
diff --git a/core/sql/ustat/hs_la.cpp b/core/sql/ustat/hs_la.cpp
index 068aef1..330fbd2 100644
--- a/core/sql/ustat/hs_la.cpp
+++ b/core/sql/ustat/hs_la.cpp
@@ -291,6 +291,7 @@ Lng32 HSSqTableDef::DescribeColumnNames()
         HSHandleError(retcode_);
         colName[len] = '\0';
         *colInfo_[i].colname = &*colName;
+        *colInfo_[i].externalColumnName = ToAnsiIdentifier(*colInfo_[i].colname);
                                                   /*== GET COLUMN DATATYPE ==*/
         retcode_ = SQL_EXEC_GetDescItem(outputDesc, entry,
                                         SQLDESC_TYPE_FS,
@@ -1010,6 +1011,7 @@ Lng32 HSHiveTableDef::DescribeColumnNames()
     {
       *(colInfo_[i].colname) = hiveColDesc->name_;
       colInfo_[i].colname->toUpper();
+      *colInfo_[i].externalColumnName = ToAnsiIdentifier(*colInfo_[i].colname);
 
       NAType* natype = getSQColTypeForHive(hiveColDesc->type_, STMTHEAP);
       colInfo_[i].datatype = natype->getFSDatatype();
@@ -1238,6 +1240,7 @@ Lng32 HSHbaseTableDef::DescribeColumnNames()
     {
       colInfo_[i].colnum = i;  // position of col in table
       *(colInfo_[i].colname) = colArr[i]->getColName();
+      *colInfo_[i].externalColumnName = ToAnsiIdentifier(*colInfo_[i].colname);
       natype = colArr[i]->getType();
       colInfo_[i].datatype = natype->getFSDatatype();
       colInfo_[i].nullflag = natype->supportsSQLnullLogical();

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4ac56f58/core/sql/ustat/hs_update.cpp
----------------------------------------------------------------------
diff --git a/core/sql/ustat/hs_update.cpp b/core/sql/ustat/hs_update.cpp
index 4dd70d6..080af79 100644
--- a/core/sql/ustat/hs_update.cpp
+++ b/core/sql/ustat/hs_update.cpp
@@ -308,6 +308,12 @@ Lng32 UpdateStats(char *input, NABoolean requestedByCompiler)
     retcode = HSFuncExecQuery("CONTROL QUERY DEFAULT TRAF_LARGEINT_UNSIGNED_IO 'ON'");
     HSExitIfError(retcode);
 
+    // Set the following CQD to allow "_SALT_", "_DIV_" and similar system columns
+    // in a sample table when the table is created using CREATE TABLE AS SELECT
+    retcode = HSFuncExecQuery("CONTROL QUERY DEFAULT TRAF_ALLOW_RESERVED_COLNAMES 'ON'");
+    HSExitIfError(retcode);
+
+
     LM->StopTimer();
 
     LM->StartTimer("Parse statement");


Mime
View raw message