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 2015/11/06 17:54:27 UTC

[1/2] incubator-trafodion git commit: [TRAFODION-1590] UPSERT into VALUES (, ...) fails
Repository: incubator-trafodion
Updated Branches:
  refs/heads/master 986d4fecb -> 392b99b96


[TRAFODION-1590] UPSERT into <table> VALUES (<subquery>, ...) fails

Please see JIRA for fix information. This occurs only when table has an index.
Thank you to Selva, Hans and Dave for help with this fix.


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

Branch: refs/heads/master
Commit: e7dd420e76dc7d8dedd6020c01b7b3b2824dd03b
Parents: bd960ca
Author: Suresh Subbiah <su...@apache.org>
Authored: Thu Nov 5 18:45:42 2015 +0000
Committer: Suresh Subbiah <su...@apache.org>
Committed: Thu Nov 5 18:45:42 2015 +0000

----------------------------------------------------------------------
 core/sql/optimizer/BindRelExpr.cpp          | 43 ++++++++++++------------
 core/sql/regress/executor/EXPECTED015.SB    | 27 +++++++++++++++
 core/sql/regress/executor/TEST015           |  7 ++++
 core/sql/regress/tools/runregr_executor.ksh | 12 +++----
 4 files changed, 62 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e7dd420e/core/sql/optimizer/BindRelExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/BindRelExpr.cpp b/core/sql/optimizer/BindRelExpr.cpp
index 5e15d02..795e249 100644
--- a/core/sql/optimizer/BindRelExpr.cpp
+++ b/core/sql/optimizer/BindRelExpr.cpp
@@ -10260,22 +10260,18 @@ RelExpr* Insert::xformUpsertToMerge(BindWA *bindWA)
                 NULL);
 
   ((MergeUpdate *)re)->setXformedUpsert();
-  ValueIdSet debugSet;
-  if (child(0) && (child(0)->getOperatorType() != REL_TUPLE))
-  {
-    RelExpr * mu = re;
+  RelExpr * mu = re;
     
-    re = new(bindWA->wHeap()) Join
-      (child(0), re, REL_TSJ_FLOW, NULL);
-    ((Join*)re)->doNotTransformToTSJ();
-    ((Join*)re)->setTSJForMerge(TRUE);	
-    ((Join*)re)->setTSJForMergeWithInsert(TRUE);
-    ((Join*)re)->setTSJForWrite(TRUE);
-    if (bindWA->hasDynamicRowsetsInQuery())
-      mu->getGroupAttr()->addCharacteristicInputs(myOuterRefs);
-    else
-      re->getGroupAttr()->addCharacteristicInputs(myOuterRefs);
-  } 
+  re = new(bindWA->wHeap()) Join
+    (child(0), mu, REL_TSJ_FLOW, NULL);
+  ((Join*)re)->doNotTransformToTSJ();
+  ((Join*)re)->setTSJForMerge(TRUE);	
+  ((Join*)re)->setTSJForMergeWithInsert(TRUE);
+  ((Join*)re)->setTSJForWrite(TRUE);
+  if (bindWA->hasDynamicRowsetsInQuery())
+    mu->getGroupAttr()->addCharacteristicInputs(myOuterRefs);
+  else
+    re->getGroupAttr()->addCharacteristicInputs(myOuterRefs);
   
   re = re->bindNode(bindWA);
   if (bindWA->errStatus())
@@ -10589,8 +10585,14 @@ RelExpr *MergeUpdate::bindNode(BindWA *bindWA)
   
   bindWA->initNewScope();
 
-  if ((isMerge()) && 
-      (child(0)))
+  // For an xformaed upsert any UDF or subquery is guaranteed to be 
+  // in the using clause. Upsert will not generate a merge without using 
+  // clause. ON clause, when matched SET clause and when not matched INSERT
+  // clauses all use expressions from the using clause. (same vid).
+  // Therefore any subquery or UDF in the using clause will flow to the
+  // rest of he tree through the TSJ and will be available. Each subquery
+  // will be evaluated only once, and will be evaluated prior to the merge
+  if (isMerge() && child(0) && !xformedUpsert())
   {
     ItemExpr *selPred = child(0)->castToRelExpr()->selPredTree();
     if (selPred || where_)
@@ -10626,8 +10628,7 @@ RelExpr *MergeUpdate::bindNode(BindWA *bindWA)
     }
   }
 
