You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafodion.apache.org by su...@apache.org on 2016/09/11 23:53:34 UTC

[1/3] incubator-trafodion git commit: automatic creation of schemas

Repository: incubator-trafodion
Updated Branches:
  refs/heads/master 9e8c75fc7 -> 057ae469c


automatic creation of schemas

couple changes:
1) if dev regressions are being run and regr schema ("trafodion.sch")
  doesn't exist, then it is automatically created as part
  of the first 'create' stmt. This schema is also updated
  as the default schema in DEFAULTS metadata table.
2) if cqd traf_auto_create_schema is set and the schema specified
  in a 'create' stmt doesn't exist, then it is automatically
  created. This helps with migrating scripts from other vendors
  if schema is specified as part of create table stmt.


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

Branch: refs/heads/master
Commit: 48be43e983d2b03dc0d09a44bbda39b8961fece5
Parents: 35342a4
Author: Anoop Sharma <an...@esgyn.com>
Authored: Sun Sep 11 20:17:51 2016 +0000
Committer: Anoop Sharma <an...@esgyn.com>
Committed: Sun Sep 11 20:17:51 2016 +0000

----------------------------------------------------------------------
 core/sql/regress/seabase/EXPECTED032     | 43 +++++++++++++++++++++++++--
 core/sql/regress/seabase/TEST032         | 15 ++++++++++
 core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp | 38 +++++++++++++++++++----
 core/sql/sqlcomp/DefaultConstants.h      |  4 +++
 core/sql/sqlcomp/nadefaults.cpp          |  2 ++
 5 files changed, 95 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/48be43e9/core/sql/regress/seabase/EXPECTED032
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/EXPECTED032 b/core/sql/regress/seabase/EXPECTED032
index b43dd14..45f0304 100644
--- a/core/sql/regress/seabase/EXPECTED032
+++ b/core/sql/regress/seabase/EXPECTED032
@@ -15,7 +15,7 @@
 >>invoke t032t1;
 
 -- Definition of Trafodion table TRAFODION.SCH.T032T1
