You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafodion.apache.org by db...@apache.org on 2016/11/30 16:06:44 UTC

[1/2] incubator-trafodion git commit: [TRAFODION-2371] Fix ALTER TALBE RENAME for IDENTITY columns

Repository: incubator-trafodion
Updated Branches:
  refs/heads/master acedc3c20 -> dff04c6fb


[TRAFODION-2371] Fix ALTER TALBE RENAME for IDENTITY columns


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

Branch: refs/heads/master
Commit: 8c71ef682dc422eae7312f003852b0b5ce31fcc9
Parents: 3b31663
Author: Dave Birdsall <db...@apache.org>
Authored: Mon Nov 28 22:58:32 2016 +0000
Committer: Dave Birdsall <db...@apache.org>
Committed: Mon Nov 28 22:58:32 2016 +0000

----------------------------------------------------------------------
 core/sql/sqlcomp/CmpSeabaseDDLtable.cpp | 60 ++++++++++++++++++++++++++--
 1 file changed, 57 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/8c71ef68/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp b/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
index 7f2b045..6af00b0 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
@@ -3959,6 +3959,12 @@ void CmpSeabaseDDL::renameSeabaseTable(
       return;
     }
 
+  // variables needed to find identity column (have to be declared before
+  // the first goto or C++ will moan because of the initializers)
+  NABoolean found = FALSE;
+  Lng32 idPos = 0;
+  NAColumn *col = NULL;
+
   if ((isSeabaseReservedSchema(tableName)) &&
       (!Get_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL)))
     {
@@ -4204,8 +4210,55 @@ void CmpSeabaseDDL::renameSeabaseTable(
   if (cliRC < 0)
     {
       processReturn();
-      
-      goto label_error;
+      goto label_error_2;
+    }
+
+  // if there is an identity column, rename the sequence corresponding to it
+  found = FALSE;
+  while ((NOT found) && (idPos < naTable->getColumnCount()))
+    {
+
+      col = naTable->getNAColumnArray()[idPos];
+      if (col->isIdentityColumn())
+        {
+          found = TRUE;
+          continue;
+        }
+
+      idPos++;
+    }
+
+  if (found)
+    {
+      NAString oldSeqName;
+      SequenceGeneratorAttributes::genSequenceName
+        (catalogNamePart, schemaNamePart, objectNamePart, col->getColName(),
+         oldSeqName);
+  
+      NAString newSeqName;
+      SequenceGeneratorAttributes::genSequenceName
+        (catalogNamePart, schemaNamePart, newObjectNamePart, col->getColName(),
+         newSeqName);
+
+      Int64 seqUID = getObjectUID(&cliInterface,
+                                  catalogNamePart.data(), schemaNamePart.data(), 
+                                  oldSeqName.data(),
+                                  COM_SEQUENCE_GENERATOR_OBJECT_LIT);
+      if (seqUID < 0)
+        {
+          processReturn();
+          goto label_error_2;
+        }
+
+      cliRC = updateObjectName(&cliInterface,
+                               seqUID,
+                               catalogNamePart.data(), schemaNamePart.data(),
+                               newSeqName.data());
+      if (cliRC < 0)
+        {
+          processReturn();
+          goto label_error_2;
+        }
     }
 
   // rename the underlying hbase object
@@ -4255,9 +4308,10 @@ void CmpSeabaseDDL::renameSeabaseTable(
 
   return;
 
- label_error:
+ label_error:  // come here after HBase copy
   retcode = dropHbaseTable(ehi, &newHbaseTable, FALSE, FALSE);
 
+ label_error_2:  // come here after beginXnIfNotInProgress but before HBase copy
   endXnIfStartedHere(&cliInterface, xnWasStartedHere, cliRC);
   
   deallocEHI(ehi); 


[2/2] incubator-trafodion git commit: Merge [TRAFODION-2371] PR 856 Fix ALTER TABLE RENAME for IDENTITY columns

Posted by db...@apache.org.
Merge [TRAFODION-2371] PR 856 Fix ALTER TABLE RENAME for IDENTITY columns


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

Branch: refs/heads/master
Commit: dff04c6fb4de0c767f6d587f2fb1ad59e0b544fb
Parents: acedc3c 8c71ef6
Author: Dave Birdsall <db...@apache.org>
Authored: Wed Nov 30 16:05:28 2016 +0000
Committer: Dave Birdsall <db...@apache.org>
Committed: Wed Nov 30 16:05:28 2016 +0000

----------------------------------------------------------------------
 core/sql/sqlcomp/CmpSeabaseDDLtable.cpp | 60 ++++++++++++++++++++++++++--
 1 file changed, 57 insertions(+), 3 deletions(-)
----------------------------------------------------------------------