[TRAFODION-2037] Improve DDL concurrency

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

Branch: refs/heads/master
Commit: 2605440bee754ff60192656f330d0851d8046f17
Parents: 9dff321
Author: Dave Birdsall <[email protected]>
Authored: Mon Jun 27 18:32:44 2016 +0000
Committer: Dave Birdsall <[email protected]>
Committed: Mon Jun 27 18:32:44 2016 +0000

----------------------------------------------------------------------
 core/sql/comexe/ComTdb.h                    |   3 +-
 core/sql/common/ComSmallDefs.h              |   1 +
 core/sql/regress/compGeneral/EXPECTED004.SB |   4 +-
 core/sql/regress/core/EXPECTED000.SB        |   2 +-
 core/sql/regress/core/TEST000               |   2 +-
 core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp    |  40 +-
 core/sql/sqlcomp/CmpSeabaseDDLincludes.h    |  10 +-
 core/sql/sqlcomp/CmpSeabaseDDLmd.h          | 489 ++++++++++++++++++++++-
 core/sql/sqlcomp/CmpSeabaseDDLroutine.cpp   |   6 +-
 core/sql/sqlcomp/CmpSeabaseDDLtable.cpp     |  15 +
 core/sql/sqlcomp/CmpSeabaseDDLupgrade.h     |  54 ++-
 11 files changed, 589 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/2605440b/core/sql/comexe/ComTdb.h
----------------------------------------------------------------------
diff --git a/core/sql/comexe/ComTdb.h b/core/sql/comexe/ComTdb.h
index 689bded..ae2bd64 100644
--- a/core/sql/comexe/ComTdb.h
+++ b/core/sql/comexe/ComTdb.h
@@ -975,7 +975,8 @@ class ComTdbVirtTableKeyInfo : public ComTdbVirtTableBase
   const char * colName;
   Lng32   keySeqNum;
   Lng32   tableColNum;
-  Lng32   ordering;
+  Lng32   ordering;  // 0 means ascending, 1 means descending
+                     // (see, for example, CmpSeabaseDDL::buildKeyInfoArray)
 
   Lng32 nonKeyCol; // if 1, this is a base table pkey col for unique indexes
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/2605440b/core/sql/common/ComSmallDefs.h
----------------------------------------------------------------------
diff --git a/core/sql/common/ComSmallDefs.h b/core/sql/common/ComSmallDefs.h
index 8055e22..4c5e19c 100644
--- a/core/sql/common/ComSmallDefs.h
+++ b/core/sql/common/ComSmallDefs.h
@@ -149,6 +149,7 @@ typedef NABoolean               ComBoolean;
 #define SEABASE_SEQ_GEN          "SEQ_GEN"
 #define SEABASE_TABLES            "TABLES"
 #define SEABASE_TABLE_CONSTRAINTS "TABLE_CONSTRAINTS"
+#define SEABASE_TABLE_CONSTRAINTS_IDX "TABLE_CONSTRAINTS_IDX"
 #define SEABASE_TEXT            "TEXT"
 #define SEABASE_UNIQUE_REF_CONSTR_USAGE "UNIQUE_REF_CONSTR_USAGE"
 #define SEABASE_VIEWS              "VIEWS"

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/2605440b/core/sql/regress/compGeneral/EXPECTED004.SB
----------------------------------------------------------------------
diff --git a/core/sql/regress/compGeneral/EXPECTED004.SB 
b/core/sql/regress/compGeneral/EXPECTED004.SB
index 1948245..3a5348e 100644
--- a/core/sql/regress/compGeneral/EXPECTED004.SB
+++ b/core/sql/regress/compGeneral/EXPECTED004.SB
@@ -1127,8 +1127,8 @@ LC   RC   OP   OPERATOR              OPT       
DESCRIPTION           CARD
 4    .    5    root                                                  1.00E+002
 1    3    4    nested_join                                           1.00E+002
 2    .    3    probe_cache                                           1.00E+000
-.    .    2    trafodion_index_scan            OBJECTS_UNIQ_IDX               
1.00E+000
-.    .    1    trafodion_scan                  TABLE_CONSTRAINTS     1.00E+002
+.    .    2    trafodion_index_scan            OBJECTS_UNIQ_IDX      1.00E+000
+.    .    1    trafodion_index_scan            TABLE_CONSTRAINTS_I   1.00E+002
 
 --- SQL operation complete.
 >>

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/2605440b/core/sql/regress/core/EXPECTED000.SB
----------------------------------------------------------------------
diff --git a/core/sql/regress/core/EXPECTED000.SB 
b/core/sql/regress/core/EXPECTED000.SB
index cdadb69..e1a28dd 100644
--- a/core/sql/regress/core/EXPECTED000.SB
+++ b/core/sql/regress/core/EXPECTED000.SB
@@ -1,7 +1,7 @@
 >>
 >>upsert into TRAFODION."_MD_".DEFAULTS
 +>     values