-  if ((isMerge()) &&
-      (recExprTree()))
+  if (isMerge() && recExprTree() && !xformedUpsert())
   {
     if (recExprTree()->containsSubquery())
     {
@@ -10649,14 +10650,14 @@ RelExpr *MergeUpdate::bindNode(BindWA *bindWA)
   // if insertValues, then this is an upsert stmt.
   if (insertValues())
     {
-      if (insertValues()->containsSubquery())
+      if (insertValues()->containsSubquery() && !xformedUpsert())
         {
           *CmpCommon::diags() << DgSqlCode(-3241) 
                               << DgString0(" Subquery in INSERT clause not allowed.");
           bindWA->setErrStatus();
           return this;
         }
-      if (insertValues()->containsUDF())
+      if (insertValues()->containsUDF() && !xformedUpsert())
         {
           *CmpCommon::diags() << DgSqlCode(-4471) 
                               << DgString0(((UDFunction *)insertValues()->containsUDF())->

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e7dd420e/core/sql/regress/executor/EXPECTED015.SB
----------------------------------------------------------------------
diff --git a/core/sql/regress/executor/EXPECTED015.SB b/core/sql/regress/executor/EXPECTED015.SB
index 02efa0c..a478603 100755
--- a/core/sql/regress/executor/EXPECTED015.SB
+++ b/core/sql/regress/executor/EXPECTED015.SB
@@ -1694,4 +1694,31 @@ LC   RC   OP   OPERATOR              OPT       DESCRIPTION           CARD
 
 --- 0 row(s) inserted.
 >>
+>>-- Upsert/merge with self-referntial subquery in values list
+>>delete from t015t7;
+
+--- 1 row(s) deleted.
+>>upsert into t015t7 values (1, NVL((select b from t015t7 where a = 1),DEFAULT),10) ;
+
+--- 1 row(s) inserted.
+>>select * from t015t7;
+
+A            B                     C          
+-----------  --------------------  -----------
+
+          1                     2           10
+
+--- 1 row(s) selected.
+>>upsert into t015t7 values (1, NVL((select b+1 from t015t7 where a = 1),DEFAULT),20) ;
+
+--- 1 row(s) inserted.
+>>select * from t015t7;
+
+A            B                     C          
+-----------  --------------------  -----------
+
+          1                     3           20
+
+--- 1 row(s) selected.
+>>
 >>log;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e7dd420e/core/sql/regress/executor/TEST015
----------------------------------------------------------------------
diff --git a/core/sql/regress/executor/TEST015 b/core/sql/regress/executor/TEST015
index b8d41d3..7512d0e 100755
--- a/core/sql/regress/executor/TEST015
+++ b/core/sql/regress/executor/TEST015
@@ -731,5 +731,12 @@ upsert into t015t14 values (1,2),(11,12);
 upsert into t015t15 values (2);
 upsert into t015t14 values (1,3);
 
+-- Upsert/merge with self-referntial subquery in values list
+delete from t015t7;
+upsert into t015t7 values (1, NVL((select b from t015t7 where a = 1),DEFAULT),10) ;
+select * from t015t7;
+upsert into t015t7 values (1, NVL((select b+1 from t015t7 where a = 1),DEFAULT),20) ;
+select * from t015t7;
+
 log;
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e7dd420e/core/sql/regress/tools/runregr_executor.ksh
----------------------------------------------------------------------
diff --git a/core/sql/regress/tools/runregr_executor.ksh b/core/sql/regress/tools/runregr_executor.ksh
index 2cc337f..a34af0f 100755
--- a/core/sql/regress/tools/runregr_executor.ksh
+++ b/core/sql/regress/tools/runregr_executor.ksh
@@ -449,9 +449,9 @@ fi
 
 # Tests that use SPJ on NSK or Linux require a running ODBC
 # service. So if the regressions are running, start MXOAS.
-if [ $USE_NDCS -ne 0 -a $diffOnly -eq 0 ]; then
-  START_MXODBC
-fi
+#if [ $USE_NDCS -ne 0 -a $diffOnly -eq 0 ]; then
+#  START_MXODBC
+#fi
 
 # main loop over all test files
 for i in $prettyfiles; do
@@ -914,9 +914,9 @@ for i in $prettyfiles; do
 done # for i in $prettyfiles
 
 # stop the MXOAS if it was started
-if [ $MXODBC_USABLE -eq 1 ]; then
-  STOP_MXODBC
-fi
+#if [ $MXODBC_USABLE -eq 1 ]; then
+#  STOP_MXODBC
+#fi
 
 #rm -f $MAKESCRIPT 2>$NULL
 rm -f $REGRRUNDIR/runmxcmp.ksh 2>$NULL


[2/2] incubator-trafodion git commit: Merge branch 'master' of github.com:apache/incubator-trafodion into upsert1

Posted by su...@apache.org.
Merge branch 'master' of github.com:apache/incubator-trafodion into upsert1


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

Branch: refs/heads/master
Commit: 392b99b96e9e87b5e42a62df7f919d96ed89d990
Parents: e7dd420 986d4fe
Author: Suresh Subbiah <su...@apache.org>
Authored: Thu Nov 5 23:53:19 2015 +0000
Committer: Suresh Subbiah <su...@apache.org>
Committed: Thu Nov 5 23:53:19 2015 +0000

----------------------------------------------------------------------
 .rat-excludes                                   |    1 -
 DISCLAIMER.txt                                  |   12 +
 LICENSE.txt                                     |  271 +
 NOTICE.txt                                      |    2 +-
 RAT_README.txt                                  |  158 +-
 README.txt                                      |   35 +
 core/rest/pom.xml                               |    6 +-
 core/sqf/sqenvcom.sh                            |    4 +-
 core/sqf/sql/scripts/install_traf_components    |    1 +
 .../transactional/SplitBalanceHelper.java       |    2 +-
 core/sql/optimizer/NAColumn.cpp                 |   24 +
 core/sql/optimizer/NAColumn.h                   |    3 +
 core/sql/optimizer/NAFileSet.cpp                |   14 +
 core/sql/optimizer/NAFileSet.h                  |    2 +
 core/sql/optimizer/OptPhysRelExpr.cpp           |  123 +-
 core/sql/optimizer/ScmCostMethod.cpp            |   13 +-
 core/sql/regress/hive/EXPECTED018               |  176 +-
 core/sql/sqlcomp/CmpSeabaseDDLtable.cpp         |    7 -
 core/sql/sqlcomp/nadefaults.cpp                 |    6 +-
 core/sql/ustat/hs_cli.cpp                       |  204 +-
 dcs/pom.xml                                     |    8 +-
 .../dcs/tmpl/server/ServerStatusTmpl.jamon      |    7 +-
 .../dcs/tmpl/servermt/ServerStatusTmpl.jamon    |    7 +-
 .../org/trafodion/dcs/master/ServerManager.java |    3 +-
 .../master/datatables/license-gpl2.txt          |  339 -
 .../resources/dcs-webapps/master/servers.jsp    |   34 +-
 .../main/resources/dcs-webapps/static/dcs.css   |   16 +-
 .../java/org/trafodion/jdbc_test/TestCat.java   |    6 +-
 dcs/src/test/pytests/.env.sh.tmpl               |    2 +-
 dcs/src/test/pytests/.odbc.ini.tmpl             |    2 -
 install/installer/traf_cloudera_mods98          |   96 +-
 install/installer/traf_config                   |  297 +
 install/installer/traf_config_setup             |   22 +-
 install/installer/traf_getHadoopNodes           |   25 +-
 install/installer/traf_hortonworks_mods98       |    9 +
 install/installer/traf_start                    |  290 +-
 .../installer/trafodion_apache_hadoop_install   |    6 +-
 install/installer/trafodion_install             |   35 +-
 install/installer/trafodion_license             |   27 +-
 readme.md                                       |    5 -
 tests/phx/phoenix_test.py                       |    2 +-
 .../SetCertificateDirReg.rc                     |  222 +-
 .../SetCertificateDirReg_os.vcxproj             |  390 +-
 .../SetCertificateDirReg_os.vcxproj.filters     |  104 +-
 .../SetCertificateDirReg_os.vcxproj.user        |    4 +-
 .../SetCertificateDirReg/odbccp32.props         |   34 +-
 .../SetCertificateDirReg/resource.h             |   40 +-
 .../SetCertificateDirReg_os.sln                 |   52 +-
 .../Install/UpdateDSN/UpdateDSN/UpdateDSN.cpp   |  200 -
 .../UpdateDSN/UpdateDSN/UpdateDSN.vcxproj       |  170 -
 .../UpdateDSN/UpdateDSN.vcxproj.filters         |   33 -
 .../UpdateDSN/UpdateDSN/UpdateDSN_os.vcxproj    |  104 -
 .../UpdateDSN/UpdateDSN_os.vcxproj.filters      |   33 -
 .../UpdateDSN/UpdateDSN_os.vcxproj.user         |    3 -
 .../Install/UpdateDSN/UpdateDSN/stdafx.cpp      |   28 -
 win-odbc64/Install/UpdateDSN/UpdateDSN/stdafx.h |   37 -
 win-odbc64/Install/UpdateDSN/UpdateDSN_os.sln   |   26 -
 .../Install/win64_installer/installer.iss       |  200 +
 .../win64_installer/win64_installer_os.ism      | 6029 ------------------
 win-odbc64/odbcclient/Drvr35Res/Drvr35Res.rc    |   12 +-
 .../odbcclient/Drvr35Res/Drvr35Res_os.vcxproj   |    4 +-
 .../odbcclient/Drvr35Res/res/Drvr35Res.rc2      |   26 +-
 win-odbc64/odbcclient/README.txt                |  111 +-
 .../odbcclient/TranslationDll/TranslationDll.rc |   12 +-
 .../TranslationDll/TranslationDll_os.vcxproj    |    4 +-
 win-odbc64/odbcclient/build_os.bat              |  333 +-
 win-odbc64/odbcclient/drvr35/TCPIPV4/TCPIPV4.RC |   12 +-
 .../drvr35/TCPIPV4/TCPIPV4_os.vcxproj           |    8 +-
 win-odbc64/odbcclient/drvr35/TCPIPV6/TCPIPV6.RC |   12 +-
 .../drvr35/TCPIPV6/TCPIPV6_os.vcxproj           |    8 +-
 win-odbc64/odbcclient/drvr35/drvr35.rc          |   12 +-
 win-odbc64/odbcclient/drvr35/drvr35_os.vcxproj  |   16 +-
 .../odbcclient/drvr35adm/Drvr35Adm_os.vcxproj   |    5 +-
 win-odbc64/odbcclient/drvr35adm/drvr35adm.rc    |   12 +-
 win-odbc64/odbcclient/drvr35adm/pagenetwork.cpp |    2 +-
 .../odbcclient/drvr35adm/tabpagenetwork.cpp     |    2 +-
 win-odbc64/odbcclient/drvr35msg/DrvMsg35.rc     |   12 +-
 .../odbcclient/drvr35msg/Drvr35Msg_os.vcxproj   |    4 +-
 win-odbc64/odbcclient/odbcclient_os.sln         |   17 +-
 win-odbc64/odbcclient/pkg.bat                   |   38 -
 80 files changed, 2205 insertions(+), 8468 deletions(-)
----------------------------------------------------------------------