You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafodion.apache.org by an...@apache.org on 2018/04/05 00:09:59 UTC
[3/4] trafodion git commit: various fixes
various fixes
-- JIRA 2980 support for INSTR function.
INSTR(source_string, pattern, startPos, occurrence)
Search for pattern in source_string.
Start at startPos'th character. Optional, default 1
Return occurrence'th occurrence. Optional, default 1
(exp/exp_function.cpp/h, exp/ExpPCodeClauseGen.cpp,
generator/GenItemFunc.cpp, optimizer/BindItemExpr.cpp, ItemExpr.cpp,
optimizer/ItemFunc.h, SynthType.cpp, parser/sqlparser.y)
-- hivemd returns precision, scale, display_datatype
(comexe/ComTdbExeUtil.h, common/BaseTypes.cpp,NAType.cpp/h,
executor/ExExeUtilGet.cpp, ExExeUtil.h)
-- hive decimal type is treated as sql NUMERIC for performance.
(common/NAType.cpp)
-- hive select from hivemd with prepare and multiple executes work
(executor/ExExeUtilGet.cpp)
-- fix for crash in sql buffer pool when allocating large size rows.
(executor/sql_buffer.cpp)
-- SIGN(op) now returns error if op is not numeric
(BindItemExpr.cpp)
-- strings of length zero are no longer cached. Caching them causes problem
during backpatching.
(optimizer/ItemCache.cpp)
--- compile time predicates on constants were not being created correctly
in some cases. That has been fixed.
(ValueDesc.cpp)
-- trim now supported on scaled numeric, float and bignum datatypes
(BindItemExpr.cpp)
-- CASE is now supported on scaled numerics, float, bignum
(BindItemExpr.cpp)
-- char_length is now supported on numerics
(ItemFunc.h, BindItemExpr.cpp)
-- DAYOFMONTH now allowed only on datetime datatypes
(common/OperTypeEnum.h, sqlparser.y, BindItemExpr.cpp, ItemExpr.cpp)
-- TO_TIME now allowed only on 'datetime with time' or character datatypes.
(BindItemExpr.cpp, bin/SqlciErrors.txt)
-- updated expected file for compGeneral/test042
Project: http://git-wip-us.apache.org/repos/asf/trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafodion/commit/43984c46
Tree: http://git-wip-us.apache.org/repos/asf/trafodion/tree/43984c46
Diff: http://git-wip-us.apache.org/repos/asf/trafodion/diff/43984c46
Branch: refs/heads/master
Commit: 43984c46cc9ea2cfc0e816080e93e0dc7e61369a
Parents: 659e8ec
Author: Anoop Sharma <an...@esgyn.com>
Authored: Mon Apr 2 16:40:16 2018 +0000
Committer: Anoop Sharma <an...@esgyn.com>
Committed: Mon Apr 2 16:40:16 2018 +0000
----------------------------------------------------------------------
core/sql/bin/SqlciErrors.txt | 2 +-
core/sql/comexe/ComTdbExeUtil.h | 32 +-
core/sql/common/BaseTypes.cpp | 3 +-
core/sql/common/NAType.cpp | 12 +-
core/sql/common/NAType.h | 3 +-
core/sql/common/OperTypeEnum.h | 1 +
core/sql/executor/ExExeUtil.h | 12 +-
core/sql/executor/ExExeUtilGet.cpp | 121 +++--
core/sql/executor/sql_buffer.cpp | 3 +-
core/sql/exp/ExpPCodeClauseGen.cpp | 4 +
core/sql/exp/exp_function.cpp | 249 +++++++---
core/sql/exp/exp_function.h | 30 +-
core/sql/generator/GenItemFunc.cpp | 6 +-
core/sql/optimizer/BindItemExpr.cpp | 300 +++++++++---
core/sql/optimizer/ItemCache.cpp | 8 +
core/sql/optimizer/ItemExpr.cpp | 7 +-
core/sql/optimizer/ItemFunc.h | 12 +-
core/sql/optimizer/SynthType.cpp | 41 +-
core/sql/optimizer/ValueDesc.cpp | 57 ++-
core/sql/parser/sqlparser.y | 39 +-
core/sql/regress/compGeneral/EXPECTED006.SB | 10 +-
core/sql/regress/compGeneral/EXPECTED042 | 139 +++---
core/sql/regress/core/EXPECTED038.LINUX | 26 +-
core/sql/regress/executor/EXPECTED012 | 598 ++++++++++++++++++++++-
core/sql/regress/executor/TEST012 | 103 +++-
core/sql/regress/hive/EXPECTED005 | 112 ++---
core/sql/regress/seabase/EXPECTED002 | 288 ++++++-----
core/sql/regress/seabase/EXPECTED030 | 14 +
core/sql/regress/seabase/EXPECTED031 | 44 +-
core/sql/regress/seabase/TEST002 | 41 +-
core/sql/regress/seabase/TEST030 | 4 +
core/sql/regress/seabase/TEST031 | 10 +
32 files changed, 1758 insertions(+), 573 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafodion/blob/43984c46/core/sql/bin/SqlciErrors.txt
----------------------------------------------------------------------
diff --git a/core/sql/bin/SqlciErrors.txt b/core/sql/bin/SqlciErrors.txt
index e66e170..981dabc 100644
--- a/core/sql/bin/SqlciErrors.txt
+++ b/core/sql/bin/SqlciErrors.txt
@@ -1047,7 +1047,7 @@ $1~String1 --------------------------------
3412 ZZZZZ 99999 BEGINNER MAJOR DBADMIN IDENTITY column $0~ColumnName must be the primary key or must have a unique index on it.
3413 ZZZZZ 99999 BEGINNER MAJOR DBADMIN The NOT NULL constraint on IDENTITY column $0~ColumnName must be NOT DROPPABLE.
3414 ZZZZZ 99999 BEGINNER MAJOR DBADMIN For an IDENTITY column $0~ColumnName, the tuple list cannot have mixed user specified and DEFAULT values. Specify values for all or specify DEFAULT for all.
-3415 42000 99999 BEGINNER MAJOR DBADMIN The first operand of function $0~string0 is not valid.
+3415 42000 99999 BEGINNER MAJOR DBADMIN The first operand of function $0~string0 is not valid.$1~String1
3416 42000 99999 BEGINNER MAJOR DBADMIN The last operand of function $0~string0 must not be NULL.
3417 ZZZZZ 99999 BEGINNER MINOR DBADMIN Invalid DISK POOL $0~Int0 as the maximum number of pools allowed is $1~Int1.
3418 ZZZZZ 99999 BEGINNER MAJOR DBADMIN Local Number of Partitions clause is not allowed with DISK POOL clause.
http://git-wip-us.apache.org/repos/asf/trafodion/blob/43984c46/core/sql/comexe/ComTdbExeUtil.h
----------------------------------------------------------------------
diff --git a/core/sql/comexe/ComTdbExeUtil.h b/core/sql/comexe/ComTdbExeUtil.h
index fba4d7b..9024afe 100644
--- a/core/sql/comexe/ComTdbExeUtil.h
+++ b/core/sql/comexe/ComTdbExeUtil.h
@@ -3187,21 +3187,22 @@ static const ComTdbVirtTableColumnInfo hiveMDColumnsColInfo[] =
{ "COLUMN_NAME", 3, COM_USER_COLUMN, REC_BYTE_F_ASCII, 256, FALSE, SQLCHARSETCODE_UTF8, 0, 0, 0, 0, 0, 0, 0, COM_NO_DEFAULT, "" ,NULL,NULL,COM_UNKNOWN_DIRECTION_LIT, 0},
{ "SQL_DATA_TYPE", 4, COM_USER_COLUMN, REC_BYTE_F_ASCII, 32, FALSE, SQLCHARSETCODE_ISO88591, 0, 0, 0, 0, 0, 0, 0, COM_NO_DEFAULT, "" ,NULL,NULL,COM_UNKNOWN_DIRECTION_LIT, 0},
{ "FS_DATA_TYPE", 5, COM_USER_COLUMN, REC_BIN32_SIGNED, 4, FALSE, SQLCHARSETCODE_UNKNOWN, 0, 0, 0, 0, 0, 0, 0, COM_NO_DEFAULT, "" ,NULL,NULL,COM_UNKNOWN_DIRECTION_LIT, 0},
- { "HIVE_DATA_TYPE", 6, COM_USER_COLUMN, REC_BYTE_F_ASCII, 32, FALSE, SQLCHARSETCODE_ISO88591, 0, 0, 0, 0, 0, 0, 0, COM_NO_DEFAULT, "" ,NULL,NULL,COM_UNKNOWN_DIRECTION_LIT, 0},
- { "COLUMN_SIZE", 7, COM_USER_COLUMN, REC_BIN32_SIGNED, 4, FALSE, SQLCHARSETCODE_UNKNOWN, 0, 0, 0, 0, 0, 0, 0, COM_NO_DEFAULT, "" ,NULL,NULL,COM_UNKNOWN_DIRECTION_LIT, 0},
- { "CHARACTER_SET", 8, COM_USER_COLUMN, REC_BYTE_F_ASCII, 40, FALSE, SQLCHARSETCODE_ISO88591, 0, 0, 0, 0, 0, 0, 0, COM_NO_DEFAULT, "" ,NULL,NULL,COM_UNKNOWN_DIRECTION_LIT, 0},
- { "COLUMN_PRECISION", 9, COM_USER_COLUMN, REC_BIN32_SIGNED, 4, FALSE, SQLCHARSETCODE_UNKNOWN, 0, 0, 0, 0, 0, 0, 0, COM_NO_DEFAULT, "" ,NULL,NULL,COM_UNKNOWN_DIRECTION_LIT, 0},
- { "COLUMN_SCALE", 10, COM_USER_COLUMN, REC_BIN32_SIGNED, 4, FALSE, SQLCHARSETCODE_UNKNOWN, 0, 0, 0, 0, 0, 0, 0, COM_NO_DEFAULT, "" ,NULL,NULL,COM_UNKNOWN_DIRECTION_LIT, 0},
- { "DT_CODE", 11, COM_USER_COLUMN, REC_BIN32_SIGNED, 4, FALSE, SQLCHARSETCODE_UNKNOWN, 0, 0, 0, 0, 0, 0, 0, COM_NO_DEFAULT, "" ,NULL,NULL,COM_UNKNOWN_DIRECTION_LIT, 0},
- { "NULLABLE", 12, COM_USER_COLUMN, REC_BIN32_SIGNED, 4, FALSE, SQLCHARSETCODE_UNKNOWN, 0, 0, 0, 0, 0, 0, 0, COM_NO_DEFAULT, "" ,NULL,NULL,COM_UNKNOWN_DIRECTION_LIT, 0},
- { "COLUMN_NUMBER", 13, COM_USER_COLUMN, REC_BIN32_SIGNED, 4, FALSE, SQLCHARSETCODE_UNKNOWN, 0, 0, 0, 0, 0, 0, 0, COM_NO_DEFAULT, "" ,NULL,NULL,COM_UNKNOWN_DIRECTION_LIT, 0},
- { "PART_COL_NUMBER", 14, COM_USER_COLUMN, REC_BIN32_SIGNED, 4, FALSE, SQLCHARSETCODE_UNKNOWN, 0, 0, 0, 0, 0, 0, 0, COM_NO_DEFAULT, "" ,NULL,NULL,COM_UNKNOWN_DIRECTION_LIT, 0},
- { "BUCKET_COL_NUMBER", 15, COM_USER_COLUMN, REC_BIN32_SIGNED, 4, FALSE, SQLCHARSETCODE_UNKNOWN, 0, 0, 0, 0, 0, 0, 0, COM_NO_DEFAULT, "" ,NULL,NULL,COM_UNKNOWN_DIRECTION_LIT, 0},
- { "SORT_COL_NUMBER", 16, COM_USER_COLUMN, REC_BIN32_SIGNED, 4, FALSE, SQLCHARSETCODE_UNKNOWN, 0, 0, 0, 0, 0, 0, 0, COM_NO_DEFAULT, "" ,NULL,NULL,COM_UNKNOWN_DIRECTION_LIT, 0},
- { "DATETIME_QUALIFIER", 17, COM_USER_COLUMN, REC_BYTE_F_ASCII, 28, FALSE, SQLCHARSETCODE_ISO88591, 0, 0, 0, 0, 0, 0, 0, COM_NO_DEFAULT, "" ,NULL,NULL,COM_UNKNOWN_DIRECTION_LIT, 0},
- { "DATETIME_START_FIELD", 18, COM_USER_COLUMN, REC_BIN32_SIGNED, 4, FALSE, SQLCHARSETCODE_UNKNOWN, 0, 0, 0, 0, 0, 0, 0, COM_NO_DEFAULT, "" ,NULL,NULL,COM_UNKNOWN_DIRECTION_LIT, 0},
- { "DATETIME_END_FIELD", 19, COM_USER_COLUMN, REC_BIN32_SIGNED, 4, FALSE, SQLCHARSETCODE_UNKNOWN, 0, 0, 0, 0, 0, 0, 0, COM_NO_DEFAULT, "" ,NULL,NULL,COM_UNKNOWN_DIRECTION_LIT, 0},
- { "DEFAULT_VALUE", 20, COM_USER_COLUMN, REC_BYTE_F_ASCII, 240, FALSE, SQLCHARSETCODE_UTF8, 0, 0, 0, 0, 0, 0, 0, COM_NO_DEFAULT, "" ,NULL,NULL,COM_UNKNOWN_DIRECTION_LIT, 0},
+ { "DISPLAY_DATA_TYPE", 6, COM_USER_COLUMN, REC_BYTE_F_ASCII, 96, FALSE, SQLCHARSETCODE_ISO88591, 0, 0, 0, 0, 0, 0, 0, COM_NO_DEFAULT, "" ,NULL,NULL,COM_UNKNOWN_DIRECTION_LIT, 0},
+ { "HIVE_DATA_TYPE", 7, COM_USER_COLUMN, REC_BYTE_F_ASCII, 32, FALSE, SQLCHARSETCODE_ISO88591, 0, 0, 0, 0, 0, 0, 0, COM_NO_DEFAULT, "" ,NULL,NULL,COM_UNKNOWN_DIRECTION_LIT, 0},
+ { "COLUMN_SIZE", 8, COM_USER_COLUMN, REC_BIN32_SIGNED, 4, FALSE, SQLCHARSETCODE_UNKNOWN, 0, 0, 0, 0, 0, 0, 0, COM_NO_DEFAULT, "" ,NULL,NULL,COM_UNKNOWN_DIRECTION_LIT, 0},
+ { "CHARACTER_SET", 9, COM_USER_COLUMN, REC_BYTE_F_ASCII, 40, FALSE, SQLCHARSETCODE_ISO88591, 0, 0, 0, 0, 0, 0, 0, COM_NO_DEFAULT, "" ,NULL,NULL,COM_UNKNOWN_DIRECTION_LIT, 0},
+ { "COLUMN_PRECISION", 10, COM_USER_COLUMN, REC_BIN32_SIGNED, 4, FALSE, SQLCHARSETCODE_UNKNOWN, 0, 0, 0, 0, 0, 0, 0, COM_NO_DEFAULT, "" ,NULL,NULL,COM_UNKNOWN_DIRECTION_LIT, 0},
+ { "COLUMN_SCALE", 11, COM_USER_COLUMN, REC_BIN32_SIGNED, 4, FALSE, SQLCHARSETCODE_UNKNOWN, 0, 0, 0, 0, 0, 0, 0, COM_NO_DEFAULT, "" ,NULL,NULL,COM_UNKNOWN_DIRECTION_LIT, 0},
+ { "DT_CODE", 12, COM_USER_COLUMN, REC_BIN32_SIGNED, 4, FALSE, SQLCHARSETCODE_UNKNOWN, 0, 0, 0, 0, 0, 0, 0, COM_NO_DEFAULT, "" ,NULL,NULL,COM_UNKNOWN_DIRECTION_LIT, 0},
+ { "NULLABLE", 13, COM_USER_COLUMN, REC_BIN32_SIGNED, 4, FALSE, SQLCHARSETCODE_UNKNOWN, 0, 0, 0, 0, 0, 0, 0, COM_NO_DEFAULT, "" ,NULL,NULL,COM_UNKNOWN_DIRECTION_LIT, 0},
+ { "COLUMN_NUMBER", 14, COM_USER_COLUMN, REC_BIN32_SIGNED, 4, FALSE, SQLCHARSETCODE_UNKNOWN, 0, 0, 0, 0, 0, 0, 0, COM_NO_DEFAULT, "" ,NULL,NULL,COM_UNKNOWN_DIRECTION_LIT, 0},
+ { "PART_COL_NUMBER", 15, COM_USER_COLUMN, REC_BIN32_SIGNED, 4, FALSE, SQLCHARSETCODE_UNKNOWN, 0, 0, 0, 0, 0, 0, 0, COM_NO_DEFAULT, "" ,NULL,NULL,COM_UNKNOWN_DIRECTION_LIT, 0},
+ { "BUCKET_COL_NUMBER", 16, COM_USER_COLUMN, REC_BIN32_SIGNED, 4, FALSE, SQLCHARSETCODE_UNKNOWN, 0, 0, 0, 0, 0, 0, 0, COM_NO_DEFAULT, "" ,NULL,NULL,COM_UNKNOWN_DIRECTION_LIT, 0},
+ { "SORT_COL_NUMBER", 17, COM_USER_COLUMN, REC_BIN32_SIGNED, 4, FALSE, SQLCHARSETCODE_UNKNOWN, 0, 0, 0, 0, 0, 0, 0, COM_NO_DEFAULT, "" ,NULL,NULL,COM_UNKNOWN_DIRECTION_LIT, 0},
+ { "DATETIME_QUALIFIER", 18, COM_USER_COLUMN, REC_BYTE_F_ASCII, 28, FALSE, SQLCHARSETCODE_ISO88591, 0, 0, 0, 0, 0, 0, 0, COM_NO_DEFAULT, "" ,NULL,NULL,COM_UNKNOWN_DIRECTION_LIT, 0},
+ { "DATETIME_START_FIELD", 19, COM_USER_COLUMN, REC_BIN32_SIGNED, 4, FALSE, SQLCHARSETCODE_UNKNOWN, 0, 0, 0, 0, 0, 0, 0, COM_NO_DEFAULT, "" ,NULL,NULL,COM_UNKNOWN_DIRECTION_LIT, 0},
+ { "DATETIME_END_FIELD", 20, COM_USER_COLUMN, REC_BIN32_SIGNED, 4, FALSE, SQLCHARSETCODE_UNKNOWN, 0, 0, 0, 0, 0, 0, 0, COM_NO_DEFAULT, "" ,NULL,NULL,COM_UNKNOWN_DIRECTION_LIT, 0},
+ { "DEFAULT_VALUE", 21, COM_USER_COLUMN, REC_BYTE_F_ASCII, 240, FALSE, SQLCHARSETCODE_UTF8, 0, 0, 0, 0, 0, 0, 0, COM_NO_DEFAULT, "" ,NULL,NULL,COM_UNKNOWN_DIRECTION_LIT, 0},
};
struct HiveMDColumnsColInfoStruct
@@ -3212,6 +3213,7 @@ struct HiveMDColumnsColInfoStruct
char colName[256];
char sqlDatatype[32];
Lng32 fsDatatype;
+ char displayDatatype[96];
char hiveDatatype[32];
Lng32 colSize;
char charSet[40];
http://git-wip-us.apache.org/repos/asf/trafodion/blob/43984c46/core/sql/common/BaseTypes.cpp
----------------------------------------------------------------------
diff --git a/core/sql/common/BaseTypes.cpp b/core/sql/common/BaseTypes.cpp
index 0b22550..91ac01d 100644
--- a/core/sql/common/BaseTypes.cpp
+++ b/core/sql/common/BaseTypes.cpp
@@ -645,7 +645,8 @@ short convertTypeToText_basic(char * text, // OUTPUT
CharInfo::getCharSetName(charSet));
}
- if (addCollate && (collation_name != NULL))
+ if (addCollate && (collation_name != NULL) &&
+ (strcmp(collation_name, SQLCOLLATIONSTRING_UNKNOWN) != 0))
{
str_sprintf(&text[str_len(text)],
" COLLATE %s",
http://git-wip-us.apache.org/repos/asf/trafodion/blob/43984c46/core/sql/common/NAType.cpp
----------------------------------------------------------------------
diff --git a/core/sql/common/NAType.cpp b/core/sql/common/NAType.cpp
index 8ace6f7..0271b0c 100644
--- a/core/sql/common/NAType.cpp
+++ b/core/sql/common/NAType.cpp
@@ -777,7 +777,8 @@ short NAType::getMyTypeAsHiveText(NAString * outputStr/*out*/) const
}
short NAType::getMyTypeAsText(NAString * outputStr, // output
- NABoolean addNullability) const
+ NABoolean addNullability,
+ NABoolean addCollation) const
{
// get the right value for all these
Lng32 fs_datatype = getFSDatatype();
@@ -829,7 +830,8 @@ short NAType::getMyTypeAsText(NAString * outputStr, // output
isUpshifted = charType.isUpshifted();
isCaseinsensitive = charType.isCaseinsensitive();
characterSet = charType.getCharSet();
- collationSequence = charType.getCollation();
+ if (addCollation)
+ collationSequence = charType.getCollation();
if ( characterSet == CharInfo::UTF8 /* || (characterSet == CharInfo::SJIS */ )
{
// If byte length limit is EXACTLY (maxBytesPerChar * character limit), then use character limit
@@ -1063,6 +1065,8 @@ NAType* NAType::getNATypeForHive(const char* hiveType, NAMemory* heap)
if ( !strncmp(hiveType, "decimal", 7) )
{
+ const Int16 DisAmbiguate = 0;
+
Int32 i=0, pstart=-1, pend=-1, sstart=-1, send=-1, p=-1, s = -1;
Int32 hiveTypeLen = strlen(hiveType);
char pstr[MAX_NUM_LEN], sstr[MAX_NUM_LEN];
@@ -1112,7 +1116,7 @@ NAType* NAType::getNATypeForHive(const char* hiveType, NAMemory* heap)
if( (p>0) && (p <= MAX_PRECISION_ALLOWED) ) //have precision between 1 - 18
{
if( ( s >=0 ) && ( s<= p) ) //have valid scale
- return new (heap) SQLDecimal(heap, p, s, TRUE, TRUE);
+ return new (heap) SQLNumeric(heap, TRUE, p, s, DisAmbiguate, TRUE);
else
return NULL;
}
@@ -1127,7 +1131,7 @@ NAType* NAType::getNATypeForHive(const char* hiveType, NAMemory* heap)
else if( ( p == -1 ) && ( s == -1 ) )
{
// hive define decimal as decimal ( 10, 0 )
- return new (heap) SQLDecimal(heap, 10, 0, TRUE, TRUE);
+ return new (heap) SQLNumeric(heap, TRUE, 10, 0, DisAmbiguate, TRUE);
}
else
{
http://git-wip-us.apache.org/repos/asf/trafodion/blob/43984c46/core/sql/common/NAType.h
----------------------------------------------------------------------
diff --git a/core/sql/common/NAType.h b/core/sql/common/NAType.h
index c66a121..7b719a9 100644
--- a/core/sql/common/NAType.h
+++ b/core/sql/common/NAType.h
@@ -562,7 +562,8 @@ public:
short displayCaseSpecific = 0);
short getMyTypeAsText(NAString * outputStr,
- NABoolean addNullability = TRUE) const; // output
+ NABoolean addNullability = TRUE,
+ NABoolean addCollation = TRUE) const; // output
short getMyTypeAsHiveText(NAString * outputStr) const; // output
http://git-wip-us.apache.org/repos/asf/trafodion/blob/43984c46/core/sql/common/OperTypeEnum.h
----------------------------------------------------------------------
diff --git a/core/sql/common/OperTypeEnum.h b/core/sql/common/OperTypeEnum.h
index ee84c80..1d41ebe 100644
--- a/core/sql/common/OperTypeEnum.h
+++ b/core/sql/common/OperTypeEnum.h
@@ -587,6 +587,7 @@ enum OperatorTypeEnum {
ITM_DAYOFYEAR = 2311,
ITM_FIRSTDAYOFYEAR = 2312,
ITM_INTERNALTIMESTAMP = 2313, // ++ Triggers,
+ ITM_DAYOFMONTH = 2314,
ITM_DATE_TRUNC_YEAR = 2315,
ITM_DATE_TRUNC_MONTH = 2316,
http://git-wip-us.apache.org/repos/asf/trafodion/blob/43984c46/core/sql/executor/ExExeUtil.h
----------------------------------------------------------------------
diff --git a/core/sql/executor/ExExeUtil.h b/core/sql/executor/ExExeUtil.h
index 85173c8..d169653 100644
--- a/core/sql/executor/ExExeUtil.h
+++ b/core/sql/executor/ExExeUtil.h
@@ -3346,9 +3346,15 @@ virtual ex_tcb_private_state *
Lng32 &pstateLength); // out, length of one element
protected:
- Lng32 getFSTypeFromHiveColType(const char* hiveType);
- Lng32 getLengthFromHiveColType(const char* hiveType);
-
+ Lng32 getTypeAttrsFromHiveColType(const char* hiveType,
+ NABoolean isORC,
+ Lng32 &fstype,
+ Lng32 &length,
+ Lng32 &precision,
+ Lng32 &scale,
+ char *sqlType,
+ char *displayType,
+ char *charset);
enum Step
{
INITIAL_,
http://git-wip-us.apache.org/repos/asf/trafodion/blob/43984c46/core/sql/executor/ExExeUtilGet.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/ExExeUtilGet.cpp b/core/sql/executor/ExExeUtilGet.cpp
index ff40c40..4428998 100644
--- a/core/sql/executor/ExExeUtilGet.cpp
+++ b/core/sql/executor/ExExeUtilGet.cpp
@@ -5460,22 +5460,58 @@ ExExeUtilHiveMDaccessTcb::~ExExeUtilHiveMDaccessTcb()
}
// should move this method to common dir.
-Lng32 ExExeUtilHiveMDaccessTcb::getFSTypeFromHiveColType(const char* hiveType)
+Lng32 ExExeUtilHiveMDaccessTcb::getTypeAttrsFromHiveColType(const char* hiveType,
+ NABoolean isORC,
+ Lng32 &fstype,
+ Lng32 &length,
+ Lng32 &precision,
+ Lng32 &scale,
+ char *sqlType,
+ char *displayType,
+ char *charset)
{
- Lng32 fstype = -1;
- NAType * nat = NAType::getNATypeForHive(hiveType, getHeap());
- fstype = nat->getFSDatatype();
- delete nat;
- return fstype;
-}
+ short rc = 0;
-Lng32 ExExeUtilHiveMDaccessTcb::getLengthFromHiveColType(const char* hiveType)
-{
- Lng32 len = -1;
+ fstype = -1;
+ length = -1;
+ precision = -1;
+ scale = -1;
NAType * nat = NAType::getNATypeForHive(hiveType, getHeap());
- len = nat->getNominalSize();
- delete nat;
- return len;
+ if (nat)
+ {
+ fstype = nat->getFSDatatype();
+ length = nat->getNominalSize();
+ precision = nat->getPrecision();
+ scale = nat->getScale();
+
+ const char * sdtStr =
+ Descriptor::ansiTypeStrFromFSType(fstype);
+ strcpy(sqlType, sdtStr);
+
+ NAString displayTypeNAS;
+ rc = nat->getMyTypeAsText(&displayTypeNAS, FALSE, FALSE);
+ if (rc)
+ {
+ delete nat;
+ return -1;
+ }
+
+ strcpy(displayType, displayTypeNAS.data());
+
+ charset[0] = 0;
+ CharInfo::CharSet charSetEnum = nat->getCharSet();
+ if (charSetEnum != CharInfo::UnknownCharSet)
+ {
+ const char * charSetName = CharInfo::getCharSetName(charSetEnum);
+ if (charSetName)
+ strcpy(charset, charSetName);
+ }
+
+ delete nat;
+ return 0;
+ }
+
+ return -1;
}
short ExExeUtilHiveMDaccessTcb::work()
@@ -5537,6 +5573,8 @@ short ExExeUtilHiveMDaccessTcb::work()
case SETUP_SCHEMAS_:
{
+ schNames_.clear();
+
if ((hiveMDtdb().mdType_ == ComTdbExeUtilHiveMDaccess::SCHEMAS_) ||
(! hiveMDtdb().getSchema()))
{
@@ -5795,40 +5833,51 @@ short ExExeUtilHiveMDaccessTcb::work()
str_cpy(infoCol->colName,
(hcd ? hcd->name_ : hpd->name_), 256, ' ');
- infoCol->fsDatatype =
- getFSTypeFromHiveColType(hcd ? hcd->type_ : hpd->type_);
-
- if (infoCol->fsDatatype < 0)
+ Lng32 fstype = -1;
+ Lng32 length = -1;
+ Lng32 precision = -1;
+ Lng32 scale = -1;
+ char sqlType[50];
+ char displayType[100];
+ char charset[50];
+ retcode =
+ getTypeAttrsFromHiveColType(hcd ? hcd->type_ : hpd->type_,
+ htd->getSDs()->isOrcFile(),
+ fstype, length, precision, scale,
+ sqlType, displayType, charset);
+
+ if (retcode < 0)
{
+ // add a warning and continue.
char strP[300];
- sprintf(strP, "Datatype %s is not supported.",
- (hcd ? hcd->type_ : hpd->type_));
- *diags << DgSqlCode(-CLI_GET_METADATA_INFO_ERROR)
+ sprintf(strP, "Datatype %s for column '%s' in table %s.%s.%s is not supported. This table will be ignored.",
+ (hcd ? hcd->type_ : hpd->type_),
+ (hcd ? hcd->name_ : hpd->name_),
+ hiveCat_, hiveSch_, htd->tblName_);
+ *diags << DgSqlCode(CLI_GET_METADATA_INFO_ERROR)
<< DgString0(strP);
-
- step_ = HANDLE_ERROR_;
- break;
+
+ step_ = ADVANCE_ROW_;
+ break;
}
- const char * sdtStr =
- Descriptor::ansiTypeStrFromFSType(infoCol->fsDatatype);
- str_cpy(infoCol->sqlDatatype, sdtStr, 32, ' ');
+ infoCol->fsDatatype = fstype;
+
+ str_cpy(infoCol->sqlDatatype, sqlType, 32, ' ');
+
+ str_cpy(infoCol->displayDatatype, displayType, 96, ' ');
str_cpy(infoCol->hiveDatatype, (hcd ? hcd->type_ : hpd->type_),
32, ' ');
- infoCol->colSize =
- getLengthFromHiveColType(hcd ? hcd->type_ : hpd->type_);
- infoCol->colScale = 0;
+ infoCol->colSize = length;
+ infoCol->colPrecision = precision;
+ infoCol->colScale = scale;
- // only iso charset
- if ((infoCol->fsDatatype == REC_BYTE_F_ASCII) ||
- (infoCol->fsDatatype == REC_BYTE_V_ASCII))
- str_cpy(infoCol->charSet, "ISO88591", 40, ' ');
- else
- str_pad(infoCol->charSet, 40, ' ');
+ str_pad(infoCol->charSet, 40, ' ');
+ if (strlen(charset) > 0)
+ str_cpy(infoCol->charSet, charset, 40, ' ');
- infoCol->colPrecision = 0;
infoCol->nullable = 1;
infoCol->dtCode = 0;
http://git-wip-us.apache.org/repos/asf/trafodion/blob/43984c46/core/sql/executor/sql_buffer.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/sql_buffer.cpp b/core/sql/executor/sql_buffer.cpp
index 14d1f46..911ce11 100644
--- a/core/sql/executor/sql_buffer.cpp
+++ b/core/sql/executor/sql_buffer.cpp
@@ -2697,7 +2697,8 @@ sql_buffer_pool::moveIn(atp_struct *atp1,
if (get_free_tuple(atp2->getTupp(tuppIndex), tupDataSize)) {
if(addBufferIfNeeded) {
- addBuffer(bufferSize);
+ ULng32 neededSize = SqlBufferNeededSize(1, bufferSize, bufType_);
+ addBuffer(neededSize);
if (get_free_tuple(atp2->getTupp(tuppIndex), tupDataSize)) {
ex_assert(0, "sql_buffer_pool::moveIn() No more space for tuples");
}
http://git-wip-us.apache.org/repos/asf/trafodion/blob/43984c46/core/sql/exp/ExpPCodeClauseGen.cpp
----------------------------------------------------------------------
diff --git a/core/sql/exp/ExpPCodeClauseGen.cpp b/core/sql/exp/ExpPCodeClauseGen.cpp
index 92e7fb2..958e210 100644
--- a/core/sql/exp/ExpPCodeClauseGen.cpp
+++ b/core/sql/exp/ExpPCodeClauseGen.cpp
@@ -4553,6 +4553,10 @@ ex_function_position::pCodeGenerate(Space *space, UInt32 f)
if(cs != CharInfo::ISO88591)
return ex_clause::pCodeGenerate(space, f);
+ // pcode currently doesn't handle non-default start position or n'th occurrence
+ if (getNumOperands() > 3)
+ return ex_clause::pCodeGenerate(space, f);
+
// We don't support system collations (e.g. czech). Note, some clauses have
// the collation defined in the clause. Others don't - in which case the
// info needs to be derived from the operand.
http://git-wip-us.apache.org/repos/asf/trafodion/blob/43984c46/core/sql/exp/exp_function.cpp
----------------------------------------------------------------------
diff --git a/core/sql/exp/exp_function.cpp b/core/sql/exp/exp_function.cpp
index 67ca194..75ffcf9 100644
--- a/core/sql/exp/exp_function.cpp
+++ b/core/sql/exp/exp_function.cpp
@@ -290,14 +290,19 @@ ExFunctionInetNtoa::ExFunctionInetNtoa(OperatorTypeEnum oper_type,
};
ExFunctionAESEncrypt::ExFunctionAESEncrypt(OperatorTypeEnum oper_type,
- Attributes ** attr, Space * space, int args_num, Int32 aes_mode )
- : ex_function_clause(oper_type, args_num + 1, attr, space), args_num(args_num), aes_mode(aes_mode)
+ Attributes ** attr, Space * space,
+ int in_args_num,
+ Int32 aes_mode )
+ : ex_function_clause(oper_type, in_args_num + 1, attr, space),
+ args_num(in_args_num), aes_mode(aes_mode)
{
};
ExFunctionAESDecrypt::ExFunctionAESDecrypt(OperatorTypeEnum oper_type,
- Attributes ** attr, Space * space, int args_num, Int32 aes_mode)
- : ex_function_clause(oper_type, args_num + 1, attr, space), args_num(args_num), aes_mode(aes_mode)
+ Attributes ** attr, Space * space,
+ int in_args_num, Int32 aes_mode)
+ : ex_function_clause(oper_type, in_args_num + 1, attr, space),
+ args_num(in_args_num), aes_mode(aes_mode)
{
};
@@ -347,18 +352,21 @@ ex_function_oct_length::ex_function_oct_length(OperatorTypeEnum oper_type,
};
ex_function_position::ex_function_position(OperatorTypeEnum oper_type,
- Attributes ** attr, Space * space)
-: ex_function_clause(oper_type, 3, attr, space)
+ Attributes ** attr, Space * space,
+ int in_args_num)
+ : ex_function_clause(oper_type, in_args_num, attr, space),
+ args_num(in_args_num)
{
};
ex_function_position_doublebyte::ex_function_position_doublebyte
(
- OperatorTypeEnum oper_type,
- Attributes ** attr, Space * space
+ OperatorTypeEnum oper_type,
+ Attributes ** attr, Space * space, int in_args_num
)
-: ex_function_clause(oper_type, 3, attr, space)
+ : ex_function_clause(oper_type, in_args_num, attr, space),
+ args_num(in_args_num)
{
};
@@ -2167,6 +2175,7 @@ Lng32 ex_function_position::findPosition
if (searchLen <= 0)
return 0;
+
Int32 position = 1;
Int32 collPosition = 1;
Int32 char_count = 1;
@@ -2181,14 +2190,14 @@ Lng32 ex_function_position::findPosition
}
else
{
- number_bytes = Attributes::getFirstCharLength
- (&sourceStr[position-1], sourceLen - position + 1, cs);
-
- if(number_bytes <= 0)
- return (Lng32)-1;
-
- ++char_count;
- position += number_bytes;
+ number_bytes = Attributes::getFirstCharLength
+ (&sourceStr[position-1], sourceLen - position + 1, cs);
+
+ if(number_bytes <= 0)
+ return (Lng32)-1;
+
+ ++char_count;
+ position += number_bytes;
}
else
{
@@ -2198,17 +2207,16 @@ Lng32 ex_function_position::findPosition
}
else
{
- if(charOffsetFlag)
- return char_count;
- else
- return position;
+ if(charOffsetFlag)
+ return char_count;
+ else
+ return position;
}
}
}
return 0;
}
-
ex_expr::exp_return_type
ex_function_char_length_doublebyte::eval(char *op_data[],
CollHeap*,
@@ -2224,12 +2232,51 @@ ex_function_char_length_doublebyte::eval(char *op_data[],
return ex_expr::EXPR_OK;
};
+Lng32 ex_function_position::errorChecks(Lng32 startPos, Lng32 occurrence,
+ CollHeap* heap, ComDiagsArea** diagsArea)
+{
+ // startPos is 1 based. Cannot be <= 0
+ if (startPos < 0)
+ {
+ ExRaiseSqlError(heap, diagsArea, (ExeErrorCode)1572);
+ *(*diagsArea) << DgString0("START POSITION") << DgString1("INSTR function");
+ return -1;
+ }
+
+ if (startPos == 0)
+ {
+ ExRaiseSqlError(heap, diagsArea, (ExeErrorCode)1571);
+ *(*diagsArea) << DgString0("START POSITION") << DgString1("INSTR function");
+ return -1;
+ }
+
+ if (occurrence < 0)
+ {
+ ExRaiseSqlError(heap, diagsArea, (ExeErrorCode)1572);
+ *(*diagsArea) << DgString0("OCCURRENCE") << DgString1("INSTR function");
+
+ return -1;
+ }
+
+ if (occurrence == 0)
+ {
+ ExRaiseSqlError(heap, diagsArea, (ExeErrorCode)1571);
+ *(*diagsArea) << DgString0("OCCURRENCE") << DgString1("INSTR function");
+
+ return -1;
+ }
+
+ return 0;
+}
+
+
ex_expr::exp_return_type ex_function_position::eval(char *op_data[],
CollHeap* heap,
ComDiagsArea** diagsArea)
{
CharInfo::CharSet cs = ((SimpleType *)getOperand(1))->getCharSet();
+ // return value is 1 based. First character position is 1.
// search for operand 1
Lng32 len1 = getOperand(1)->getLength(op_data[-MAX_OPERANDS+1]);
@@ -2247,30 +2294,60 @@ ex_expr::exp_return_type ex_function_position::eval(char *op_data[],
len2 = Attributes::trimFillerSpaces( op_data[2], prec2, len2, cs );
}
- // If len1 is 0, return a position of 1.
- Lng32 position;
- if (len1 > 0)
+ Int32 startPos = 1;
+ Int32 occurrence = 1;
+ if (getNumOperands() >= 4) // start position and optional occurrence specified
{
+ startPos = *(Int32*)op_data[3];
+ if (getNumOperands() == 5)
+ occurrence = *(Int32*)op_data[4];
+
+ if (errorChecks(startPos, occurrence, heap, diagsArea))
+ return ex_expr::EXPR_ERROR;
+ }
+
+ // operand2/srcStr is the string to be searched in.
+ char * srcStr = &op_data[2][startPos-1];
+ len2 -= (startPos-1);
+ char * pat = op_data[1];
+
+ Lng32 position = 0;
+ if (len1 > 0)
+ {
short nPasses = CollationInfo::getCollationNPasses(getCollation());
- position = findPosition(op_data[2],
- len2,
- op_data[1],
- len1,
- 1,
- nPasses,
- getCollation(),
- 1,
- cs);
+ for (Int32 occ = 1; occ <= occurrence; occ++)
+ {
+ position = findPosition(srcStr,
+ len2,
+ pat,
+ len1,
+ 1,
+ nPasses,
+ getCollation(),
+ 1,
+ cs);
+
+ if(position < 0)
+ {
+ const char *csname = CharInfo::getCharSetName(cs);
+ ExRaiseSqlError(heap, diagsArea, EXE_INVALID_CHARACTER);
+ *(*diagsArea) << DgString0(csname) << DgString1("POSITION FUNCTION");
+ return ex_expr::EXPR_ERROR;
+ }
- if(position < 0)
- {
- const char *csname = CharInfo::getCharSetName(cs);
- ExRaiseSqlError(heap, diagsArea, EXE_INVALID_CHARACTER);
- *(*diagsArea) << DgString0(csname) << DgString1("POSITION FUNCTION");
- return ex_expr::EXPR_ERROR;
- }
-
+ if ((occ < occurrence) &&
+ (position > 0)) // found a matching string
+ {
+ // skip the current matched string and continue
+ srcStr += (position + len1 - 1);
+ len2 -= (position + len1 - 1);
+ startPos += (position + len1 -1);
+ }
+ } // for occ
+
+ if (position > 0) // found matching string
+ position += (startPos - 1);
}
else
{
@@ -2285,39 +2362,87 @@ ex_expr::exp_return_type ex_function_position::eval(char *op_data[],
};
ex_expr::exp_return_type ex_function_position_doublebyte::eval(char *op_data[],
- CollHeap*,
- ComDiagsArea**)
+ CollHeap*heap,
+ ComDiagsArea**diagsArea)
{
+ // len1 and len2 are character lengths.
+
+ // len1 is the pattern length to be searched.
Lng32 len1 = ( getOperand(1)->getLength(op_data[-MAX_OPERANDS+1]) ) / sizeof(NAWchar);
+
+ // len2 is the length of string to be seached in.
+ Lng32 len2 = ( getOperand(2)->getLength(op_data[-MAX_OPERANDS+2]) ) / sizeof(NAWchar);
- // If len1 is 0, return a position of 1.
- Lng32 position = 1;
- if (len1 > 0)
+ // startPos is character pos and not byte pos
+ Int32 startPos = 1;
+
+ Int32 occurrence = 1;
+ if (getNumOperands() >= 4)
{
- Lng32 len2 = ( getOperand(2)->getLength(op_data[-MAX_OPERANDS+2]) ) / sizeof(NAWchar);
+ startPos = *(Int32*)op_data[3];
+ if (getNumOperands() == 5)
+ occurrence = *(Int32*)op_data[4];
- NAWchar* pat = (NAWchar*)op_data[1];
- NAWchar* source = (NAWchar*)op_data[2];
-
- // If len1 > len2 or if operand 1 is not present in operand 2, return
- // a position of 0; otherwise return the position of operand 1 in
- // operand 2.
+ if (ex_function_position::errorChecks(startPos, occurrence,
+ heap, diagsArea))
+ return ex_expr::EXPR_ERROR;
+ }
+
+ // operand2/srcStr is the string to be searched in.
+ NAWchar * srcStr =
+ (NAWchar*)&op_data[2][startPos*sizeof(NAWchar) - sizeof(NAWchar)];
+
+ NAWchar* pat = (NAWchar*)op_data[1];
+
+ // start at specified startPos
+ Lng32 position = startPos;
+
+ // If patter length(len1) > srcStr len(len2), return position of 0
+ if (len1 > len2)
+ position = 0;
+ else if (len1 > 0)
+ {
+ // if pat is not present in srcStr, return position of 0;
+ // otherwise return the position of pat in srcStr for the
+ // specified occurrence.
short found = 0;
- while (position+len1-1 <= len2 && !found)
+ for (Int32 occ = 1; occ <= occurrence; occ++)
{
- if (wc_str_cmp(pat, &source[position-1], (Int32)len1))
- position++;
- else
- found = 1;
- }
- if (!found) position = 0;
+ found = 0;
+ while (position+len1-1 <= len2 && !found)
+ {
+ if (wc_str_cmp(pat, srcStr, (Int32)len1))
+ {
+ position++;
+ srcStr += 1;
+ }
+ else
+ found = 1;
+ }
+
+ if ((occ < occurrence) &&
+ (found)) // found a matching string
+ {
+ srcStr += len1;
+ position += len1;
+ }
+ } // for occ
+
+ if (! found) // not found matching string, return 0;
+ position = 0;
}
-
+ else
+ {
+ // if len1 <= 0, return position of 1.
+ position = 1;
+ }
+
// Now copy the position into result which is a long.
*(Lng32 *)op_data[0] = position;
return ex_expr::EXPR_OK;
};
+
static Lng32 findTokenPosition(char * sourceStr, Lng32 sourceLen,
char * searchStr, Lng32 searchLen,
short bytesPerChar)
http://git-wip-us.apache.org/repos/asf/trafodion/blob/43984c46/core/sql/exp/exp_function.h
----------------------------------------------------------------------
diff --git a/core/sql/exp/exp_function.h b/core/sql/exp/exp_function.h
index 13b7185..3f6bd0c 100644
--- a/core/sql/exp/exp_function.h
+++ b/core/sql/exp/exp_function.h
@@ -359,8 +359,9 @@ public:
class ex_function_position : public ex_function_clause {
public:
ex_function_position(OperatorTypeEnum oper_type,
- Attributes ** attr,
- Space * space);
+ Attributes ** attr,
+ Space * space,
+ int in_args_num);
ex_function_position();
@@ -403,10 +404,13 @@ public:
short charOffsetFlag = 0,
CharInfo::CharSet cs = CharInfo::ISO88591);
+ static Lng32 errorChecks(Lng32 startPos, Lng32 occurrence,
+ CollHeap* heap, ComDiagsArea** diagsArea);
+
ex_expr::exp_return_type pCodeGenerate(Space *space, UInt32 f);
- ex_expr::exp_return_type eval(char *op_data[], CollHeap*,
- ComDiagsArea** = 0);
+ ex_expr::exp_return_type eval(char *op_data[], CollHeap* heap,
+ ComDiagsArea** = 0);
Long pack(void *);
// ---------------------------------------------------------------------
@@ -443,22 +447,23 @@ public:
private:
Int16 collation_;
- char fillers_[6]; //
-
+ Int16 args_num;
+ char fillers_[4]; //
};
class ex_function_position_doublebyte :
public ex_function_clause {
public:
ex_function_position_doublebyte(OperatorTypeEnum oper_type,
- Attributes ** attr,
- Space * space);
+ Attributes ** attr,
+ Space * space,
+ int in_args_num);
ex_function_position_doublebyte();
- ex_expr::exp_return_type eval(char *op_data[], CollHeap*,
- ComDiagsArea** = 0);
+ ex_expr::exp_return_type eval(char *op_data[], CollHeap* heap,
+ ComDiagsArea** = 0);
Long pack(void *);
// ---------------------------------------------------------------------
@@ -477,6 +482,11 @@ public:
virtual short getClassSize() { return (short)sizeof(*this); }
// ---------------------------------------------------------------------
+
+private:
+ Int16 args_num;
+
+ char fillers_[6]; //
};
class ex_function_concat : public ex_function_clause {
http://git-wip-us.apache.org/repos/asf/trafodion/blob/43984c46/core/sql/generator/GenItemFunc.cpp
----------------------------------------------------------------------
diff --git a/core/sql/generator/GenItemFunc.cpp b/core/sql/generator/GenItemFunc.cpp
index 86c1758..6121110 100644
--- a/core/sql/generator/GenItemFunc.cpp
+++ b/core/sql/generator/GenItemFunc.cpp
@@ -445,7 +445,8 @@ short BuiltinFunction::codeGen(Generator * generator)
case CharInfo::UTF8:
// case CharInfo::SJIS: // Uncomment this if we ever support SJIS
function_clause = new(generator->getSpace())
- ex_function_position(ITM_POSITION, attr, space);
+ ex_function_position(ITM_POSITION, attr, space,
+ (getArity() + 1));
((ex_function_position *)function_clause)->setCollation(((PositionFunc*)this)->getCollation());
@@ -453,7 +454,8 @@ short BuiltinFunction::codeGen(Generator * generator)
case CharInfo::UCS2:
function_clause = new(generator->getSpace())
- ex_function_position_doublebyte(ITM_POSITION_DOUBLEBYTE, attr, space);
+ ex_function_position_doublebyte(ITM_POSITION_DOUBLEBYTE, attr, space,
+ (getArity() + 1));
break;
http://git-wip-us.apache.org/repos/asf/trafodion/blob/43984c46/core/sql/optimizer/BindItemExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/BindItemExpr.cpp b/core/sql/optimizer/BindItemExpr.cpp
index 3c81218..cc25f93 100644
--- a/core/sql/optimizer/BindItemExpr.cpp
+++ b/core/sql/optimizer/BindItemExpr.cpp
@@ -4038,10 +4038,20 @@ NABoolean DateFormat::errorChecks(Lng32 frmt, BindWA *bindWA,
error = 1; // error 4065
}
- if (toTime && NOT tf)
+ if (!error && toTime)
{
- // TO_TIME requires time format
- error = 1; // error 4065
+ if (NOT tf)
+ {
+ // TO_TIME requires time format
+ error = 1; // error 4065
+ }
+ // source must be datetime containing time field or a character string
+ else if (((opType->getTypeQualifier() == NA_DATETIME_TYPE) &&
+ (opType->getPrecision() == SQLDTCODE_DATE)) ||
+ (opType->getTypeQualifier() != NA_CHARACTER_TYPE))
+ {
+ error = 9; // error 3415
+ }
}
if (!error && toChar)
@@ -4095,7 +4105,7 @@ NABoolean DateFormat::errorChecks(Lng32 frmt, BindWA *bindWA,
{
*CmpCommon::diags() << DgSqlCode(-4065) << DgString0(formatStr_)
<< DgString1((toChar ? "TO_CHAR" :
- (toDate ? "TO_DATE" : "TO_TIME")));
+ (toDate ? "TO_DATE" : "TO_TIME")));
bindWA->setErrStatus();
}
break;
@@ -4149,6 +4159,14 @@ NABoolean DateFormat::errorChecks(Lng32 frmt, BindWA *bindWA,
}
break;
+ case 9:
+ {
+ *CmpCommon::diags() << DgSqlCode(-3415) << DgString0("TO_TIME")
+ << DgString1(" It must be a datetime datatype containing the time field or a character datatype.");
+ bindWA->setErrStatus();
+ }
+ break;
+
} // switch
return TRUE;
@@ -4333,28 +4351,23 @@ ItemExpr *Trim::bindNode(BindWA *bindWA)
if (type1.getTypeQualifier() == NA_NUMERIC_TYPE)
{
const NumericType &numeric = (NumericType&)type1;
- if ((numeric.isExact()) &&
- (NOT numeric.isBigNum()) &&
- (numeric.getScale() == 0))
- {
- Lng32 dLen =
- numeric.getDisplayLength(numeric.getFSDatatype(),
- numeric.getNominalSize(),
- numeric.getPrecision(),
- numeric.getScale(),
- 0);
-
- ItemExpr * newChild =
- new (bindWA->wHeap())
- Cast(child(1),
- new (bindWA->wHeap())
- SQLChar(bindWA->wHeap(), dLen, type1.supportsSQLnull()));
-
- newChild = newChild->bindNode(bindWA);
- if (bindWA->errStatus())
- return this;
- setChild(1, newChild);
- }
+ Lng32 dLen =
+ numeric.getDisplayLength(numeric.getFSDatatype(),
+ numeric.getNominalSize(),
+ numeric.getPrecision(),
+ numeric.getScale(),
+ 0);
+
+ ItemExpr * newChild =
+ new (bindWA->wHeap())
+ Cast(child(1),
+ new (bindWA->wHeap())
+ SQLChar(bindWA->wHeap(), dLen, type1.supportsSQLnull()));
+
+ newChild = newChild->bindNode(bindWA);
+ if (bindWA->errStatus())
+ return this;
+ setChild(1, newChild);
}
}
@@ -7231,25 +7244,16 @@ ItemExpr *Case::bindNode(BindWA *bindWA)
{
NumericType &numeric = (NumericType&)
thenClause->getValueId().getType();
- if ((numeric.isExact()) &&
- // (NOT numeric.isBigNum()) &&
- (numeric.getScale() == 0))
- {
- Lng32 numericDLen =
- numeric.getDisplayLength(numeric.getFSDatatype(),
- numeric.getNominalSize(),
- numeric.getPrecision(),
- numeric.getScale(),
- 0);
+ Lng32 numericDLen =
+ numeric.getDisplayLength(numeric.getFSDatatype(),
+ numeric.getNominalSize(),
+ numeric.getPrecision(),
+ numeric.getScale(),
+ 0);
- if (numericDLen > dLen)
- dLen = numericDLen;
- numericFound = TRUE;
- }
- else
- {
- done = TRUE;
- }
+ if (numericDLen > dLen)
+ dLen = numericDLen;
+ numericFound = TRUE;
}
else
{
@@ -8876,10 +8880,78 @@ ItemExpr *PositionFunc::bindNode(BindWA *bindWA)
}
}
+ // if third(start position) and fourth(occurence) child operands are
+ // specified, then convert them to INT.
+ if (child(2))
+ {
+ ValueId vid3 = child(2)->getValueId();
+ SQLInt si(NULL);
+
+ vid3.coerceType(si, NA_NUMERIC_TYPE);
+
+ const NAType &type3 = vid3.getType();
+
+ if (type3.getTypeQualifier() != NA_NUMERIC_TYPE) {
+ // 4053 The third operand of a POSITION function must be numeric.
+ *CmpCommon::diags() << DgSqlCode(-4053) << DgString0(getTextUpper());
+ return NULL;
+ }
+
+ if (((NumericType&)type3).getScale() != 0) {
+ // 4047 The third operand of a POSITION function must have a scale of 0.
+ *CmpCommon::diags() << DgSqlCode(-4047) << DgString0(getTextUpper());
+ return NULL;
+ }
+
+ if (type3.getFSDatatype() != REC_BIN32_SIGNED)
+ {
+ ItemExpr * newChild =
+ new (bindWA->wHeap())
+ Cast(child(2),
+ new (bindWA->wHeap())
+ SQLInt(bindWA->wHeap(), TRUE, type3.supportsSQLnull()));
+ newChild = newChild->bindNode(bindWA);
+ setChild(2, newChild);
+ }
+ }
+
+ if (child(3))
+ {
+ ValueId vid4 = child(3)->getValueId();
+ SQLInt si(NULL);
+
+ vid4.coerceType(si, NA_NUMERIC_TYPE);
+
+ const NAType &type4 = vid4.getType();
+
+ if (type4.getTypeQualifier() != NA_NUMERIC_TYPE) {
+ // 4053 The third operand of a POSITION function must be numeric.
+ *CmpCommon::diags() << DgSqlCode(-4053) << DgString0(getTextUpper());
+ return NULL;
+ }
+
+ if (((NumericType&)type4).getScale() != 0) {
+ // 4047 The third operand of a POSITION function must have a scale of 0.
+ *CmpCommon::diags() << DgSqlCode(-4047) << DgString0(getTextUpper());
+ return NULL;
+ }
+
+ if (type4.getFSDatatype() != REC_BIN32_SIGNED)
+ {
+ ItemExpr * newChild =
+ new (bindWA->wHeap())
+ Cast(child(3),
+ new (bindWA->wHeap())
+ SQLInt(bindWA->wHeap(), TRUE, type4.supportsSQLnull()));
+ newChild = newChild->bindNode(bindWA);
+ setChild(3, newChild);
+ }
+ }
+
BuiltinFunction::bindNode(bindWA);
if (bindWA->errStatus())
return this;
-
+
return getValueId().getItemExpr();
} // PositionFunc::bindNode()
@@ -8939,6 +9011,72 @@ ItemExpr *Replace::bindNode(BindWA *bindWA)
} // Replace::bindNode()
// -----------------------------------------------------------------------
+// member functions for class CharLength
+// -----------------------------------------------------------------------
+
+ItemExpr *CharLength::bindNode(BindWA *bindWA)
+{
+ if (nodeIsBound())
+ return getValueId().getItemExpr();
+
+ // this will bind/type-propagate all children.
+ bindChildren(bindWA);
+ if (bindWA->errStatus())
+ return this;
+
+ const NAType &type1 =
+ child(0)->castToItemExpr()->getValueId().getType();
+
+ if (type1.getTypeQualifier() == NA_NUMERIC_TYPE)
+ {
+ ItemExpr * newChild = new (bindWA->wHeap())
+ Trim((Int32)Trim::TRAILING,
+ new (PARSERHEAP()) SystemLiteral(" ", WIDE_(" ")), child(0));
+
+ setChild(0, newChild);
+ }
+
+ BuiltinFunction::bindNode(bindWA);
+ if (bindWA->errStatus())
+ return this;
+
+ return getValueId().getItemExpr();
+} // CharLength::bindNode()
+
+// -----------------------------------------------------------------------
+// member functions for class OctetLength
+// -----------------------------------------------------------------------
+
+ItemExpr *OctetLength::bindNode(BindWA *bindWA)
+{
+ if (nodeIsBound())
+ return getValueId().getItemExpr();
+
+ // this will bind/type-propagate all children.
+ bindChildren(bindWA);
+ if (bindWA->errStatus())
+ return this;
+
+ const NAType &type1 =
+ child(0)->castToItemExpr()->getValueId().getType();
+
+ if (type1.getTypeQualifier() == NA_NUMERIC_TYPE)
+ {
+ ItemExpr * newChild = new (bindWA->wHeap())
+ Trim((Int32)Trim::TRAILING,
+ new (PARSERHEAP()) SystemLiteral(" ", WIDE_(" ")), child(0));
+
+ setChild(0, newChild);
+ }
+
+ BuiltinFunction::bindNode(bindWA);
+ if (bindWA->errStatus())
+ return this;
+
+ return getValueId().getItemExpr();
+} // OctetLength::bindNode()
+
+// -----------------------------------------------------------------------
// member functions for class SelIndex
// -----------------------------------------------------------------------
@@ -11013,7 +11151,29 @@ ItemExpr *ZZZBinderFunction::bindNode(BindWA *bindWA)
}
break;
- case ITM_GREATEST:
+ case ITM_DAYOFMONTH:
+ {
+ // Make sure that the child is of date datatype.
+ ItemExpr * tempBoundTree =
+ child(0)->castToItemExpr()->bindNode(bindWA);
+ if (bindWA->errStatus())
+ return this;
+
+ if (tempBoundTree->getValueId().getType().getTypeQualifier() !=
+ NA_DATETIME_TYPE)
+ {
+ // 4071 The operand of a DAYOFMONTH function must be a datetime.
+ *CmpCommon::diags() << DgSqlCode(-4071) << DgString0(getTextUpper());
+ bindWA->setErrStatus();
+ return this;
+ }
+
+ parseTree = new(bindWA->wHeap())
+ ExtractOdbc(REC_DATE_DAY, child(0), TRUE);
+ }
+ break;
+
+ case ITM_GREATEST:
{
strcpy(buf, "CASE WHEN @A1 is NULL or @A2 is null then NULL WHEN @A1 > @A2 then @A1 else @A2 END;");
}
@@ -11032,16 +11192,16 @@ ItemExpr *ZZZBinderFunction::bindNode(BindWA *bindWA)
ItemExpr * tempBoundTree =
child(2)->castToItemExpr()->bindNode(bindWA);
if (bindWA->errStatus()) return this;
-
- // fix case 10-031103-2610, soln 10-031103-0997: make sure length arg
- // in function "INSERT(s1, start, length, s2)" is not null.
- if (tempBoundTree->getOperatorType() == ITM_CONSTANT &&
- ((ConstValue *)tempBoundTree)->isNull()) {
- *CmpCommon::diags() << DgSqlCode(-4097) << DgString0("INSERT");
- bindWA->setErrStatus();
- return this;
- }
-
+
+ // fix case 10-031103-2610, soln 10-031103-0997: make sure length arg
+ // in function "INSERT(s1, start, length, s2)" is not null.
+ if (tempBoundTree->getOperatorType() == ITM_CONSTANT &&
+ ((ConstValue *)tempBoundTree)->isNull()) {
+ *CmpCommon::diags() << DgSqlCode(-4097) << DgString0("INSERT");
+ bindWA->setErrStatus();
+ return this;
+ }
+
//
// Type cast any param.
//
@@ -11074,11 +11234,11 @@ ItemExpr *ZZZBinderFunction::bindNode(BindWA *bindWA)
// <str1> beginning at <start> and where <str2> has been inserted
// into <str1>, beginning at <start>
- // make sure replacement expression handles any null args correctly
- strcpy(buf, "CASE WHEN @A1 IS NULL THEN NULL"
- " WHEN @A2 IS NULL THEN NULL"
- " WHEN @A3 IS NULL THEN NULL"
- " WHEN @A4 IS NULL THEN NULL ELSE ");
+ // make sure replacement expression handles any null args correctly
+ strcpy(buf, "CASE WHEN @A1 IS NULL THEN NULL"
+ " WHEN @A2 IS NULL THEN NULL"
+ " WHEN @A3 IS NULL THEN NULL"
+ " WHEN @A4 IS NULL THEN NULL ELSE ");
// Get the characters before <start>
strcat(buf, "(LEFT(@A1, CAST(@A2 AS INT UNSIGNED) - 1)");
@@ -11549,11 +11709,27 @@ ItemExpr *ZZZBinderFunction::bindNode(BindWA *bindWA)
case ITM_SIGN:
{
- // find the nullability of child
ItemExpr * tempBoundTree =
child(0)->castToItemExpr()->bindNode(bindWA);
if (bindWA->errStatus()) return this;
+ //
+ // Type cast any param.
+ //
+ SQLInt nType(FALSE);
+ ValueId vid = tempBoundTree->castToItemExpr()->getValueId();
+ vid.coerceType(nType, NA_NUMERIC_TYPE);
+
+ const NAType &typ1 = vid.getType();
+ if (typ1.getTypeQualifier() != NA_NUMERIC_TYPE)
+ {
+ // 4045 Operand must be numeric.
+ *CmpCommon::diags() << DgSqlCode(-4045) << DgString0(getTextUpper());
+ bindWA->setErrStatus();
+ return this;
+ }
+
+ // find the nullability of child
NABoolean childIsNullable = FALSE;
if (tempBoundTree->getValueId().getType().supportsSQLnull())
{
http://git-wip-us.apache.org/repos/asf/trafodion/blob/43984c46/core/sql/optimizer/ItemCache.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/ItemCache.cpp b/core/sql/optimizer/ItemCache.cpp
index 4639e2d..b74447b 100644
--- a/core/sql/optimizer/ItemCache.cpp
+++ b/core/sql/optimizer/ItemCache.cpp
@@ -666,6 +666,14 @@ NABoolean ConstValue::isCacheableExpr(CacheWA& cwa)
// This fixes genesis case 10-041215-6141, soln 10-041215-2826.
return FALSE;
}
+
+ // string of length zero causes a problem during backpatching in method
+ // CacheData::backpatchParams.
+ // For now, do not cache it.
+ if ((NOT isNull()) &&
+ (isEmptyString()))
+ return FALSE;
+
return ItemExpr::isCacheableExpr(cwa);
}
http://git-wip-us.apache.org/repos/asf/trafodion/blob/43984c46/core/sql/optimizer/ItemExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/ItemExpr.cpp b/core/sql/optimizer/ItemExpr.cpp
index 744a0a5..c37a4d1 100644
--- a/core/sql/optimizer/ItemExpr.cpp
+++ b/core/sql/optimizer/ItemExpr.cpp
@@ -7503,6 +7503,8 @@ const NAString BuiltinFunction::getText() const
return "current_user";
case ITM_DATEFORMAT:
return "dateformat";
+ case ITM_DAYOFMONTH:
+ return "dayofmonth";
case ITM_DAYOFWEEK:
return "dayofweek";
case ITM_DO_WHILE:
@@ -7758,6 +7760,9 @@ const NAString BuiltinFunction::getText() const
case ITM_AGGR_GROUPING_FUNC:
return "aggr_grouping";
+ case ITM_TO_TIMESTAMP:
+ return "to_timestamp";
+
default:
return "unknown func";
} // switch
@@ -8212,7 +8217,7 @@ ItemExpr * PositionFunc::copyTopNode(ItemExpr *derivedNode, CollHeap* outHeap)
ItemExpr *result;
if (derivedNode == NULL)
- result = new (outHeap) PositionFunc(child(0), child(1), child(2));
+ result = new (outHeap) PositionFunc(child(0), child(1), child(2), child(3));
else
result = derivedNode;
http://git-wip-us.apache.org/repos/asf/trafodion/blob/43984c46/core/sql/optimizer/ItemFunc.h
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/ItemFunc.h b/core/sql/optimizer/ItemFunc.h
index 6c0c779..0003740 100644
--- a/core/sql/optimizer/ItemFunc.h
+++ b/core/sql/optimizer/ItemFunc.h
@@ -1610,6 +1610,9 @@ public:
// a virtual function for type propagating the node
virtual const NAType * synthesizeType();
+ // a virtual function for performing name binding within the query tree
+ virtual ItemExpr * bindNode(BindWA *bindWA);
+
virtual ItemExpr * copyTopNode(ItemExpr *derivedNode = NULL,
CollHeap* outHeap = 0);
@@ -1632,6 +1635,9 @@ public:
// a virtual function for type propagating the node
virtual const NAType * synthesizeType();
+ // a virtual function for performing name binding within the query tree
+ virtual ItemExpr * bindNode(BindWA *bindWA);
+
virtual ItemExpr * copyTopNode(ItemExpr *derivedNode = NULL,
CollHeap* outHeap = 0);
virtual NABoolean protectFromVEGs() { return TRUE; };
@@ -1643,8 +1649,10 @@ public:
class PositionFunc : public CacheableBuiltinFunction
{
public:
- PositionFunc(ItemExpr *val1Ptr, ItemExpr *val2Ptr, ItemExpr *val3Ptr)
- : CacheableBuiltinFunction(ITM_POSITION, 3, val1Ptr, val2Ptr, val3Ptr)
+ PositionFunc(ItemExpr *val1Ptr, ItemExpr *val2Ptr, ItemExpr *val3Ptr,
+ ItemExpr *val4Ptr)
+ : CacheableBuiltinFunction(ITM_POSITION, 4,
+ val1Ptr, val2Ptr, val3Ptr, val4Ptr)
{ allowsSQLnullArg() = FALSE; }
// virtual destructor
http://git-wip-us.apache.org/repos/asf/trafodion/blob/43984c46/core/sql/optimizer/SynthType.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/SynthType.cpp b/core/sql/optimizer/SynthType.cpp
index 5dcb94e..e97484c 100644
--- a/core/sql/optimizer/SynthType.cpp
+++ b/core/sql/optimizer/SynthType.cpp
@@ -3548,7 +3548,7 @@ const NAType *BitOperFunc::synthesizeType()
// now it's safe to cast the types to numeric type
const NumericType &ntyp1 = (NumericType &) child(0)->getValueId().getType();
const NumericType &ntyp2 = (NumericType &) child(1)->getValueId().getType();
-
+
if (NOT ntyp1.isExact() OR NOT ntyp2.isExact() OR
ntyp1.isBigNum() OR ntyp2.isBigNum())
{
@@ -3582,7 +3582,7 @@ const NAType *BitOperFunc::synthesizeType()
// now it's safe to cast the types to numeric type
const NumericType &ntyp1 = (NumericType &) child(0)->getValueId().getType();
-
+
if (NOT ntyp1.isExact() OR ntyp1.isBigNum())
{
// 4046 BIT operation is only defined for exact numeric types.
@@ -4878,21 +4878,6 @@ const NAType *OctetLength::synthesizeType()
const NAType *PositionFunc::synthesizeType()
{
- NABoolean JDBC = (CmpCommon::getDefault(JDBC_PROCESS) == DF_ON);
- if ((NOT JDBC) && (getArity() == 3))
- {
- // third argument not supported for non-JDBC callers.
- *CmpCommon::diags() << DgSqlCode(-3131);
- return NULL;
- }
- else
- {
- // third argument is only supported for JDBC_PROCESS callers and
- // is ignored. This is done for WLS/JDBC project who only want
- // to not get a syntax error if a third argument is passed in.
- // Go figure.
- // They need this to get through some certification tests.
- }
//
// Type cast any params.
@@ -4907,15 +4892,8 @@ const NAType *PositionFunc::synthesizeType()
const NAType *operand1 = &vid1.getType();
const NAType *operand2 = &vid2.getType();
const NAType *operand3 = NULL;
+ const NAType *operand4 = NULL;
- if (getArity() == 3)
- {
- ValueId vid3 = child(2)->getValueId();
- SQLInt si(NULL);
-
- vid3.coerceType(si, NA_NUMERIC_TYPE);
- operand3 = &vid3.getType();
- }
//
// Check that the operands are comparable.
@@ -4942,19 +4920,6 @@ const NAType *PositionFunc::synthesizeType()
return NULL;
}
- if (operand3) {
- if (operand3->getTypeQualifier() != NA_NUMERIC_TYPE) {
- // 4053 The third operand of a POSITION function must be numeric.
- *CmpCommon::diags() << DgSqlCode(-4053) << DgString0(getTextUpper());
- return NULL;
- }
-
- if (((NumericType*)operand3)->getScale() != 0) {
- // 4047 The third operand of a POSITION function must have a scale of 0.
- *CmpCommon::diags() << DgSqlCode(-4047) << DgString0(getTextUpper());
- return NULL;
- }
- }
// 1/5/98: make sure position pattern and source types are comparable.
const CharType *posPat = (CharType*)operand1;
http://git-wip-us.apache.org/repos/asf/trafodion/blob/43984c46/core/sql/optimizer/ValueDesc.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/ValueDesc.cpp b/core/sql/optimizer/ValueDesc.cpp
index 605118b..a39040f 100644
--- a/core/sql/optimizer/ValueDesc.cpp
+++ b/core/sql/optimizer/ValueDesc.cpp
@@ -6258,7 +6258,6 @@ void ValueIdList::convertToTextKey(const ValueIdList& keyList, NAString& result)
const NAType *constType = constVal->getType();
NAString val = *constVal->getRawText();
- // val = val.strip(NAString::leading, ' ');
short len = 0;
///////////////////////////////////////////////////////////////////////
@@ -6381,35 +6380,47 @@ void ValueIdList::convertToTextKey(const ValueIdList& keyList, NAString& result)
}
else
{
- short vLen = val.length();
+ short vLen = val.length();
if ((constType->getTypeQualifier() == NA_NUMERIC_TYPE) &&
(((NumericType*)constType)->isExact()) &&
- (NOT ((NumericType&)type).isBigNum()) &&
+ (NOT ((NumericType*)constType)->isBigNum()) &&
(constType->getScale() > 0))
{
- NAString newVal;
- if (vLen <= constType->getScale())
- {
- newVal = "0.";
- for (Lng32 i = 0; i < (constType->getScale() - vLen); i++)
- {
- newVal += "0";
- }
- newVal += val;
- }
- else
- {
- // get digits to the left of scale
- newVal = val(0, vLen - constType->getScale() );
-
- newVal += ".";
- newVal += val(vLen - constType->getScale(), constType->getScale());
- }
+ // See how many positions the result will take in the display
+ Lng32 t = constType->getDisplayLength(constType->getFSDatatype(),
+ constType->getNominalSize(),
+ constType->getPrecision(),
+ constType->getScale(),
+ 0);
+
+ char strval[100];
+ memset( strval, ' ', t );
+
+ // Get the ASCII representation
+ ex_expr::exp_return_type retcode =
+ convDoIt((char*)constVal->getConstValue(),
+ constVal->getStorageSize(),
+ (short)constType->getFSDatatype(),
+ constType->getPrecision(),
+ constType->getScale(),
+ strval,
+ t, // target length
+ REC_BYTE_F_ASCII, // target type
+ 0, // no char limit
+ SQLCHARSETCODE_ISO88591, // ISO 8859-1
+ NULL, // no vc length
+ 0); // not a varchar
+
+ if ( retcode == ex_expr::EXPR_OK )
+ {
+ strval[t] = 0;
+ val = strval;
+ val = val.strip(NAString::trailing, ' ');
+ }
- val = newVal;
vLen = val.length();
- }
+ } // exact numeric
len += vLen;
http://git-wip-us.apache.org/repos/asf/trafodion/blob/43984c46/core/sql/parser/sqlparser.y
----------------------------------------------------------------------
diff --git a/core/sql/parser/sqlparser.y b/core/sql/parser/sqlparser.y
index d7ea7f2..f2c9fbb 100755
--- a/core/sql/parser/sqlparser.y
+++ b/core/sql/parser/sqlparser.y
@@ -8767,7 +8767,11 @@ datetime_misc_function : TOK_CONVERTTIMESTAMP '(' value_expression ')'
{
$$ = new (PARSERHEAP()) ZZZBinderFunction(ITM_FIRSTDAYOFYEAR, $3);
}
-
+
+ | TOK_DAYOFMONTH '(' value_expression ')'
+ {
+ $$ = new (PARSERHEAP()) ZZZBinderFunction(ITM_DAYOFMONTH, $3);
+ }
| TOK_MONTHNAME '(' value_expression ')'
{
$$ = new (PARSERHEAP()) ZZZBinderFunction(ITM_MONTHNAME, $3);
@@ -8805,12 +8809,6 @@ datetime_misc_function : TOK_CONVERTTIMESTAMP '(' value_expression ')'
ExtractOdbc(REC_DATE_DAY, $3,
TRUE);
}
- | TOK_DAYOFMONTH '(' value_expression ')'
- {
- $$ = new(PARSERHEAP())
- ExtractOdbc(REC_DATE_DAY, $3,
- TRUE);
- }
| TOK_HOUR '(' value_expression ')'
{
$$ = new(PARSERHEAP())
@@ -9011,14 +9009,14 @@ string_function :
/* POSITION(str-exp1 IN str-exp2) */
| TOK_LOCATE '(' value_expression ',' value_expression ')'
{
- $$ = new (PARSERHEAP()) PositionFunc($3,$5,NULL);
+ $$ = new (PARSERHEAP()) PositionFunc($3,$5,NULL,NULL);
}
/* ODBC extension: map LOCATE(str-exp1, str-exp2, START) to */
/* POSITION(str-exp1 IN str-exp2) */
| TOK_LOCATE '(' value_expression ',' value_expression ',' value_expression ')'
{
- $$ = new (PARSERHEAP()) PositionFunc($3,$5,$7);
+ $$ = new (PARSERHEAP()) PositionFunc($3,$5,$7,NULL);
}
| TOK_LPAD '(' value_expression ',' value_expression ')'
@@ -9059,14 +9057,25 @@ string_function :
| TOK_POSITION '(' value_expression TOK_IN value_expression ')'
{
- $$ = new (PARSERHEAP()) PositionFunc($3,$5,NULL);
+ $$ = new (PARSERHEAP()) PositionFunc($3,$5,NULL,NULL);
}
| TOK_INSTR '(' value_expression TOK_IN value_expression ')'
{
- CheckModeSpecial4;
+ $$ = new (PARSERHEAP()) PositionFunc($3,$5,NULL,NULL);
+ }
- $$ = new (PARSERHEAP()) PositionFunc($5,$3,NULL);
+ | TOK_INSTR '(' value_expression ',' value_expression ')'
+ {
+ $$ = new (PARSERHEAP()) PositionFunc($5,$3,NULL,NULL);
+ }
+ | TOK_INSTR '(' value_expression ',' value_expression ',' value_expression ')'
+ {
+ $$ = new (PARSERHEAP()) PositionFunc($5,$3,$7,NULL);
+ }
+ | TOK_INSTR '(' value_expression ',' value_expression ',' value_expression ',' value_expression ')'
+ {
+ $$ = new (PARSERHEAP()) PositionFunc($5,$3,$7,$9);
}
/* ODBC extension */
@@ -16790,6 +16799,12 @@ exe_util_hive_query : TOK_PROCESS TOK_HIVE TOK_STATEMENT QUOTED_STRING
ExeUtilHiveQuery(*$4, ExeUtilHiveQuery::FROM_STRING,
PARSERHEAP());
}
+ | TOK_PROCESS TOK_HIVE TOK_DDL QUOTED_STRING
+ {
+ $$ = new (PARSERHEAP())
+ ExeUtilHiveQuery(*$4, ExeUtilHiveQuery::FROM_STRING,
+ PARSERHEAP());
+ }
| TOK_PROCESS TOK_HIVE TOK_STATEMENT TOK_FROM TOK_FILE QUOTED_STRING
{
$$ = new (PARSERHEAP())
http://git-wip-us.apache.org/repos/asf/trafodion/blob/43984c46/core/sql/regress/compGeneral/EXPECTED006.SB
----------------------------------------------------------------------
diff --git a/core/sql/regress/compGeneral/EXPECTED006.SB b/core/sql/regress/compGeneral/EXPECTED006.SB
index bc0a75d..945d64d 100644
--- a/core/sql/regress/compGeneral/EXPECTED006.SB
+++ b/core/sql/regress/compGeneral/EXPECTED006.SB
@@ -296,10 +296,7 @@
>>prepare xx from select char_length(a) from t006t2;
-*** ERROR[4043] The operand of function CHARACTER_LENGTH, CHAR_LENGTH, or LENGTH must be character.
-
-*** ERROR[8822] The statement was not prepared.
-
+--- SQL command prepared.
>>prepare xx from select lower(a) from t006t2;
*** ERROR[4043] The operand of function LOWER or LCASE must be character.
@@ -308,10 +305,7 @@
>>prepare xx from select octet_length(a) from t006t2;
-*** ERROR[4043] The operand of function OCTET_LENGTH must be character.
-
-*** ERROR[8822] The statement was not prepared.
-
+--- SQL command prepared.
>>
>>-- Error 4045
>>prepare xx from select zeroifnull(a) from t006t1;