You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafodion.apache.org by se...@apache.org on 2016/03/08 04:37:02 UTC

[2/3] incubator-trafodion git commit: [TRAFODION-1865] fix issues from reviewers

[TRAFODION-1865] fix issues from reviewers


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

Branch: refs/heads/master
Commit: ba7f4fea793cac5234694685e45dc3a1aa7d8fbc
Parents: 4bc4e60
Author: Liu Ming <ov...@sina.com>
Authored: Sun Mar 6 15:08:55 2016 +0000
Committer: Liu Ming <ov...@sina.com>
Committed: Sun Mar 6 15:08:55 2016 +0000

----------------------------------------------------------------------
 core/sql/optimizer/BindRI.cpp               |  6 ++-
 core/sql/regress/compGeneral/EXPECTED013.SB | 48 ++++++++++++++++++++++++
 core/sql/regress/compGeneral/TEST013        | 28 ++++++++++++++
 3 files changed, 81 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ba7f4fea/core/sql/optimizer/BindRI.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/BindRI.cpp b/core/sql/optimizer/BindRI.cpp
index 33b17b4..1b3d138 100644
--- a/core/sql/optimizer/BindRI.cpp
+++ b/core/sql/optimizer/BindRI.cpp
@@ -409,6 +409,10 @@ void RefConstraint::getMatchOptionPredicateText(NAString &text,
 }
 
 //helper function to check if the given column name is reserved hidden coloum
+//NOTE:
+//  this function hardcode the special name string for SALT, DIVSION columns
+//  if the naming convension of SALT/DIVISION column is changed,
+//  this function MUST be changed as well
 static NABoolean isHiddenColumn(const char *colname)
 {
   int len = strlen(colname);
@@ -419,7 +423,7 @@ static NABoolean isHiddenColumn(const char *colname)
   //must longer than 12
   if(len >= 12) {
     //must end with _
-    if(colname[len] == '_')
+    if(colname[len-1] == '_')
     {
       //if begin with _DIVISION_?
       if(strncmp(colname,"_DIVISION_",10) == 0) 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ba7f4fea/core/sql/regress/compGeneral/EXPECTED013.SB
----------------------------------------------------------------------
diff --git a/core/sql/regress/compGeneral/EXPECTED013.SB b/core/sql/regress/compGeneral/EXPECTED013.SB
index 740cff2..97143c6 100644
--- a/core/sql/regress/compGeneral/EXPECTED013.SB
+++ b/core/sql/regress/compGeneral/EXPECTED013.SB
@@ -367,7 +367,55 @@ SCAN
 
 --- 2 row(s) inserted.
 >>
+>>create table fksalta ( id int not null, PRIMARY KEY (id))SALT USING 4 PARTITIONS;
+
+--- SQL operation complete.
+>>
+>>CREATE TABLE fksaltb ( id int not null, val int,
++>  PRIMARY KEY (id),
++>  CONSTRAINT FKsalt FOREIGN KEY (val) REFERENCES fksalta (id))
++>  SALT USING 4 PARTITIONS;
+
+--- SQL operation complete.
+>>
+>>INSERT INTO fksalta VALUES ( 1 );
+
+--- 1 row(s) inserted.
+>>
+>>INSERT INTO fksaltb VALUES ( 1, 1);
+
+--- 1 row(s) inserted.
+>>
+>>INSERT INTO fksaltb VALUES ( 2, 2);
+
+*** ERROR[8103] The operation is prevented by referential integrity constraint TRAFODION.SCH.FKSALT on table TRAFODION.SCH.FKSALTB.
+
+--- 0 row(s) inserted.
+>>
+>>CREATE TABLE fkdiva( store_id integer not null,
++>                   item_id  integer not null,
++>                sale_date date default date '2000-01-01' not null,
++>                  sale_amt numeric(10,2),
++>                   primary key (store_id, item_id, sale_date))
++> division by (date_part('YEARMONTH', sale_date));
+
+--- SQL operation complete.
 >>
+>>create table fkdivb(c1 int not null, c2 int , c3 int, c4  date, primary key(c1), CONSTRAINT FKDIV FOREIGN KEY (c2,c3, c4) REFERENCES fkdiva (store_id,item_id, sale_date));
+
+--- SQL operation complete.
+>>
+>>INSERT INTO fkdiva VALUES ( 1 , 1, date'2016-03-05', 10.2 );
+
+--- 1 row(s) inserted.
+>>INSERT INTO fkdivb VALUES ( 1 , 1, 1, date'2016-03-05');
+
+--- 1 row(s) inserted.
+>>INSERT INTO fkdivb VALUES ( 2 , 2, 1, date'2016-01-25');
+
+*** ERROR[8103] The operation is prevented by referential integrity constraint TRAFODION.SCH.FKDIV on table TRAFODION.SCH.FKDIVB.
+
+--- 0 row(s) inserted.
 >>
 >>--- uk0 should be eliminated
 >>-- two table RI constraint join

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ba7f4fea/core/sql/regress/compGeneral/TEST013
----------------------------------------------------------------------
diff --git a/core/sql/regress/compGeneral/TEST013 b/core/sql/regress/compGeneral/TEST013
index ceca013..9e77bcf 100644
--- a/core/sql/regress/compGeneral/TEST013
+++ b/core/sql/regress/compGeneral/TEST013
@@ -167,7 +167,31 @@ create table t_013 ( a int not null,
 
 insert into t_013 values (1, 'abc', 'def'), (2, 'ghi', 'jkl');
 
+create table fksalta ( id int not null, PRIMARY KEY (id))SALT USING 4 PARTITIONS;
 
+CREATE TABLE fksaltb ( id int not null, val int,
+  PRIMARY KEY (id),
+  CONSTRAINT FKsalt FOREIGN KEY (val) REFERENCES fksalta (id))
+  SALT USING 4 PARTITIONS;
+
+INSERT INTO fksalta VALUES ( 1 );
+
+INSERT INTO fksaltb VALUES ( 1, 1);
+
+INSERT INTO fksaltb VALUES ( 2, 2);
+
+CREATE TABLE fkdiva( store_id integer not null,
+                   item_id  integer not null,
+                sale_date date default date '2000-01-01' not null,
+                  sale_amt numeric(10,2),
+                   primary key (store_id, item_id, sale_date))
+ division by (date_part('YEARMONTH', sale_date));
+
+create table fkdivb(c1 int not null, c2 int , c3 int, c4  date, primary key(c1), CONSTRAINT FKDIV FOREIGN KEY (c2,c3, c4) REFERENCES fkdiva (store_id,item_id, sale_date));
+
+INSERT INTO fkdiva VALUES ( 1 , 1, date'2016-03-05', 10.2 );
+INSERT INTO fkdivb VALUES ( 1 , 1, 1, date'2016-03-05');
+INSERT INTO fkdivb VALUES ( 2 , 2, 1, date'2016-01-25');
 
 --- uk0 should be eliminated
 -- two table RI constraint join
@@ -347,5 +371,9 @@ drop table uk1;
 drop table uk2;
 drop table uk3;
 drop table t_013;
+drop table fksalta CASCADE;
+drop table fksaltb CASCADE;
+drop table fkdiva  CASCADE;
+drop table fkdivb  CASCADE;