trafodion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dbirds...@apache.org
Subject [1/2] trafodion git commit: [TRAFODION-3237] Fix incorrect PCode optimization
Date Wed, 12 Dec 2018 19:17:29 GMT
Repository: trafodion
Updated Branches:
  refs/heads/master 043309579 -> 7714b3fde


[TRAFODION-3237] Fix incorrect PCode optimization


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

Branch: refs/heads/master
Commit: 8b4e533d3082379dc090e7efeefab80741334d00
Parents: 889631a
Author: Dave Birdsall <dbirdsall@apache.org>
Authored: Mon Dec 10 23:32:00 2018 +0000
Committer: Dave Birdsall <dbirdsall@apache.org>
Committed: Mon Dec 10 23:32:00 2018 +0000

----------------------------------------------------------------------
 core/sql/exp/ExpPCodeOptimizations.cpp  |  5 +++--
 core/sql/regress/core/EXPECTED038.LINUX | 33 ++++++++++++++++++++++++++++
 core/sql/regress/core/TEST038           | 21 ++++++++++++++++++
 3 files changed, 57 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafodion/blob/8b4e533d/core/sql/exp/ExpPCodeOptimizations.cpp
----------------------------------------------------------------------
diff --git a/core/sql/exp/ExpPCodeOptimizations.cpp b/core/sql/exp/ExpPCodeOptimizations.cpp
index bb10be6..7f4447a 100644
--- a/core/sql/exp/ExpPCodeOptimizations.cpp
+++ b/core/sql/exp/ExpPCodeOptimizations.cpp
@@ -4340,8 +4340,9 @@ NABoolean PCodeCfg::localCSE(INSTLIST** parent, PCodeBlock* tailBlock,
               (((ex_conv_clause*)clauseHead)->treatAllSpacesAsZero() ==
                ((ex_conv_clause*)clauseTail)->treatAllSpacesAsZero()));
             if ( match ) {
-               if ( ((ex_conv_clause*)clauseHead)->getInstruction() ==
-                    CONV_DATETIME_DATETIME )
+               ConvInstruction instr = ((ex_conv_clause*)clauseHead)->getInstruction();
+               if ((instr == CONV_DATETIME_DATETIME) ||
+                   ((instr >= CONV_INTERVALY_INTERVALMO) && (instr <= CONV_INTERVAL_ASCII)))
                {
                   Attributes *tgtH = ((ex_conv_clause*)clauseHead)->getOperand(0);
                   Attributes *tgtT = ((ex_conv_clause*)clauseTail)->getOperand(0);

http://git-wip-us.apache.org/repos/asf/trafodion/blob/8b4e533d/core/sql/regress/core/EXPECTED038.LINUX
----------------------------------------------------------------------
diff --git a/core/sql/regress/core/EXPECTED038.LINUX b/core/sql/regress/core/EXPECTED038.LINUX
index 6fcb4e6..49cb975 100644
--- a/core/sql/regress/core/EXPECTED038.LINUX
+++ b/core/sql/regress/core/EXPECTED038.LINUX
@@ -4944,6 +4944,39 @@ CREATE TABLE TRAFODION.SCH.T038FC2
 
 --- SQL operation complete.
 >>
+>>-- test for the bug fixed by JIRA TRAFODION-3237
+>>
+>>create table t038traf3237 (
++>c9 interval day(7) to second default NULL,
++>c10 interval day(13) to second(0) default NULL
++>);
+
+--- SQL operation complete.
+>>
+>>insert into t038traf3237 values (
++>interval '0 00:00:00' day(7) to second,
++>interval '0 00:00:00' day(13) to second(0));
+
+--- 1 row(s) inserted.
+>>
+>>insert into t038traf3237
++>select
++>c9 + interval '1' day,
++>c10 + interval '1' day -- gives incorrect result without TRAFODION-3237 fix
++>from t038traf3237;
+
+--- 1 row(s) inserted.
+>>
+>>select * from t038traf3237;
+
+C9 C10
+----------
+
+ 0 00:00:00.000000 0 00:00:00
+ 1 00:00:00.000000 1 00:00:00
+
+--- 2 row(s) selected.
+>>
 >>log;
 >>
 >>create table t038aqr( a int not null, b int not null, primary key(a) );

http://git-wip-us.apache.org/repos/asf/trafodion/blob/8b4e533d/core/sql/regress/core/TEST038
----------------------------------------------------------------------
diff --git a/core/sql/regress/core/TEST038 b/core/sql/regress/core/TEST038
index cad203e..d35504a 100755
--- a/core/sql/regress/core/TEST038
+++ b/core/sql/regress/core/TEST038
@@ -1241,6 +1241,25 @@ from T038fcl
 
 showddl T038fc2;
 
+-- test for the bug fixed by JIRA TRAFODION-3237
+
+create table t038traf3237 (
+c9 interval day(7) to second default NULL,
+c10 interval day(13) to second(0) default NULL
+);
+
+insert into t038traf3237 values (
+interval '0 00:00:00' day(7) to second,
+interval '0 00:00:00' day(13) to second(0));
+
+insert into t038traf3237 
+select 
+c9 + interval '1' day,
+c10 + interval '1' day -- gives incorrect result without TRAFODION-3237 fix 
+from t038traf3237;
+
+select * from t038traf3237;
+
 log;
 
 ?section aqr
@@ -1305,4 +1324,6 @@ drop table T038nvl;
 drop table T038fcl;
 drop table T038fc2;
 
+drop table T038traf3237;
+
 


Mime
View raw message