--- Definition current  Wed Aug 24 20:59:45 2016
+-- Definition current  Sun Sep 11 15:22:27 2016
 
   (
     A                                INT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -140,7 +140,7 @@ B
 (EXPR)                        
 ------------------------------
 
-RANDOMVAL=1935127796          
+RANDOMVAL=262036305           
 
 --- 1 row(s) selected.
 >>select random() from (values(1)) x(a);
@@ -294,4 +294,43 @@ A
 
 --- 1 row(s) selected.
 >>
+>>
+>>-- auto create schema
+>>
+>>-- should fail, schema doesnt exist
+>>create table t032sch.t032t2 (a int);
+
+*** ERROR[1003] Schema TRAFODION.T032SCH does not exist.
+
+--- SQL operation failed with errors.
+>>
+>>-- should succeed, schema will be automatically created
+>>cqd traf_auto_create_schema 'ON';
+
+--- SQL operation complete.
+>>create table t032sch.t032t2 (a int);
+
+--- SQL operation complete.
+>>set schema t032sch;
+
+--- SQL operation complete.
+>>invoke t032t2;
+
+-- Definition of Trafodion table TRAFODION.T032SCH.T032T2
+-- Definition current  Sun Sep 11 15:22:36 2016
+
+  (
+    SYSKEY                           LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
+  , A                                INT DEFAULT NULL
+  )
+
+--- SQL operation complete.
+>>insert into t032t2 values (1);
+
+--- 1 row(s) inserted.
+>>
+>>drop schema t032sch cascade;
+
+--- SQL operation complete.
+>>
 >>log;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/48be43e9/core/sql/regress/seabase/TEST032
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/TEST032 b/core/sql/regress/seabase/TEST032
index 0b618be..283d1f8 100644
--- a/core/sql/regress/seabase/TEST032
+++ b/core/sql/regress/seabase/TEST032
@@ -87,5 +87,20 @@ select * from (values(1)) x(a) where current_timestamp(0) = current_timestamp(6)
 
 select cast(1e0 as interval year) from dual;
 
+
+-- auto create schema
+
+-- should fail, schema doesnt exist
+create table t032sch.t032t2 (a int);
+
+-- should succeed, schema will be automatically created
+cqd traf_auto_create_schema 'ON';
+create table t032sch.t032t2 (a int);
+set schema t032sch;
+invoke t032t2;
+insert into t032t2 values (1);
+
+drop schema t032sch cascade;
+
 log;
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/48be43e9/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp b/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
index 6363343..2477c9e 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
@@ -8917,8 +8917,9 @@ short CmpSeabaseDDL::executeSeabaseDDL(DDLExpr * ddlExpr, ExprNode * ddlNode,
           else
             {
               createSeabaseTable(createTableParseNode, currCatName, currSchName);
-              
-              if ((getenv("SQLMX_REGRESS")) &&
+
+              if (((getenv("SQLMX_REGRESS")) ||
+                   (CmpCommon::getDefault(TRAF_AUTO_CREATE_SCHEMA) == DF_ON)) &&
                   (CmpCommon::diags()->getNumber(DgSqlCode::ERROR_)) &&
                   (CmpCommon::diags()->mainSQLCODE() == -CAT_SCHEMA_DOES_NOT_EXIST_ERROR))
                 {
@@ -8930,16 +8931,43 @@ short CmpSeabaseDDL::executeSeabaseDDL(DDLExpr * ddlExpr, ExprNode * ddlNode,
                   const NAString schemaNamePart = 
                     tableName.getSchemaNamePartAsAnsiString(TRUE);
 
-                  if (schemaNamePart == SEABASE_REGRESS_DEFAULT_SCHEMA)
+                  char query[1000];
+                  if ((getenv("SQLMX_REGRESS")) &&
+                      (schemaNamePart == SEABASE_REGRESS_DEFAULT_SCHEMA))
+                    {
+                      CmpCommon::diags()->clear();
+                      str_sprintf(query, "create shared schema %s.%s",
+                                  TRAFODION_SYSCAT_LIT, 
+                                  SEABASE_REGRESS_DEFAULT_SCHEMA);
+                      cliRC = cliInterface.executeImmediate(query);
+                      if (cliRC >= 0)
+                        {
+                          str_sprintf(query, "upsert into %s.\"%s\".%s values ('SCHEMA ', '%s.%s ', 'inserted during regressions run', 0);",
+                                      TRAFODION_SYSCAT_LIT, 
+                                      SEABASE_MD_SCHEMA,
+                                      SEABASE_DEFAULTS,
+                                      TRAFODION_SYSCAT_LIT,
+                                      SEABASE_REGRESS_DEFAULT_SCHEMA);
+                          cliRC = cliInterface.executeImmediate(query);
+                          if (cliRC >= 0)
+                            {
+                              createSeabaseTable(createTableParseNode, currCatName, currSchName);
+                            }
+                        }
+                    } // if
+                  else if (CmpCommon::getDefault(TRAF_AUTO_CREATE_SCHEMA) == DF_ON)
                     {
+                      // create this schema
                       CmpCommon::diags()->clear();
-                      cliRC = cliInterface.executeImmediate("create shared schema trafodion.sch");
+                      str_sprintf(query, "create schema %s.\"%s\";",
+                                  TRAFODION_SYSCAT_LIT, schemaNamePart.data());
+                      cliRC = cliInterface.executeImmediate(query);
                       if (cliRC >= 0)
                         {
                           createSeabaseTable(createTableParseNode, currCatName, currSchName);
                         }
                     }
-                }
+                }     
             }
         }
       else if (ddlNode->getOperatorType() == DDL_CREATE_HBASE_TABLE)

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/48be43e9/core/sql/sqlcomp/DefaultConstants.h
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/DefaultConstants.h b/core/sql/sqlcomp/DefaultConstants.h
index 08076ff..876ac4d 100644
--- a/core/sql/sqlcomp/DefaultConstants.h
+++ b/core/sql/sqlcomp/DefaultConstants.h
@@ -3854,6 +3854,10 @@ enum DefaultConstants
   // allow ORDER BY in subqueries.
   ALLOW_ORDER_BY_IN_SUBQUERIES,
 
+  // if the schema specified in a create stmt doesn't exist, automatically
+  // create it.
+  TRAF_AUTO_CREATE_SCHEMA,
+
   // This enum constant must be the LAST one in the list; it's a count,
   // not an Attribute (it's not IN DefaultDefaults; it's the SIZE of it)!
   __NUM_DEFAULT_ATTRIBUTES

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/48be43e9/core/sql/sqlcomp/nadefaults.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/nadefaults.cpp b/core/sql/sqlcomp/nadefaults.cpp
index 77ca3c9..4b184ca 100644
--- a/core/sql/sqlcomp/nadefaults.cpp
+++ b/core/sql/sqlcomp/nadefaults.cpp
@@ -3303,6 +3303,8 @@ XDDkwd__(SUBQUERY_UNNESTING,			"ON"),
 
   DDkwd__(TRAF_ALTER_COL_ATTRS,                 "ON"),   
 
+  DDkwd__(TRAF_AUTO_CREATE_SCHEMA,                 "OFF"),   
+
   DDkwd__(TRAF_BLOB_AS_VARCHAR,                 "ON"), //set to OFF to enable Lobs support  
 
   DDkwd__(TRAF_BOOLEAN_IO,                        "OFF"),


[2/3] incubator-trafodion git commit: Merge remote branch 'origin/master' into ansharma_trafixes_br

Posted by su...@apache.org.
Merge remote branch 'origin/master' into ansharma_trafixes_br


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

Branch: refs/heads/master
Commit: 81c1c6d9596fdefc1f133fea6617492f32190bbd
Parents: 48be43e 9e8c75f
Author: Anoop Sharma <an...@esgyn.com>
Authored: Sun Sep 11 20:23:19 2016 +0000
Committer: Anoop Sharma <an...@esgyn.com>
Committed: Sun Sep 11 20:23:19 2016 +0000

----------------------------------------------------------------------
 core/sql/executor/ExExeUtilCli.cpp |  8 +++++---
 core/sql/executor/ExExplain.cpp    | 11 +++++++----
 core/sql/sqlci/SqlCmd.cpp          |  6 ++++--
 3 files changed, 16 insertions(+), 9 deletions(-)
----------------------------------------------------------------------



[3/3] incubator-trafodion git commit: Merge [TRAFODION-2215] PR-695 automatic creation of schemas

Posted by su...@apache.org.
Merge [TRAFODION-2215] PR-695 automatic creation of schemas


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

Branch: refs/heads/master
Commit: 057ae469c2ec9a363159851cdee905ad65aafaa9
Parents: 9e8c75f 81c1c6d
Author: Suresh Subbiah <su...@apache.org>
Authored: Sun Sep 11 23:53:09 2016 +0000
Committer: Suresh Subbiah <su...@apache.org>
Committed: Sun Sep 11 23:53:09 2016 +0000

----------------------------------------------------------------------
 core/sql/regress/seabase/EXPECTED032     | 43 +++++++++++++++++++++++++--
 core/sql/regress/seabase/TEST032         | 15 ++++++++++
 core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp | 38 +++++++++++++++++++----
 core/sql/sqlcomp/DefaultConstants.h      |  4 +++
 core/sql/sqlcomp/nadefaults.cpp          |  2 ++
 5 files changed, 95 insertions(+), 7 deletions(-)
----------------------------------------------------------------------