trafodion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dbirds...@apache.org
Subject [trafodion] branch master updated: [TRAFODION-3314] Avoid generating redundant DDL in OSIM for unique constraints
Date Wed, 03 Jul 2019 19:57:26 GMT
This is an automated email from the ASF dual-hosted git repository.

dbirdsall pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafodion.git


The following commit(s) were added to refs/heads/master by this push:
     new 5e7f197  [TRAFODION-3314] Avoid generating redundant DDL in OSIM for unique constraints
     new ff2abb8  Merge pull request #1846 from DaveBirdsall/Trafodion3314
5e7f197 is described below

commit 5e7f19703cbf7829189733d3b0d62e3176d4366c
Author: Dave Birdsall <dbirdsall@apache.org>
AuthorDate: Tue Jul 2 20:41:57 2019 +0000

    [TRAFODION-3314] Avoid generating redundant DDL in OSIM for unique constraints
---
 core/sql/optimizer/OptimizerSimulator.cpp | 46 +++++++++++++++++++------------
 1 file changed, 29 insertions(+), 17 deletions(-)

diff --git a/core/sql/optimizer/OptimizerSimulator.cpp b/core/sql/optimizer/OptimizerSimulator.cpp
index 8441386..5aaa4f6 100644
--- a/core/sql/optimizer/OptimizerSimulator.cpp
+++ b/core/sql/optimizer/OptimizerSimulator.cpp
@@ -541,31 +541,43 @@ void OptimizerSimulator::dumpDDLs(const QualifiedName & qualifiedName)
                                    <<"."<< qualifiedName.getSchemaName() 
                                    << ";" << endl;
         
+        // skippingSystemGeneratedIndex is set to TRUE to avoid generating redundant
+        // DDL for system-generated indexes
+        NABoolean skippingSystemGeneratedIndex = FALSE;
         outQueue->position();//rewind
         for (int i = 0; i < outQueue->numEntries(); i++) {
             OutputInfo * vi = (OutputInfo*)outQueue->getNext();
             char * ptr = vi->get(0);
-            // skip heading newline, and add a comment line
-            // for the DDL text upto the first trailing '\n'
-            Int32 ix = 0;
-            for(; ptr[ix]=='\n'; ix++);
-            if( strstr(ptr, "CREATE TABLE") ||
-                strstr(ptr, "CREATE INDEX") ||
-                strstr(ptr, "CREATE UNIQUE INDEX") ||
-                strstr(ptr, "ALTER TABLE")  )
+            if (strcmp(ptr,"\n-- The following index is a system created index --") == 0)
+              skippingSystemGeneratedIndex = TRUE;
 
+            if (!skippingSystemGeneratedIndex)
             {
-              (*createTable) << "--";
-              char* x = ptr+ix;
-              while ( (*x) && *x != '\n' ) {
-                (*createTable) << *x;
-                x++;
-              } 
-              (*createTable) << endl;
+                // skip heading newline, and add a comment line
+                // for the DDL text upto the first trailing '\n'
+                Int32 ix = 0;
+                for(; ptr[ix]=='\n'; ix++);
+                if( strstr(ptr, "CREATE TABLE") ||
+                    strstr(ptr, "CREATE INDEX") ||
+                    strstr(ptr, "CREATE UNIQUE INDEX") ||
+                    strstr(ptr, "ALTER TABLE")  )
+
+                {
+                  (*createTable) << "--";
+                  char* x = ptr+ix;
+                  while ( (*x) && *x != '\n' ) {
+                    (*createTable) << *x;
+                    x++;
+                  } 
+                  (*createTable) << endl;
+                }
+
+                //output ddl  
+                (*createTable) << ptr << endl;
             }
 
-            //output ddl    
-            (*createTable) << ptr << endl;
+            if (skippingSystemGeneratedIndex && (strcmp(ptr,";") == 0)) // at end
of DDL to be skipped?
+              skippingSystemGeneratedIndex = FALSE;
         }
     }
 }


Mime
View raw message