Repository: trafodion
Updated Branches:
  refs/heads/master 0edaaf416 -> 1ecac0ae7


[TRAFODION-1881] A better way to solve TRAFODION-1858


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

Branch: refs/heads/master
Commit: cad4418c141fe5ea73888dc4b0a91272197cc14d
Parents: 5e8bfc7
Author: Liu Ming <[email protected]>
Authored: Sun Aug 12 02:05:31 2018 +0000
Committer: Liu Ming <[email protected]>
Committed: Sun Aug 12 02:05:31 2018 +0000

----------------------------------------------------------------------
 core/sql/generator/Generator.cpp |  6 +++++-
 core/sql/generator/Generator.h   |  1 +
 core/sql/optimizer/BindRI.cpp    | 11 +++++++----
 core/sql/sqlcat/TrafDDLdesc.h    | 12 +++++++++++-
 4 files changed, 24 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafodion/blob/cad4418c/core/sql/generator/Generator.cpp
----------------------------------------------------------------------
diff --git a/core/sql/generator/Generator.cpp b/core/sql/generator/Generator.cpp
index 895816c..d9e736a 100644
--- a/core/sql/generator/Generator.cpp
+++ b/core/sql/generator/Generator.cpp
@@ -1657,6 +1657,7 @@ TrafDesc * Generator::createKeyDescs(Int32 numKeys,
 
 TrafDesc * Generator::createConstrKeyColsDescs(Int32 numKeys,
                                                ComTdbVirtTableKeyInfo * 
keyInfo,
+                                               ComTdbVirtTableColumnInfo * 
columnInfo,
                                                NAMemory * space)
 {
   TrafDesc * first_key_desc = NULL;
@@ -1687,6 +1688,9 @@ TrafDesc * Generator::createConstrKeyColsDescs(Int32 
numKeys,
        tgt->colname = NULL;
       
       tgt->position   = src->tableColNum;
+      ComTdbVirtTableColumnInfo * info = columnInfo +  src->tableColNum;
+      if(info->columnClass == COM_SYSTEM_COLUMN )
+        tgt->setSystemKey(TRUE);
     }
 
   return first_key_desc;
@@ -2062,7 +2066,7 @@ TrafDesc * Generator::createVirtualTableDesc
          curr_constr_desc->constrntsDesc()->colcount = constrInfo[i].colCount;
 
          curr_constr_desc->constrntsDesc()->constr_key_cols_desc =
-           Generator::createConstrKeyColsDescs(constrInfo[i].colCount, 
constrInfo[i].keyInfoArray, space);
+           Generator::createConstrKeyColsDescs(constrInfo[i].colCount, 
constrInfo[i].keyInfoArray, columnInfo, space);
 
          if (constrInfo[i].ringConstrArray)
            {

http://git-wip-us.apache.org/repos/asf/trafodion/blob/cad4418c/core/sql/generator/Generator.h
----------------------------------------------------------------------
diff --git a/core/sql/generator/Generator.h b/core/sql/generator/Generator.h
index b22e1f2..2c0ac9e 100644
--- a/core/sql/generator/Generator.h
+++ b/core/sql/generator/Generator.h
@@ -1413,6 +1413,7 @@ public:
 
   static TrafDesc * createConstrKeyColsDescs(Int32 numKeys,
                                              ComTdbVirtTableKeyInfo * keyInfo,
+                                             ComTdbVirtTableColumnInfo * 
colInfo,
                                              NAMemory * space);
 
   static TrafDesc * createRefConstrDescStructs(

http://git-wip-us.apache.org/repos/asf/trafodion/blob/cad4418c/core/sql/optimizer/BindRI.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/BindRI.cpp b/core/sql/optimizer/BindRI.cpp
index eeb1e20..c2a1a31 100644
--- a/core/sql/optimizer/BindRI.cpp
+++ b/core/sql/optimizer/BindRI.cpp
@@ -194,13 +194,16 @@ void AbstractRIConstraint::setKeyColumns(
   while (keyColDesc)
   {
     colDesc = keyColDesc->constrntKeyColsDesc();
-    column = new (heap) NAColumn(colDesc->colname, colDesc->position, NULL, 
heap);
+    if( colDesc->isSystemKey() )
+      column = new (heap) NAColumn(colDesc->colname, colDesc->position, NULL, 
heap, NULL, SYSTEM_COLUMN);
+    else
+      column = new (heap) NAColumn(colDesc->colname, colDesc->position, NULL, 
heap);
     keyColumns_.insertAt(i, column);
     i++;
     keyColDesc = keyColDesc->next; 
   }
 
-  CMPASSERT(desc->colcount == (signed)i);
+  CMPASSERT(desc->colcount == (signed)i); 
 }
 
 UniqueConstraint::~UniqueConstraint()
@@ -456,8 +459,8 @@ void RefConstraint::getPredicateText(NAString &text,
   text += "(";
   for (CollIndex i = 0; i < keyColumns.entries(); i++)
     {
-      if(isHiddenColumn(keyColumns[i]->getColName()) )
-        continue;
+      if(keyColumns[i]->isSystemColumn() )
+         continue;
       if (pos > 0)
       {
         text += ",";

http://git-wip-us.apache.org/repos/asf/trafodion/blob/cad4418c/core/sql/sqlcat/TrafDDLdesc.h
----------------------------------------------------------------------
diff --git a/core/sql/sqlcat/TrafDDLdesc.h b/core/sql/sqlcat/TrafDDLdesc.h
index 733ffa9..7065924 100644
--- a/core/sql/sqlcat/TrafDDLdesc.h
+++ b/core/sql/sqlcat/TrafDDLdesc.h
@@ -311,9 +311,19 @@ public:
 
 class TrafConstrntKeyColsDesc : public TrafDesc {
 public:
+  enum ConsrntKeyDescFlags
+    { 
+      SYSTEM_KEY   = 0x0001
+    };
   // why almost no initializers? see note at top of file
   TrafConstrntKeyColsDesc() : TrafDesc(DESC_CONSTRNT_KEY_COLS_TYPE)
-  {}
+  {
+    constrntKeyColsDescFlags = 0;
+  }
+
+  void setSystemKey(NABoolean v) 
+  {(v ? constrntKeyColsDescFlags |= SYSTEM_KEY: constrntKeyColsDescFlags&= 
~SYSTEM_KEY); };
+  NABoolean isSystemKey() { return (constrntKeyColsDescFlags & SYSTEM_KEY) != 
0; };
 
   // ---------------------------------------------------------------------
   // Redefine virtual functions required for Versioning.

Reply via email to