-+>     ('SCHEMA ', 'TRAFODION.SCH ', 'inserted during seabase regressions 
run');
++>     ('SCHEMA ', 'TRAFODION.SCH ', 'inserted during seabase regressions 
run', 0);
 
 --- 1 row(s) inserted.
 >>

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/2605440b/core/sql/regress/core/TEST000
----------------------------------------------------------------------
diff --git a/core/sql/regress/core/TEST000 b/core/sql/regress/core/TEST000
index 2839301..eb24d0b 100755
--- a/core/sql/regress/core/TEST000
+++ b/core/sql/regress/core/TEST000
@@ -25,7 +25,7 @@ log LOG000 clear;
 
 upsert into TRAFODION."_MD_".DEFAULTS
      values
-     ('SCHEMA ', 'TRAFODION.SCH ', 'inserted during seabase regressions run');
+     ('SCHEMA ', 'TRAFODION.SCH ', 'inserted during seabase regressions run', 
0);
 
 log;
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/2605440b/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp 
b/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
index 0df3d58..e1257a4 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
@@ -435,6 +435,10 @@ short CmpSeabaseDDL::convertColAndKeyInfoArrays(
           ComTdbVirtTableKeyInfo &ki = btKeyInfoArray[ii];
           if (strcmp(ci.colName, ki.colName) == 0)
             {
+              if (ki.ordering == 0)
+                nac->setClusteringKey(ASCENDING);
+              else // ki.ordering should be 1
+                nac->setClusteringKey(DESCENDING);
               naKeyArr->insert(nac);
             }
         } // for
@@ -729,6 +733,8 @@ short CmpSeabaseDDL::processDDLandCreateDescs(
 // ----------------------------------------------------------------------------
 short CmpSeabaseDDL::createMDdescs(MDDescsInfo *&trafMDDescsInfo)
 {
+  int breadCrumb = -1;  // useful for debugging purposes
+
   // if structure is already allocated, just return
   // Question - will trafMDDescsInfo ever be NOT NULL?
   if (trafMDDescsInfo)
@@ -770,6 +776,7 @@ short CmpSeabaseDDL::createMDdescs(MDDescsInfo 
*&trafMDDescsInfo)
       ComTdbVirtTableKeyInfo * keyInfoArray = NULL;
       ComTdbVirtTableIndexInfo * indexInfo = NULL;
 
+      breadCrumb = 1;
       if (processDDLandCreateDescs(parser,
                                    mdti.newDDL, mdti.sizeOfnewDDL,
                                    (mdti.isIndex ? TRUE : FALSE),
@@ -787,6 +794,7 @@ short CmpSeabaseDDL::createMDdescs(MDDescsInfo 
*&trafMDDescsInfo)
       
       if (oldDDL)
         {
+          breadCrumb = 2;
           if (processDDLandCreateDescs(parser,
                                        oldDDL, sizeOfoldDDL,
                                        (mdti.isIndex ? TRUE : FALSE),
@@ -818,6 +826,7 @@ short CmpSeabaseDDL::createMDdescs(MDDescsInfo 
*&trafMDDescsInfo)
           ComTdbVirtTableColumnInfo * indexColInfoArray = NULL;
           ComTdbVirtTableKeyInfo * indexKeyInfoArray = NULL;
           
+          breadCrumb = 3;
           if (processDDLandCreateDescs(parser,
                                        mdti.indexDDL, mdti.sizeOfIndexDDL,
                                        FALSE,
@@ -856,6 +865,7 @@ short CmpSeabaseDDL::createMDdescs(MDDescsInfo 
*&trafMDDescsInfo)
       QString ddlString; 
       ddlString.str = tableDDL.data();
 
+      breadCrumb = 4;
       if (processDDLandCreateDescs(parser,
                                    &ddlString, sizeof(QString),
                                    FALSE,
@@ -889,6 +899,10 @@ short CmpSeabaseDDL::createMDdescs(MDDescsInfo 
*&trafMDDescsInfo)
   return 0;
 
  label_error:
+
+  // When debugging, you can look at the breadCrumb variable to figure out
+  // why you got here.
+
   if (trafMDDescsInfo)
     NADELETEBASIC(trafMDDescsInfo, CTXTHEAP);
   trafMDDescsInfo = NULL;
@@ -4938,7 +4952,7 @@ short CmpSeabaseDDL::updateSeabaseMDSPJ(
       return -1;
     }
 
-  str_sprintf(buf, "insert into %s.\"%s\".%s values (%Ld, '%s', %d)",
+  str_sprintf(buf, "insert into %s.\"%s\".%s values (%Ld, '%s', %d, 0)",
               getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_LIBRARIES,
               libObjUID, libPath, routineInfo->library_version);
   
@@ -4991,7 +5005,7 @@ short CmpSeabaseDDL::updateSeabaseMDSPJ(
     return -1;
                                  
 
-  str_sprintf(buf, "insert into %s.\"%s\".%s values (%Ld, '%s', '%s', '%s', 
'%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', '%s', '%s', '%s', %Ld, '%s' 
)",
+  str_sprintf(buf, "insert into %s.\"%s\".%s values (%Ld, '%s', '%s', '%s', 
'%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', '%s', '%s', '%s', %Ld, '%s', 
0 )",
               getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_ROUTINES,
               spjObjUID,
               routineInfo->UDR_type,
@@ -5019,7 +5033,7 @@ short CmpSeabaseDDL::updateSeabaseMDSPJ(
       return -1;
     }
 
-  str_sprintf(buf, "insert into %s.\"%s\".%s values (%Ld, %Ld)",
+  str_sprintf(buf, "insert into %s.\"%s\".%s values (%Ld, %Ld, 0)",
               getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_LIBRARIES_USAGE,
               libObjUID, spjObjUID);
 
@@ -6650,6 +6664,7 @@ short CmpSeabaseDDL::updateSeabaseAuths(
 
 void CmpSeabaseDDL::initSeabaseMD(NABoolean ddlXns)
 {
+  int breadCrumb = -1;  // useful for debugging
   Lng32 retcode = 0;
   Lng32 cliRC = 0;
   NABoolean xnWasStartedHere = FALSE;
@@ -6758,15 +6773,17 @@ void CmpSeabaseDDL::initSeabaseMD(NABoolean ddlXns)
   NAString installJar(getenv("MY_SQROOT"));
   installJar += "/export/lib/trafodion-sql-currversion.jar";
 
+  breadCrumb = 1;
   if (beginXnIfNotInProgress(&cliInterface, xnWasStartedHere))
     goto label_error;
 
   cliRC = cliInterface.holdAndSetCQD("traf_bootstrap_md_mode", "ON");
   if (cliRC < 0)
     {
+      breadCrumb = 2;
       goto label_error;
     }
-
+  breadCrumb = 3;
 
   // Create Seabase system schema
   if (updateSeabaseMDObjectsTable(&cliInterface,sysCat,SEABASE_SYSTEM_SCHEMA,
@@ -6776,6 +6793,7 @@ void CmpSeabaseDDL::initSeabaseMD(NABoolean ddlXns)
   {
     goto label_error;
   }
+  breadCrumb = 4;
   
   // Create Seabase metadata schema
   schemaUID = -1;
@@ -6810,6 +6828,7 @@ void CmpSeabaseDDL::initSeabaseMD(NABoolean ddlXns)
                                mddi.indexInfo,
                                objUID))
         {
+          breadCrumb = 5;
           goto label_error;
         }
 
@@ -6850,6 +6869,7 @@ void CmpSeabaseDDL::initSeabaseMD(NABoolean ddlXns)
                                0, NULL,
                                objUID))
         {
+          breadCrumb = 6;
           goto label_error;
         }
     } // for
@@ -6862,6 +6882,7 @@ void CmpSeabaseDDL::initSeabaseMD(NABoolean ddlXns)
                          sizeof(seabaseMDValidateRoutineColInfo) / 
sizeof(ComTdbVirtTableColumnInfo),
                          seabaseMDValidateRoutineColInfo))
     {
+      breadCrumb = 7;
       goto label_error;
     }
 
@@ -6876,26 +6897,31 @@ void CmpSeabaseDDL::initSeabaseMD(NABoolean ddlXns)
 
   if (createSchemaObjects(&cliInterface))
     {
+      breadCrumb = 8;
       goto label_error;
     }
  
  if (createMetadataViews(&cliInterface))
     {
+      breadCrumb = 9;
       goto label_error;
     }
 
  if (createRepos(&cliInterface))
    {
+     breadCrumb = 10;
      goto label_error;
    }
 
  if (createPrivMgrRepos(&cliInterface, ddlXns))
    {
+     breadCrumb = 11;
      goto label_error;
    }
 
  if (createSeabaseLibmgr (&cliInterface))
-   {
+   {   
+     breadCrumb = 12;
      goto label_error;
    }
 
@@ -6904,6 +6930,10 @@ void CmpSeabaseDDL::initSeabaseMD(NABoolean ddlXns)
   return;
 
  label_error:
+
+  // When debugging, the breadCrumb variable is useful to tell you
+  // how you got here.
+
   endXnIfStartedHere(&cliInterface, xnWasStartedHere, -1);
 
   return;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/2605440b/core/sql/sqlcomp/CmpSeabaseDDLincludes.h
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLincludes.h 
b/core/sql/sqlcomp/CmpSeabaseDDLincludes.h
index b97149e..80fed40 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLincludes.h
+++ b/core/sql/sqlcomp/CmpSeabaseDDLincludes.h
@@ -97,14 +97,14 @@
 #define SOFTWARE_UPDATE_VERSION TRAF_SOFTWARE_VERS_UPDATE
 #define HBASE_OPTIONS_MAX_LENGTH 6000
 
-// new metadata version 1.1.0 changed for release 1.1.0.
-// Old metadata version 3.0.
+// new metadata version 2.1.0 changed for release 2.1.0.
+// Old metadata version 1.1.
 enum { 
-  METADATA_MAJOR_VERSION = 1,
-  METADATA_OLD_MAJOR_VERSION = 3,
+  METADATA_MAJOR_VERSION = 2,
+  METADATA_OLD_MAJOR_VERSION = 1,
   METADATA_MINOR_VERSION = 1,
   METADATA_UPDATE_VERSION = 0,
-  METADATA_OLD_MINOR_VERSION = 0,
+  METADATA_OLD_MINOR_VERSION = 1,
   METADATA_OLD_UPDATE_VERSION = 0,
   DATAFORMAT_MAJOR_VERSION = 1,
   DATAFORMAT_MINOR_VERSION = 1

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/2605440b/core/sql/sqlcomp/CmpSeabaseDDLmd.h
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLmd.h 
b/core/sql/sqlcomp/CmpSeabaseDDLmd.h
index 6f12ac9..cf50951 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLmd.h
+++ b/core/sql/sqlcomp/CmpSeabaseDDLmd.h
@@ -33,8 +33,8 @@
  *               The remaining sections contain metadata definitions for prior
  *               versions.
  *
- *               Version definitions are defined in CmpSeabaseDDL.h and are
- *               persistent in the VERSIONS metadata table.
+ *               Version definitions are defined in CmpSeabaseDDLincludes.h and
+ *               are persistent in the VERSIONS metadata table.
  *
  * 
*****************************************************************************
  */
@@ -132,7 +132,8 @@ static const QString seabaseDefaultsDDL[] =
   {" ( "},
   {"   attribute varchar(100 bytes) character set utf8 not null not 
serialized, "},
   {"   attr_value varchar(1000 bytes) character set utf8 not null not 
serialized, "},
-  {"   attr_comment varchar(1000 bytes) character set utf8 not null not 
serialized "},
+  {"   attr_comment varchar(1000 bytes) character set utf8 not null not 
serialized, "},
+  {"   flags largeint not null not serialized "},
   {" ) "},
   {" primary key (attribute) "},
   {" ; "}
@@ -177,7 +178,8 @@ static const QString seabaseLibrariesDDL[] =
   {" ( "},
   {"   library_uid largeint not null not serialized, "},
   {"   library_filename varchar(512) character set iso88591 not null not 
serialized, "},
-  {"   version int not null not serialized "},
+  {"   version int not null not serialized, "},
+  {"   flags largeint not null not serialized "},
   {" ) "},
   {" primary key (library_uid) "},
   {" ; "}
@@ -188,7 +190,8 @@ static const QString seabaseLibrariesUsageDDL[] =
   {" create table "SEABASE_LIBRARIES_USAGE" "},
   {" ( "},
   {"   using_library_uid largeint not null not serialized, "},
-  {"   used_udr_uid largeint not null not serialized "},
+  {"   used_udr_uid largeint not null not serialized, "},
+  {"   flags largeint not null not serialized "},
   {" ) "},
   {" primary key (using_library_uid, used_udr_uid) "},
   {" ; "}
@@ -284,7 +287,8 @@ static const QString seabaseRoutinesDDL[] =
   {"   external_security char(2) character set iso88591 not null not 
serialized, "},
   {"   execution_mode char(2) character set iso88591 not null not serialized, 
"},
   {"   library_uid largeint not null not serialized, "},
-  {"   signature varchar(8192 bytes) character set utf8 not null not 
serialized "},
+  {"   signature varchar(8192 bytes) character set utf8 not null not 
serialized, "},
+  {"   flags largeint not null not serialized "},
   {" ) "},
   {" primary key (udr_uid) "},
   {" ; "}
@@ -357,6 +361,27 @@ static const QString seabaseTableConstraintsDDL[] =
   {" ; "}
 };
 
+static const QString seabaseTableConstraintsIdxIndexDDL[] =
+{
+  {" create index "SEABASE_TABLE_CONSTRAINTS_IDX" on 
"TRAFODION_SYSCAT_LIT".\""SEABASE_MD_SCHEMA"\"."SEABASE_TABLE_CONSTRAINTS" "},
+  {" ( "},
+  {"   constraint_uid "},
+  {" ) "},
+  {" ; "}
+};
+
+static const QString seabaseTableConstraintsIdxDDL[] =
+{
+  {" create table "SEABASE_TABLE_CONSTRAINTS_IDX" "},
+  {" ( "},
+  {"   \"CONSTRAINT_UID@\" largeint not null not serialized, "},
+  {"   table_uid largeint not null not serialized, "},
+  {"   constraint_type char(2) character set iso88591 not null not serialized 
"},
+  {" ) "},
+  {" primary key (\"CONSTRAINT_UID@\", table_uid, constraint_type) "},
+  {" ; "}
+};
+
 static const QString seabaseTextDDL[] =
 {
   {" create table "SEABASE_TEXT" "},
@@ -574,7 +599,11 @@ static const MDTableInfo allMDtablesInfo[] = {
 
   {SEABASE_TABLE_CONSTRAINTS, 
    seabaseTableConstraintsDDL, sizeof(seabaseTableConstraintsDDL),
-   NULL, 0, FALSE},
+   seabaseTableConstraintsIdxIndexDDL, 
sizeof(seabaseTableConstraintsIdxIndexDDL), FALSE},
+
+  {SEABASE_TABLE_CONSTRAINTS_IDX,
+   seabaseTableConstraintsIdxDDL, sizeof(seabaseTableConstraintsIdxDDL),
+   NULL, 0, TRUE},
 
   {SEABASE_TEXT, 
    seabaseTextDDL, sizeof(seabaseTextDDL),
@@ -653,6 +682,452 @@ static const MDTableInfo allMDHistInfo[] = {
 #define SEABASE_VALIDATE_LIBRARY_OLD_MD  SEABASE_VALIDATE_LIBRARY"_OLD_MD"
 
 ////////////////////////////////////////////////////////////////////////
+//// START_OLD_MD_v11: 
+////        OLD metadata Version 1.1 (Major version = 1, Minor version = 1).
+//////////////////////////////////////////////////////////////////////////
+
+static const QString seabaseOldTrafMDv11AuthsDDL[] =
+{
+  {" create table "SEABASE_AUTHS_OLD_MD" "},
+  {" ( "},
+  {"  auth_id int unsigned not null not serialized, "},
+  {"  auth_db_name varchar(256 bytes) character set utf8 not null not 
serialized, "},
+  {"  auth_ext_name varchar(256 bytes) character set utf8 not null not 
serialized, "},
+  {"  auth_type char(2) character set iso88591 not null not serialized, "},
+  {"  auth_creator int unsigned not null not serialized, "},
+  {"  auth_is_valid char(2) character set iso88591 not null not serialized, "},
+  {"  auth_create_time largeint not null not serialized, "},
+  {"  auth_redef_time largeint not null not serialized, "},
+  {"  flags largeint not null not serialized "},
+  {" ) "},
+  {" primary key (auth_id) "},
+  {" ; "}
+};
+
+static const QString seabaseOldTrafMDv11ColumnsDDL[] =
+{
+  {" create table "SEABASE_COLUMNS_OLD_MD" "},
+  {" ( "},
+  {"   object_uid largeint not null not serialized, "},
+  {"   column_name varchar(256 bytes) character set utf8 not null not 
serialized, "},
+  {"   column_number int not null not serialized, "},
+  {"   column_class char(2) character set iso88591 not null not serialized, "},
+  {"   fs_data_type int not null not serialized, "},
+  {"   sql_data_type char(32) character set iso88591 not null not serialized, 
"},
+  {"   column_size int not null not serialized, "},
+  {"   column_precision int not null not serialized, "},
+  {"   column_scale int not null not serialized, "},
+  {"   datetime_start_field int not null not serialized, "},
+  {"   datetime_end_field int not null not serialized, "},
+  {"   is_upshifted char(2) character set iso88591 not null not serialized, "},
+  {"   column_flags int unsigned not null not serialized, "},
+  {"   nullable int not null not serialized, "},
+  {"   character_set char(40) character set iso88591 not null not serialized, 
"},
+  {"   default_class int not null not serialized, "},
+  {"   default_value varchar(1024 bytes) character set utf8 not null not 
serialized, "},
+  {"   column_heading varchar(256 bytes) character set utf8 not null not 
serialized, "},
+  {"   hbase_col_family varchar(40) character set iso88591 not null not 
serialized, "},
+  {"   hbase_col_qualifier varchar(40) character set iso88591 not null not 
serialized, "},
+  {"   direction char(2) character set iso88591 not null not serialized, "},
+  {"   is_optional char(2) character set iso88591 not null not serialized, "},
+  {"   flags largeint not null not serialized "},
+  {" ) "},
+  {" primary key (object_uid, column_name) "},
+  {" ; "}
+};
+
+enum SeabaseOldTrafMDv11ColumnsFlags {
+  SEABASE_COLUMN_IS_SALT_V11   = 0x0000000000000001, // don't rely on this 
quite yet,
+                                                     // since some older tables
+                                                     // don't have this flag 
set
+  SEABASE_COLUMN_IS_DIVISION_V11 = 0x0000000000000002
+};
+
+static const QString seabaseOldTrafMDv11DefaultsDDL[] =
+{
+  {" create table "SEABASE_DEFAULTS_OLD_MD" "},
+  {" ( "},
+  {"   attribute varchar(100 bytes) character set utf8 not null not 
serialized, "},
+  {"   attr_value varchar(1000 bytes) character set utf8 not null not 
serialized, "},
+  {"   attr_comment varchar(1000 bytes) character set utf8 not null not 
serialized "},
+  {" ) "},
+  {" primary key (attribute) "},
+  {" ; "}
+};
+
+static const QString seabaseOldTrafMDv11KeysDDL[] =
+{
+  {" create table "SEABASE_KEYS_OLD_MD" "},
+  {" ( "},
+  {"   object_uid largeint not null not serialized, "},
+  {"   column_name varchar( 256 bytes ) character set utf8 not null not 
serialized, "},
+  {"   keyseq_number int not null not serialized, "},
+  {"   column_number int not null not serialized, "},
+  {"   ordering int not null not serialized, "},
+  {"   nonkeycol int not null not serialized, "},
+  {"   flags largeint not null not serialized "},
+  {" ) "},
+  {" primary key (object_uid, keyseq_number) "},
+  {" ; "}
+};
+
+static const QString seabaseOldTrafMDv11IndexesDDL[] =
+{
+  {" create table "SEABASE_INDEXES_OLD_MD" "},
+  {" ( "},
+  {"   base_table_uid largeint not null not serialized, "},
+  {"   keytag int not null not serialized, "},
+  {"   is_unique int not null not serialized, "},
+  {"   key_colcount int not null not serialized, "},
+  {"   nonkey_colcount int not null not serialized, "},
+  {"   is_explicit int not null not serialized, "},
+  {"   index_uid largeint not null not serialized, "},
+  {"   flags largeint not null not serialized "},
+  {" ) "},
+  {" primary key (base_table_uid, index_uid) "},
+  {" ; "}
+};
+
+static const QString seabaseOldTrafMDv11LibrariesDDL[] =
+{
+  {" create table "SEABASE_LIBRARIES_OLD_MD" "},
+  {" ( "},
+  {"   library_uid largeint not null not serialized, "},
+  {"   library_filename varchar(512) character set iso88591 not null not 
serialized, "},
+  {"   version int not null not serialized "},
+  {" ) "},
+  {" primary key (library_uid) "},
+  {" ; "}
+};
+
+static const QString seabaseOldTrafMDv11LibrariesUsageDDL[] =
+{
+  {" create table "SEABASE_LIBRARIES_USAGE_OLD_MD" "},
+  {" ( "},
+  {"   using_library_uid largeint not null not serialized, "},
+  {"   used_udr_uid largeint not null not serialized "},
+  {" ) "},
+  {" primary key (using_library_uid, used_udr_uid) "},
+  {" ; "}
+};
+
+static const QString seabaseOldTrafMDv11ObjectsDDL[] =
+{
+  {" create table "SEABASE_OBJECTS_OLD_MD" "},
+  {" ( "},
+  {"   catalog_name varchar ( 256 bytes ) character set utf8 not null not 
serialized, "},
+  {"   schema_name varchar ( 256 bytes ) character set utf8 not null not 
serialized, "},
+  {"   object_name varchar ( 256 bytes ) character set utf8 not null not 
serialized, "},
+  {"   object_type char(2) character set iso88591 not null not serialized, "},
+  {"   object_uid largeint not null not serialized, "},
+  {"   create_time largeint not null not serialized, "},
+  {"   redef_time largeint not null not serialized, "},
+  {"   valid_def char(2) character set iso88591 not null not serialized, "},
+  {"   droppable char(2) character set iso88591 not null not serialized, "},
+  {"   object_owner int not null not serialized, "},
+  {"   schema_owner int not null not serialized, "},
+  {"   flags largeint not null not serialized "},
+  {" ) "},
+  {" primary key (catalog_name, schema_name, object_name, object_type) "},
+  {" ; "}
+};
+
+static const QString seabaseOldTrafMDv11ObjectsUniqIdxIndexDDL[] =
+{
+  {" create unique index "SEABASE_OBJECTS_UNIQ_IDX_OLD_MD" on 
"TRAFODION_SYSCAT_LIT".\""SEABASE_MD_SCHEMA"\"."SEABASE_OBJECTS_OLD_MD" "},
+  {" ( "},
+  {"   object_uid "},
+  {" ) "},
+  {" ; "}
+};
+
+static const QString seabaseOldTrafMDv11ObjectsUniqIdxDDL[] =
+{
+  {" create table "SEABASE_OBJECTS_UNIQ_IDX_OLD_MD" "},
+  {" ( "},
+  {"   \"OBJECT_UID@\" largeint not null not serialized, "},
+  {"   catalog_name varchar(256 bytes) character set utf8 not null not 
serialized, "},
+  {"   schema_name varchar(256 bytes) character set utf8 not null not 
serialized, "},
+  {"   object_name varchar(256 bytes) character set utf8 not null not 
serialized, "},
+  {"   object_type char(2) character set iso88591 not null not serialized "},
+  {" ) "},
+  {" primary key (\"OBJECT_UID@\") "},
+  {" ; "}
+};
+
+enum SeabaseOldTrafMDv11ObjectsFlags {
+  SEABASE_OBJECT_IS_EXTERNAL_HIVE_V11 = 0x0000000000000001, // set if this 
object
+                                                         // references external
+                                                         // HIVE table
+  SEABASE_OBJECT_IS_EXTERNAL_HBASE_V11 = 0x0000000000000002 // set if this 
object
+                                                         // references external
+                                                         // HBASE table
+
+};
+
+static const QString seabaseOldTrafMDv11RefConstraintsDDL[] =
+{
+  {" create table "SEABASE_REF_CONSTRAINTS_OLD_MD" "},
+  {" ( "},
+  {"   ref_constraint_uid largeint not null not serialized, "},
+  {"   unique_constraint_uid largeint not null not serialized, "},
+  {"   match_option char(2) not null not serialized, "},
+  {"   update_rule char(2) character set iso88591 not null not serialized, "},
+  {"   delete_rule char(2) character set iso88591 not null not serialized, "},
+  {"   flags largeint not null not serialized "},
+  {" ) "},
+  {" primary key (ref_constraint_uid, unique_constraint_uid) "},
+  {" ; "}
+};
+
+static const QString seabaseOldTrafMDv11RoutinesDDL[] =
+{
+  {" create table "SEABASE_ROUTINES_OLD_MD" "},
+  {" ( "},
+  {"   udr_uid largeint not null not serialized, "},
+  {"   udr_type char(2) not  null, "},
+  {"   language_type char(2) character set iso88591 not null not serialized, 
"},
+  {"   deterministic_bool char(2) character set iso88591 not null not 
serialized, "},
+  {"   sql_access char(2) character set iso88591 not null not serialized, "},
+  {"   call_on_null char(2) character set iso88591 not null not serialized, "},
+  {"   isolate_bool char(2) character set iso88591 not null not serialized, "},
+  {"   param_style char(2) character set iso88591 not null not serialized, "},
+  {"   transaction_attributes char(2) character set iso88591 not null not 
serialized, "},
+  {"   max_results int not null not serialized, "},
+  {"   state_area_size int not null not serialized, "},
+  {"   external_name varchar(1024 bytes) character set utf8 not null not 
serialized, "},
+  {"   parallelism char(2) character set iso88591 not null not serialized, "},
+  {"   user_version varchar(32) character set iso88591 not null not 
serialized, "},
+  {"   external_security char(2) character set iso88591 not null not 
serialized, "},
+  {"   execution_mode char(2) character set iso88591 not null not serialized, 
"},
+  {"   library_uid largeint not null not serialized, "},
+  {"   signature varchar(8192 bytes) character set utf8 not null not 
serialized "},
+  {" ) "},
+  {" primary key (udr_uid) "},
+  {" ; "}
+};
+
+static const QString seabaseOldTrafMDv11SeqGenDDL[] =
+{
+  {" create table "SEABASE_SEQ_GEN_OLD_MD" "},
+  {" ( "},
+  {"   seq_type char(2) character set iso88591 not null not serialized, "},
+  {"   seq_uid largeint not null not serialized, "},
+  {"   fs_data_type integer not null not serialized, "},
+  {"   start_value largeint not null not serialized, "},
+  {"   increment largeint not null not serialized, "},
+  {"   max_value largeint not null not serialized, "},
+  {"   min_value largeint not null not serialized, "},
+  {"   cycle_option char(2) character set iso88591 not null not serialized, "},
+  {"   cache_size largeint not null not serialized, "},
+
+  // next value that seq generator will return
+  {"   next_value largeint not null not serialized, "},
+
+  // number of seq generator calls accessing this metadata table
+  {"   num_calls largeint not null not serialized, "},
+
+  {"   redef_ts largeint not null serialized, "},
+  {"   upd_ts largeint not null serialized, "},
+
+  {"   flags largeint not null not serialized "},
+  {" ) "},
+  {" primary key (seq_uid) "},
+  {" ; "}
+};
+
+static const QString seabaseOldTrafMDv11TablesDDL[] =
+{
+  {" create table "SEABASE_TABLES_OLD_MD" "},
+  {" ( "},
+  {"   table_uid largeint not null not serialized, "},
+  {"   row_format char(2) character set iso88591 not null not serialized, "},
+  {"   is_audited char(2) character set iso88591 not null not serialized, "},
+  {"   row_data_length int not null not serialized, "},
+  {"   row_total_length int not null not serialized, "},
+  {"   key_length int not null not serialized, "},
+  {"   num_salt_partns int not null not serialized, "},
+  {"   flags largeint not null not serialized "},
+  {" ) "},
+  {" primary key (table_uid) "},
+  {" ; "}
+};
+
+static const QString seabaseOldTrafMDv11TableConstraintsDDL[] =
+{
+  {" create table "SEABASE_TABLE_CONSTRAINTS_OLD_MD" "},
+  {" ( "},
+  {"   table_uid largeint not null not serialized, "},
+  {"   constraint_uid largeint not null not serialized, "},
+  {"   constraint_type char(2) character set iso88591 not null not serialized, 
"},
+  {"   disabled char(2) character set iso88591 not null not serialized, "},
+  {"   droppable char(2) character set iso88591 not null not serialized, "},
+  {"   is_deferrable char(2) character set iso88591 not null not serialized, 
"},
+  {"   enforced char(2) character set iso88591 not null not serialized, "},
+  {"   validated char(2) character set iso88591 not null not serialized, "},
+  {"   last_validated largeint not null not serialized, "},
+  {"   col_count int not null not serialized, "},
+  {"   index_uid largeint not null not serialized, "},
+  {"   flags largeint not null not serialized "},
+  {" ) "},
+  {" primary key (table_uid, constraint_uid, constraint_type) "},
+  {" ; "}
+};
+
+static const QString seabaseOldTrafMDv11TextDDL[] =
+{
+  {" create table "SEABASE_TEXT_OLD_MD" "},
+  {" ( "},
+  {"   text_uid largeint not null not serialized, "},
+  {"   text_type int not null not serialized, "},
+  {"   sub_id int not null not serialized, "},
+  {"   seq_num int not null not serialized, "},
+  {"   flags largeint not null not serialized, "},
+  {"   text varchar(10000 bytes) character set utf8 not null not serialized "},
+  {" ) "},
+  {" primary key (text_uid, text_type, sub_id, seq_num) "},
+  {" ; "}
+};
+
+static const QString seabaseOldTrafMDv11UniqueRefConstrUsageDDL[] =
+{
+  {" create table "SEABASE_UNIQUE_REF_CONSTR_USAGE_OLD_MD" "},
+  {" ( "},
+  {"   unique_constraint_uid largeint not null not serialized, "},
+  {"   foreign_constraint_uid largeint not null not serialized, "},
+  {"   flags largeint not null not serialized "},
+  {" ) "},
+  {" primary key (unique_constraint_uid, foreign_constraint_uid) "},
+  {" ; "}
+};
+
+static const QString seabaseOldTrafMDv11VersionsDDL[] =
+{
+  {" create table "SEABASE_VERSIONS_OLD_MD" "},
+  {" ( "},
+  {"   version_type char(50 bytes) character set utf8 not null not serialized, 
"},
+  {"   major_version largeint not null not serialized, "},
+  {"   minor_version largeint not null not serialized, "},
+  {"   init_time largeint not null not serialized, "},
+  {"   comment varchar(1000 bytes) character set utf8 not null not serialized 
"},
+  {" ) "},
+  {" primary key (version_type) "},
+  {" ; "}
+};
+
+static const QString seabaseOldTrafMDv11ViewsDDL[] =
+{
+  {" create table "SEABASE_VIEWS_OLD_MD" "},
+  {" ( "},
+  {"   view_uid largeint not null not serialized, "},
+  {"   check_option char(2) character set iso88591 not null not serialized, "},
+  {"   is_updatable int not null not serialized, "},
+  {"   is_insertable int not null not serialized, "},
+  {"   flags largeint not null not serialized "},
+  {" ) "},
+  {" primary key (view_uid) "},
+  {" ; "}
+};
+
+static const QString seabaseOldTrafMDv11ViewsUsageDDL[] =
+{
+  {" create table "SEABASE_VIEWS_USAGE_OLD_MD" "},
+  {" ( "},
+  {"   using_view_uid largeint not null not serialized, "},
+  {"   used_object_uid largeint not null not serialized, "},
+  {"   used_object_type char(2) character set iso88591 not null not 
serialized, "},
+  {"   flags largeint not null not serialized "},
+  {" ) "},
+  {" primary key (using_view_uid, used_object_uid) "},
+  {" ; "}
+};
+
+static const ComTdbVirtTableRoutineInfo 
seabaseOldTrafMDv11MDValidateRoutineInfo =
+  {
+    "VALIDATEROUTINE", COM_PROCEDURE_TYPE_LIT,  COM_LANGUAGE_JAVA_LIT, 1, 
COM_NO_SQL_LIT, 0, 0, COM_STYLE_JAVA_CALL_LIT, COM_NO_TRANSACTION_REQUIRED_LIT, 
0, 0, "org.trafodion.sql.udr.LmUtility.validateMethod", 
COM_ROUTINE_NO_PARALLELISM_LIT, " ", COM_ROUTINE_EXTERNAL_SECURITY_INVOKER_LIT, 
COM_ROUTINE_SAFE_EXECUTION_LIT, " ", 1, 
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;III[Ljava/lang/String;[I[Ljava/lang/String;)V",
 " "
+  };
+
+static const ComTdbVirtTableColumnInfo 
seabaseOldTrafMDv11MDValidateRoutineColInfo[] =
+  {        
+    { "CLASSNAME", 0,  COM_USER_COLUMN, REC_BYTE_V_ASCII, 256, FALSE , 
SQLCHARSETCODE_ISO88591, 0, 0, 0, 0, 0, 0, 0, COM_NO_DEFAULT, 
"",SEABASE_DEFAULT_COL_FAMILY,"1", COM_INPUT_COLUMN_LIT, 0},
+    { "METHODNAME", 1,  COM_USER_COLUMN, REC_BYTE_V_ASCII, 256, FALSE , 
SQLCHARSETCODE_ISO88591, 0, 0, 0, 0, 0, 0, 0, COM_NO_DEFAULT, 
"",SEABASE_DEFAULT_COL_FAMILY,"2", COM_INPUT_COLUMN_LIT, 0},
+    { "EXTERNALPATH", 2,  COM_USER_COLUMN, REC_BYTE_V_ASCII, 256, FALSE , 
SQLCHARSETCODE_ISO88591, 0, 0, 0, 0, 0, 0, 0, COM_NO_DEFAULT, 
"",SEABASE_DEFAULT_COL_FAMILY,"3", COM_INPUT_COLUMN_LIT, 0},
+    { "SIGNATURE", 3,  COM_USER_COLUMN, REC_BYTE_V_ASCII, 8192, FALSE , 
SQLCHARSETCODE_ISO88591, 0, 0, 0, 0, 0, 0, 0, COM_NO_DEFAULT, 
"",SEABASE_DEFAULT_COL_FAMILY,"4", COM_INPUT_COLUMN_LIT, 0},
+    { "NUMPARAM", 4,  COM_USER_COLUMN, REC_BIN32_SIGNED, 4, FALSE , 
SQLCHARSETCODE_UNKNOWN, 0, 0, 0, 0, 0, 0, 0, COM_NO_DEFAULT, 
"",SEABASE_DEFAULT_COL_FAMILY,"5", COM_INPUT_COLUMN_LIT, 0},
+    { "MAXRESULTSETS", 5,  COM_USER_COLUMN, REC_BIN32_SIGNED, 4, FALSE , 
SQLCHARSETCODE_UNKNOWN, 0, 0, 0, 0, 0, 0, 0, COM_NO_DEFAULT, 
"",SEABASE_DEFAULT_COL_FAMILY,"6", COM_INPUT_COLUMN_LIT, 0},
+    { "OPTIONALSIG", 6,  COM_USER_COLUMN, REC_BIN32_SIGNED, 4, FALSE , 
SQLCHARSETCODE_UNKNOWN, 0, 0, 0, 0, 0, 0, 0, COM_NO_DEFAULT, 
"",SEABASE_DEFAULT_COL_FAMILY,"7", COM_INPUT_COLUMN_LIT, 0},
+     { "RETSIG", 7,  COM_USER_COLUMN, REC_BYTE_V_ASCII, 8192, FALSE , 
SQLCHARSETCODE_ISO88591, 0, 0, 0, 0, 0, 0, 0, COM_NO_DEFAULT, 
"",SEABASE_DEFAULT_COL_FAMILY,"8", COM_OUTPUT_COLUMN_LIT, 0},
+    { "ERRCODE", 8,  COM_USER_COLUMN, REC_BIN32_SIGNED, 4, FALSE , 
SQLCHARSETCODE_UNKNOWN, 0, 0, 0, 0, 0, 0, 0, COM_NO_DEFAULT, 
"",SEABASE_DEFAULT_COL_FAMILY,"9", COM_OUTPUT_COLUMN_LIT, 0},
+     { "ERRDETAIL", 9,  COM_USER_COLUMN, REC_BYTE_V_ASCII, 8192, FALSE , 
SQLCHARSETCODE_ISO88591, 0, 0, 0, 0, 0, 0, 0, COM_NO_DEFAULT, 
"",SEABASE_DEFAULT_COL_FAMILY,"10", COM_OUTPUT_COLUMN_LIT, 0}
+  };
+
+static const QString seabaseOldTrafMDv11HistogramsDDL[] =
+{
+  {" create table "HBASE_HIST_NAME"_OLD_MD "},
+  {" ( "},
+  {"   table_uid largeint not null not serialized, "},
+  {"   histogram_id int unsigned not null not serialized, "},
+  {"   col_position int not null not serialized, "},
+  {"   column_number int not null not serialized, "},
+  {"   colcount int not null not serialized, "},
+  {"   interval_count smallint not null not serialized, "},
+  {"   rowcount largeint not null not serialized, "},
+  {"   total_uec largeint not null not serialized, "},
+  {"   stats_time timestamp(0) not null not serialized, "},
+  {"   low_value varchar(250) character set ucs2 not null not serialized, "},
+  {"   high_value varchar(250) character set ucs2 not null not serialized, "},
+  {"   read_time timestamp(0) not null not serialized, "},
+  {"   read_count smallint not null not serialized, "},
+  {"   sample_secs largeint not null not serialized, "},
+  {"   col_secs largeint not null not serialized, "},
+  {"   sample_percent smallint not null not serialized, "},
+  {"   cv double precision not null not serialized, "},
+  {"   reason char(1) character set iso88591 not null not serialized, "},
+  {"   v1 largeint not null not serialized, "},
+  {"   v2 largeint not null not serialized, "},
+  {"   v3 largeint not null not serialized, "},
+  {"   v4 largeint not null not serialized, "},
+  {"   v5 varchar(250) character set ucs2 not null not serialized, "},
+  {"   v6 varchar(250) character set ucs2 not null not serialized "},
+  {" , constraint "HBASE_HIST_PK" primary key "},
+  {"     (table_uid, histogram_id, col_position) "},
+  {" ) "},
+  {" ; "}
+};
+
+static const QString seabaseOldTrafMDv11HistogramIntervalsDDL[] =
+{
+  {" create table "HBASE_HISTINT_NAME"_OLD_MD "},
+  {" ( "},
+  {"   table_uid largeint not null not serialized, "},
+  {"   histogram_id int unsigned not null not serialized, "},
+  {"   interval_number smallint not null not serialized, "},
+  {"   interval_rowcount largeint not null not serialized, "},
+  {"   interval_uec largeint not null not serialized, "},
+  {"   interval_boundary varchar(250) character set ucs2 not null not 
serialized, "},
+  {"   std_dev_of_freq numeric(12,3) not null not serialized, "},
+  {"   v1 largeint not null not serialized, "},
+  {"   v2 largeint not null not serialized, "},
+  {"   v3 largeint not null not serialized, "},
+  {"   v4 largeint not null not serialized, "},
+  {"   v5 varchar(250) character set ucs2 not null not serialized, "},
+  {"   v6 varchar(250) character set ucs2 not null not serialized"},
+  {" , constraint "HBASE_HISTINT_PK" primary key "},
+  {"    (table_uid, histogram_id, interval_number) "},
+  {" ) "},
+  {" ; "}
+};
+
+////////////////////////////////////////////////////////////////////////
+//// END_OLD_MD_v11: 
+////        OLD metadata Version 1.1  (Major version = 1, Minor version = 1).
+//////////////////////////////////////////////////////////////////////////
+
+// Note: The older metadata definitions below were from before we
+// reset the version to 1.1 with the early Trafodion releases. (We
+// went backwards to match the Trafodion release number.)
+
+////////////////////////////////////////////////////////////////////////
 //// START_OLD_MD_v23: 
 ////        OLD metadata Version 2.3  (Major version = 2, Minor version = 3).
 //////////////////////////////////////////////////////////////////////////

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/2605440b/core/sql/sqlcomp/CmpSeabaseDDLroutine.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLroutine.cpp 
b/core/sql/sqlcomp/CmpSeabaseDDLroutine.cpp
index 7285c37..5b22307 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLroutine.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLroutine.cpp
@@ -390,7 +390,7 @@ void CmpSeabaseDDL::createSeabaseLibrary(
     }
  
   char * query = new(STMTHEAP) char[1000];
-  str_sprintf(query, "insert into %s.\"%s\".%s values (%Ld, '%s', %d)",
+  str_sprintf(query, "insert into %s.\"%s\".%s values (%Ld, '%s', %d, 0)",
              getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_LIBRARIES,
              objUID,
               libFileName.data(),
@@ -1102,7 +1102,7 @@ void CmpSeabaseDDL::createSeabaseRoutine(
   
 
   char * query = new(STMTHEAP) char[2000+MAX_SIGNATURE_LENGTH];
-  str_sprintf(query, "insert into %s.\"%s\".%s values (%Ld, '%s', '%s', '%s', 
'%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', '%s', '%s', '%s', %Ld, '%s' 
)",
+  str_sprintf(query, "insert into %s.\"%s\".%s values (%Ld, '%s', '%s', '%s', 
'%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', '%s', '%s', '%s', %Ld, '%s', 
0)",
              getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_ROUTINES,
              objUID,
               udrType.data(),
@@ -1133,7 +1133,7 @@ void CmpSeabaseDDL::createSeabaseRoutine(
     }
 
   char * query1 = new(STMTHEAP) char[1000];
-  str_sprintf(query1, "insert into %s.\"%s\".%s values (%Ld, %Ld)",
+  str_sprintf(query1, "insert into %s.\"%s\".%s values (%Ld, %Ld, 0)",
              getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_LIBRARIES_USAGE,
              libUID, objUID);
   

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/2605440b/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp 
b/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
index 5a2c1d7..4037afc 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
@@ -10585,6 +10585,17 @@ desc_struct * 
CmpSeabaseDDL::getSeabaseUserTableDesc(const NAString &catName,
       if ((strcmp(constrType, COM_UNIQUE_CONSTRAINT_LIT) == 0) ||
           (strcmp(constrType, COM_PRIMARY_KEY_CONSTRAINT_LIT) == 0))
         {
+          // force the query plan; without this we tend to do full scans of
+          // TABLE_CONSTRAINTS which reduces DDL concurrency
+          str_sprintf(query,"control query shape 
sort(nested_join(nested_join(nested_join(scan('U'),scan('O')), 
scan('T','TRAFODION.\"_MD_\".TABLE_CONSTRAINTS_IDX')),cut))");
+          cliRC = cliInterface.setCQS(query);
+          if (cliRC < 0)
+            {
+              cliInterface.retrieveSQLDiagnostics(CmpCommon::diags());         
    
+              processReturn();
+              return NULL;
+            }
+
           str_sprintf(query, "select trim(O.catalog_name || '.' || '\"' || 
O.schema_name || '\"' || '.' || '\"' || O.object_name || '\"' ) constr_name, 
trim(O2.catalog_name || '.' || '\"' || O2.schema_name || '\"' || '.' || '\"' || 
O2.object_name || '\"' ) table_name from %s.\"%s\".%s U, %s.\"%s\".%s O, 
%s.\"%s\".%s O2, %s.\"%s\".%s T where  O.object_uid = U.foreign_constraint_uid 
and O2.object_uid = T.table_uid and T.constraint_uid = U.foreign_constraint_uid 
and U.unique_constraint_uid = %Ld order by 2, 1",
                       getSystemCatalog(), SEABASE_MD_SCHEMA, 
SEABASE_UNIQUE_REF_CONSTR_USAGE,
                       getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_OBJECTS,
@@ -10600,9 +10611,13 @@ desc_struct * 
CmpSeabaseDDL::getSeabaseUserTableDesc(const NAString &catName,
               cliInterface.retrieveSQLDiagnostics(CmpCommon::diags());
               
               processReturn();
+
+              cliInterface.resetCQS();
               
               return NULL;
             }
+      
+          cliInterface.resetCQS();
 
           ComTdbVirtTableRefConstraints * ringInfoArray = NULL;
           if (ringInfoQueue->numEntries() > 0)

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/2605440b/core/sql/sqlcomp/CmpSeabaseDDLupgrade.h
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLupgrade.h 
b/core/sql/sqlcomp/CmpSeabaseDDLupgrade.h
index 1316101..4e7111c 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLupgrade.h
+++ b/core/sql/sqlcomp/CmpSeabaseDDLupgrade.h
@@ -38,6 +38,9 @@ CmpSeabaseDDLmd.h
      to START_OLD_MD_v23 section. 
    -- Change name to *_OLD_MD.  (Ex: SEABASE_COLUMNS_OLD_MD)
    -- Change definition name to seabaseOldMDv23* (Ex: 
seabaseOldMDv23ColumnsDDL)
+      (Note: There was a reset in version numbers when Trafodion Release 1.1
+      went out. So, use "OldTrafMDvxx" now instead of "OldMDvxx", to avoid
+      conflicts should those numbering schemes overlap.)
    -- modify current definition to reflect new definition(Ex: 
seabaseColumnsDDL)
 
 CmpSeabaseDDLupgrade.h
@@ -46,7 +49,7 @@ CmpSeabaseDDLupgrade.h
        -- add old defn, insert/select col list, added/dropped col flag, etc.
   -- see struct MDUpgradeInfo for details on what fields need to be modified.
 
-CmpSeabaseDDL.h
+CmpSeabaseDDLincludes.h
 -- modify enum METADATA_MAJOR/MINOR, OLD_MAJOR/MINOR versions
 
 CmpSeabaseDDLcommon.cpp and other files:
@@ -129,8 +132,8 @@ struct MDDescsInfo
 // This section should reflect the upgrade steps needed to go from
 // previous to current version.
 // Modify it as needed.
-// Currently it is set to upgrade from V30(source major version 3, minor 
version 0)
-// to V31.
+// Currently it is set to upgrade from V11(source major version 1, minor 
version 1)
+// to V21.
 //////////////////////////////////////////////////////////////
 static const MDUpgradeInfo allMDupgradeInfo[] = {
   {SEABASE_AUTHS, SEABASE_AUTHS_OLD_MD,
@@ -147,9 +150,12 @@ static const MDUpgradeInfo allMDupgradeInfo[] = {
 
   {SEABASE_DEFAULTS, SEABASE_DEFAULTS_OLD_MD,
    seabaseDefaultsDDL, sizeof(seabaseDefaultsDDL),
+   seabaseOldTrafMDv11DefaultsDDL, sizeof(seabaseOldTrafMDv11DefaultsDDL),
    NULL, 0,
-   NULL, 0,
-   FALSE, NULL, NULL, NULL, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE},
+   TRUE, 
+   "attribute,attr_value,attr_comment,flags",
+   "attribute,attr_value,attr_comment,0",
+   NULL, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE},
 
   {SEABASE_INDEXES, SEABASE_INDEXES_OLD_MD,
    seabaseIndexesDDL, sizeof(seabaseIndexesDDL),
@@ -165,15 +171,21 @@ static const MDUpgradeInfo allMDupgradeInfo[] = {
 
   {SEABASE_LIBRARIES, SEABASE_LIBRARIES_OLD_MD,
    seabaseLibrariesDDL, sizeof(seabaseLibrariesDDL),
+   seabaseOldTrafMDv11LibrariesDDL, sizeof(seabaseOldTrafMDv11LibrariesDDL),
    NULL, 0,
-   NULL, 0,
-   FALSE, NULL, NULL, NULL, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE},
+   TRUE, 
+   "library_uid,library_filename,version,flags",
+   "library_uid,library_filename,version,0", 
+   NULL, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE},
 
   {SEABASE_LIBRARIES_USAGE, SEABASE_LIBRARIES_USAGE_OLD_MD,
    seabaseLibrariesUsageDDL, sizeof(seabaseLibrariesUsageDDL),
+   seabaseOldTrafMDv11LibrariesUsageDDL, 
sizeof(seabaseOldTrafMDv11LibrariesUsageDDL),
    NULL, 0,
-   NULL, 0,
-   FALSE, NULL, NULL, NULL, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE},
+   TRUE, 
+   "using_library_uid,used_udr_uid,flags",
+   "using_library_uid,used_udr_uid,0",
+   NULL, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE},
 
   {SEABASE_OBJECTS, SEABASE_OBJECTS_OLD_MD,
    seabaseObjectsDDL, sizeof(seabaseObjectsDDL),
@@ -195,9 +207,20 @@ static const MDUpgradeInfo allMDupgradeInfo[] = {
 
   {SEABASE_ROUTINES, SEABASE_ROUTINES_OLD_MD,
    seabaseRoutinesDDL, sizeof(seabaseRoutinesDDL),
+   seabaseOldTrafMDv11RoutinesDDL, sizeof(seabaseOldTrafMDv11RoutinesDDL),
    NULL, 0,
-   NULL, 0,
-   FALSE, NULL, NULL, NULL, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE},
+   TRUE,
+   "udr_uid,udr_type,language_type,deterministic_bool,sql_access,"
+   "call_on_null,isolate_bool,param_style,transaction_attributes,"
+   "max_results,state_area_size,external_name,parallelism,"
+   "user_version,external_security,execution_mode,library_uid,"
+   "signature,flags",
+   "udr_uid,udr_type,language_type,deterministic_bool,sql_access,"
+   "call_on_null,isolate_bool,param_style,transaction_attributes,"
+   "max_results,state_area_size,external_name,parallelism,"
+   "user_version,external_security,execution_mode,library_uid,"
+   "signature,0",   
+   NULL, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE},
 
   {SEABASE_SEQ_GEN, SEABASE_SEQ_GEN_OLD_MD,
    seabaseSeqGenDDL, sizeof(seabaseSeqGenDDL),
@@ -217,6 +240,13 @@ static const MDUpgradeInfo allMDupgradeInfo[] = {
    NULL, 0,
    FALSE, NULL, NULL, NULL, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE},
 
+   // For next metadata upgrade, replace NULL with 
SEABASE_TABLE_CONSTRAINTS_IDX_OLD_MD below
+  {SEABASE_TABLE_CONSTRAINTS_IDX, NULL /* index didn't exist before Trafodion 
2.1 */,
+   seabaseTableConstraintsIdxDDL, sizeof(seabaseTableConstraintsIdxDDL),
+   NULL, 0,
+   NULL, 0,
+   FALSE, NULL, NULL, NULL, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE},
+
   {SEABASE_TEXT, SEABASE_TEXT_OLD_MD,
    seabaseTextDDL, sizeof(seabaseTextDDL),
    NULL, 0,
@@ -251,7 +281,7 @@ static const MDUpgradeInfo allMDupgradeInfo[] = {
    NULL, 0,
    NULL, 0,
    NULL, 0,
-   FALSE, NULL, NULL, NULL, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE},
+   FALSE, NULL, NULL, NULL, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE},
 
   {SEABASE_VALIDATE_LIBRARY, SEABASE_VALIDATE_LIBRARY_OLD_MD,
    NULL, 0,


Reply via email to