You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafodion.apache.org by li...@apache.org on 2018/04/06 23:09:16 UTC
[5/6] trafodion git commit: take care of merge value
take care of merge value
Project: http://git-wip-us.apache.org/repos/asf/trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafodion/commit/fce62f89
Tree: http://git-wip-us.apache.org/repos/asf/trafodion/tree/fce62f89
Diff: http://git-wip-us.apache.org/repos/asf/trafodion/diff/fce62f89
Branch: refs/heads/master
Commit: fce62f89e5bd07764fb00e3b0503dfab1998a8e8
Parents: 007dcc6
Author: Liu Ming <ov...@sina.com>
Authored: Sun Mar 25 17:40:01 2018 +0000
Committer: Liu Ming <ov...@sina.com>
Committed: Sun Mar 25 17:40:01 2018 +0000
----------------------------------------------------------------------
core/sql/common/ComSmallDefs.h | 36 ++++++++-----
core/sql/optimizer/BindRelExpr.cpp | 3 +-
core/sql/optimizer/ItemExpr.cpp | 2 +
core/sql/regress/seabase/EXPECTED020 | 88 ++++++++++++++++++++++++++++---
core/sql/regress/seabase/TEST020 | 29 ++++++++--
5 files changed, 130 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafodion/blob/fce62f89/core/sql/common/ComSmallDefs.h
----------------------------------------------------------------------
diff --git a/core/sql/common/ComSmallDefs.h b/core/sql/common/ComSmallDefs.h
index 54d0cbf..29a0e0f 100644
--- a/core/sql/common/ComSmallDefs.h
+++ b/core/sql/common/ComSmallDefs.h
@@ -609,18 +609,22 @@ enum ComColumnClass { COM_UNKNOWN_CLASS
#define COM_MV_SYSTEM_ADDED_COLUMN_LIT "M "
#define COM_ALTERED_USER_COLUMN_LIT "C "
-enum ComColumnDefaultClass { COM_CURRENT_DEFAULT
- , COM_CURRENT_UT_DEFAULT
- , COM_NO_DEFAULT
- , COM_NULL_DEFAULT
- , COM_USER_DEFINED_DEFAULT
- , COM_USER_FUNCTION_DEFAULT
- , COM_UUID_DEFAULT
- , COM_IDENTITY_GENERATED_BY_DEFAULT
- , COM_IDENTITY_GENERATED_ALWAYS
- , COM_ALWAYS_COMPUTE_COMPUTED_COLUMN_DEFAULT
- , COM_ALWAYS_DEFAULT_COMPUTED_COLUMN_DEFAULT
- , COM_FUNCTION_DEFINED_DEFAULT
+/* This enum will be saved as integer in metadata tables
+ * If you change it, that will affect the existing values
+ * Make sure to add new values at the end
+ */
+enum ComColumnDefaultClass { COM_CURRENT_DEFAULT = 0
+ , COM_NO_DEFAULT = 1
+ , COM_NULL_DEFAULT = 2
+ , COM_USER_DEFINED_DEFAULT = 3
+ , COM_USER_FUNCTION_DEFAULT = 4
+ , COM_IDENTITY_GENERATED_BY_DEFAULT = 5
+ , COM_IDENTITY_GENERATED_ALWAYS =6
+ , COM_ALWAYS_COMPUTE_COMPUTED_COLUMN_DEFAULT = 7
+ , COM_ALWAYS_DEFAULT_COMPUTED_COLUMN_DEFAULT = 8
+ , COM_UUID_DEFAULT = 9
+ , COM_CURRENT_UT_DEFAULT = 10
+ , COM_FUNCTION_DEFINED_DEFAULT = 11
};
#define COM_CURRENT_DEFAULT_LIT "CD"
@@ -636,20 +640,24 @@ enum ComColumnDefaultClass { COM_CURRENT_DEFAULT
#define COM_ALWAYS_COMPUTE_COMPUTED_COLUMN_DEFAULT_LIT "AC"
#define COM_ALWAYS_DEFAULT_COMPUTED_COLUMN_DEFAULT_LIT "AD"
+/* This enum will be saved as integer in metadata tables
+ * If you change it, that will affect the existing values
+ * Make sure to add new values at the end
+ */
enum ComParamDefaultClass { COM_CURRENT_PARAM_DEFAULT = COM_CURRENT_DEFAULT
- , COM_CURRENT_UT_PARAM_DEFAULT = COM_CURRENT_UT_DEFAULT
, COM_NO_PARAM_DEFAULT
= COM_NO_DEFAULT
, COM_NULL_PARAM_DEFAULT = COM_NULL_DEFAULT
, COM_USER_DEFINED_PARAM_DEFAULT = COM_USER_DEFINED_DEFAULT
, COM_USER_FUNCTION_PARAM_DEFAULT = COM_USER_FUNCTION_DEFAULT
- , COM_UUID_PARAM_DEAULT = COM_UUID_DEFAULT
// IDENTITY GENERATED BY DEFAULT not applicable
// IDENTITY GENERATED ALWAYS not applicable
, COM_ALWAYS_COMPUTE_COMPUTED_PARAM_DEFAULT // for future internal use only
= COM_ALWAYS_COMPUTE_COMPUTED_COLUMN_DEFAULT
, COM_ALWAYS_DEFAULT_COMPUTED_PARAM_DEFAULT // for future internal use only
= COM_ALWAYS_DEFAULT_COMPUTED_COLUMN_DEFAULT
+ , COM_UUID_PARAM_DEAULT = COM_UUID_DEFAULT
+ , COM_CURRENT_UT_PARAM_DEFAULT = COM_CURRENT_UT_DEFAULT
, COM_FUNCTION_DEFINED_PARAM_DEFAULT
= COM_FUNCTION_DEFINED_DEFAULT
};
http://git-wip-us.apache.org/repos/asf/trafodion/blob/fce62f89/core/sql/optimizer/BindRelExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/BindRelExpr.cpp b/core/sql/optimizer/BindRelExpr.cpp
index eb5bbe0..89908b2 100644
--- a/core/sql/optimizer/BindRelExpr.cpp
+++ b/core/sql/optimizer/BindRelExpr.cpp
@@ -10425,7 +10425,8 @@ RelExpr *Insert::bindNode(BindWA *bindWA)
// column. COM_CURRENT_DEFAULT is only used for Datetime
// columns.
//
- if (nacol->getDefaultClass() == COM_CURRENT_DEFAULT) {
+ if (nacol->getDefaultClass() == COM_CURRENT_DEFAULT || nacol->getDefaultClass() == COM_CURRENT_UT_DEFAULT
+ || nacol->getDefaultClass() == COM_UUID_DEFAULT) {
castType = nacol->getType()->newCopy(bindWA->wHeap());
omittedCurrentDefaultClassCols = TRUE;
omittedDefaultCols = TRUE;
http://git-wip-us.apache.org/repos/asf/trafodion/blob/fce62f89/core/sql/optimizer/ItemExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/ItemExpr.cpp b/core/sql/optimizer/ItemExpr.cpp
index 744a0a5..324a0bd 100644
--- a/core/sql/optimizer/ItemExpr.cpp
+++ b/core/sql/optimizer/ItemExpr.cpp
@@ -875,6 +875,7 @@ NABoolean ItemExpr::doesExprEvaluateToConstant(NABoolean strict,
case ITM_CURRENT_USER:
case ITM_SESSION_USER:
case ITM_CURRENT_TIMESTAMP:
+ case ITM_UNIX_TIMESTAMP:
case ITM_GET_TRIGGERS_STATUS:
case ITM_UNIQUE_EXECUTE_ID:
case ITM_CURR_TRANSID:
@@ -967,6 +968,7 @@ NABoolean ItemExpr::referencesAHostVar() const
case ITM_CURRENT_USER:
case ITM_SESSION_USER:
case ITM_CURRENT_TIMESTAMP:
+ case ITM_UNIX_TIMESTAMP:
case ITM_GET_TRIGGERS_STATUS:
case ITM_UNIQUE_EXECUTE_ID:
case ITM_CURR_TRANSID:
http://git-wip-us.apache.org/repos/asf/trafodion/blob/fce62f89/core/sql/regress/seabase/EXPECTED020
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/EXPECTED020 b/core/sql/regress/seabase/EXPECTED020
index 32c151d..3c1104b 100644
--- a/core/sql/regress/seabase/EXPECTED020
+++ b/core/sql/regress/seabase/EXPECTED020
@@ -3947,31 +3947,103 @@ AAAA ? 2
>>
>>obey TEST020(trafodion_2335);
>>--create seqence test020_seq;
+>>cqd traf_upsert_mode 'merge';
+
+--- SQL operation complete.
+>>cqd traf_aligned_row_format 'off' ;
+
+--- SQL operation complete.
>>create table test020t45(a largeint not null default unix_timestamp(),
+> b char(36) not null default uuid(),
+> c varchar(10) default to_char(sysdate,'YYYYMMDD'),
+> --support sequence as default in next check-in
+> --d int not null default testi020_seq.nextval,
-+> e int );
++> e int not null,
++> f int, primary key(e));
--- SQL operation complete.
->>insert into test020t45(e) values(1),(2),(3);
+>>-- check if the timestamp is inserted with the recent timestamp
+>>insert into test020t45(e,f) values(1,1),(2,2),(3,3);
--- 3 row(s) inserted.
->>upsert into test020t45(e) values(4),(5);
+>>select sleep(1) from dual;
---- 2 row(s) inserted.
->>upsert using load into test020t45(e) values (6);
+(EXPR)
+--------------------
+
+ 1
+
+--- 1 row(s) selected.
+>>upsert into test020t45(e,f) values(1,4);
--- 1 row(s) inserted.
->>select count(*) from test020t45 where c = to_char(sysdate,'YYYYMMDD');
+>>select count(distinct(a)),count(distinct(b)),count(distinct(c)) from test020t45 ;
-(EXPR)
+(EXPR) (EXPR) (EXPR)
+-------------------- -------------------- --------------------
+
+ 1 3 1
+
+--- 1 row(s) selected.
+>>
+>>cqd traf_upsert_mode 'replace';
+
+--- SQL operation complete.
+>>delete from test020t45;
+
+--- 3 row(s) deleted.
+>>insert into test020t45(e,f) values(1,1),(2,2),(3,3);
+
+--- 3 row(s) inserted.
+>>select sleep(1) from dual;
+
+(EXPR)
--------------------
- 6
+ 1
--- 1 row(s) selected.
+>>upsert into test020t45(e,f) values(1,4);
+
+--- 1 row(s) inserted.
+>>select count(distinct(a)),count(distinct(b)),count(distinct(c)) from test020t45 ;
+
+(EXPR) (EXPR) (EXPR)
+-------------------- -------------------- --------------------
+
+ 2 3 1
+
+--- 1 row(s) selected.
+>>
+>>cqd traf_upsert_mode 'optimal';
+
+--- SQL operation complete.
+>>delete from test020t45;
+
+--- 3 row(s) deleted.
+>>insert into test020t45(e,f) values(1,1),(2,2),(3,3);
+
+--- 3 row(s) inserted.
+>>select sleep(1) from dual;
+
+(EXPR)
+--------------------
+
+ 1
+
+--- 1 row(s) selected.
+>>upsert into test020t45(e,f) values(1,4);
+
+--- 1 row(s) inserted.
+>>select count(distinct(a)),count(distinct(b)),count(distinct(c)) from test020t45 ;
+
+(EXPR) (EXPR) (EXPR)
+-------------------- -------------------- --------------------
+
+ 1 3 1
+
+--- 1 row(s) selected.
+>>
>>--negative tests
>>--the function is not variable-free, so should fail
>>create table test020t45(a largeint not null default unix_timestamp(),
http://git-wip-us.apache.org/repos/asf/trafodion/blob/fce62f89/core/sql/regress/seabase/TEST020
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/TEST020 b/core/sql/regress/seabase/TEST020
index deb6583..47b6aec 100755
--- a/core/sql/regress/seabase/TEST020
+++ b/core/sql/regress/seabase/TEST020
@@ -933,16 +933,35 @@ select * from test020t44;
?section trafodion_2335
--create seqence test020_seq;
+cqd traf_upsert_mode 'merge';
+cqd traf_aligned_row_format 'off' ;
create table test020t45(a largeint not null default unix_timestamp(),
b char(36) not null default uuid(),
c varchar(10) default to_char(sysdate,'YYYYMMDD'),
--support sequence as default in next check-in
--d int not null default testi020_seq.nextval,
- e int );
-insert into test020t45(e) values(1),(2),(3);
-upsert into test020t45(e) values(4),(5);
-upsert using load into test020t45(e) values (6);
-select count(*) from test020t45 where c = to_char(sysdate,'YYYYMMDD');
+ e int not null,
+ f int, primary key(e));
+-- check if the timestamp is inserted with the recent timestamp
+insert into test020t45(e,f) values(1,1),(2,2),(3,3);
+select sleep(1) from dual;
+upsert into test020t45(e,f) values(1,4);
+select count(distinct(a)),count(distinct(b)),count(distinct(c)) from test020t45 ;
+
+cqd traf_upsert_mode 'replace';
+delete from test020t45;
+insert into test020t45(e,f) values(1,1),(2,2),(3,3);
+select sleep(1) from dual;
+upsert into test020t45(e,f) values(1,4);
+select count(distinct(a)),count(distinct(b)),count(distinct(c)) from test020t45 ;
+
+cqd traf_upsert_mode 'optimal';
+delete from test020t45;
+insert into test020t45(e,f) values(1,1),(2,2),(3,3);
+select sleep(1) from dual;
+upsert into test020t45(e,f) values(1,4);
+select count(distinct(a)),count(distinct(b)),count(distinct(c)) from test020t45 ;
+
--negative tests
--the function is not variable-free, so should fail
create table test020t45(a largeint not null default unix_timestamp(),