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 2016/04/27 03:28:03 UTC
[06/12] incubator-trafodion git commit: Various fixes (details below)
Various fixes (details below)
-- ddl_transactions cqd is now on by default.
All ddl, where allowed and supported, will run
within one transaction
-- drop schema has been disabled to run within one transaction.
When jira 1948 is fixed, it will be enabled.
-- hdfs scan handles hive col values > 32K
-- pcode handles varchar with len > 32K
-- errors (gaps, unsorted order) for cqd values in nadefaults are
detected without crashing arkcmp.
-- volatile and regular schema drop returns the reason if an error occured
(for ex: name of objects that could not be dropped)
-- dateformat displays european format correctly with a blank
seperator between date and time values
-- dateformat timestamp in usa format displayes time with AM/PM
-- dateformat inside a cast function returns correct values.
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/1c52a1b4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/1c52a1b4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/1c52a1b4
Branch: refs/heads/master
Commit: 1c52a1b4ef645c8c8be87b8dab132ae07bc621b6
Parents: b7a6e54
Author: Anoop Sharma <ce...@ansharma-3.novalocal>
Authored: Thu Apr 21 22:21:59 2016 +0000
Committer: Anoop Sharma <ce...@ansharma-3.novalocal>
Committed: Thu Apr 21 22:21:59 2016 +0000
----------------------------------------------------------------------
core/sql/bin/SqlciErrors.txt | 2 +-
core/sql/common/CharType.cpp | 19 ++--
core/sql/common/CharType.h | 5 +-
core/sql/executor/ExExeUtil.h | 4 +-
core/sql/executor/ExExeUtilVolTab.cpp | 21 +++-
core/sql/executor/ExHdfsScan.cpp | 12 ++-
core/sql/exp/exp_clause.cpp | 12 +++
core/sql/exp/exp_datetime.cpp | 28 ++++--
core/sql/exp/exp_datetime.h | 3 +-
core/sql/exp/exp_eval.cpp | 2 +-
core/sql/exp/exp_function.h | 2 +
core/sql/generator/GenPreCode.cpp | 1 +
core/sql/generator/GenRelScan.cpp | 75 ++++++++------
core/sql/optimizer/BindItemExpr.cpp | 6 +-
core/sql/optimizer/RelScan.h | 5 +-
core/sql/regress/compGeneral/TEST004 | 9 +-
core/sql/regress/executor/EXPECTED140 | 3 -
core/sql/regress/seabase/EXPECTED030 | 18 +++-
core/sql/regress/seabase/TEST030 | 2 +
core/sql/sqlcomp/CmpSeabaseDDLschema.cpp | 134 +++++++++++++++++++-------
20 files changed, 260 insertions(+), 103 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1c52a1b4/core/sql/bin/SqlciErrors.txt
----------------------------------------------------------------------
diff --git a/core/sql/bin/SqlciErrors.txt b/core/sql/bin/SqlciErrors.txt
index ad65ac9..3798754 100644
--- a/core/sql/bin/SqlciErrors.txt
+++ b/core/sql/bin/SqlciErrors.txt
@@ -68,7 +68,7 @@
1066 ZZZZZ 99999 BEGINNER MAJOR DBADMIN Creating index $0~TableName in metadata schema is not allowed.
1067 ZZZZZ 99999 BEGINNER MAJOR DBADMIN Creating module $0~String0 in metadata schema is not allowed.
1068 ZZZZZ 99999 ADVANCED MAJOR DIALOUT An internal error was encountered: cannot create lock $0~TableName in metadata schema.
-1069 ZZZZZ 99999 BEGINNER MAJOR DBADMIN Schema $0~SchemaName could not be dropped.
+1069 ZZZZZ 99999 BEGINNER MAJOR DBADMIN Schema $0~SchemaName could not be dropped. $0~String0
1070 ZZZZZ 99999 BEGINNER MAJOR DBADMIN Object $0~TableName could not be created. File error: $1~Int0.
1071 ZZZZZ 99999 BEGINNER MAJOR DBADMIN Object $0~TableName could not be accessed.
1072 ZZZZZ 99999 BEGINNER MAJOR DBADMIN Unique constraint $0~String0 is disabled, so foreign key constraint $1~ConstraintName could not be created.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1c52a1b4/core/sql/common/CharType.cpp
----------------------------------------------------------------------
diff --git a/core/sql/common/CharType.cpp b/core/sql/common/CharType.cpp
index 6f9e8a3..dc08028 100644
--- a/core/sql/common/CharType.cpp
+++ b/core/sql/common/CharType.cpp
@@ -69,7 +69,7 @@ CharType::CharType( const NAString& adtName,
CharInfo::Collation co,
CharInfo::Coercibility ce,
CharInfo::CharSet encoding,
- Int32 iCharLen // default is 0
+ Int32 vcIndLen // default is 0
)
: NAType( adtName
, NA_CHARACTER_TYPE
@@ -77,11 +77,13 @@ CharType::CharType( const NAString& adtName,
, allowSQLnull
, allowSQLnull ? SQL_NULL_HDR_SIZE : 0
, varLenFlag
- , (varLenFlag ? (((maxLenInBytesOrNAWchars*CharInfo::minBytesPerChar(cs)) & 0xFFFF8000)
- ? SQL_VARCHAR_HDR_SIZE_4
- : SQL_VARCHAR_HDR_SIZE)
- : 0) // computes length of VarCharLen field (0 or 2 or 4 bytes)
- // see also ../sqludr/sqludr.cpp, method TypeInfo::TypeInfo
+ // computes length of VarCharLen field (0 or 2 or 4 bytes)
+ // if not passed in
+ , (varLenFlag ? ((vcIndLen > 0) ? vcIndLen :
+ (((maxLenInBytesOrNAWchars*CharInfo::minBytesPerChar(cs)) & 0xFFFF8000)
+ ? SQL_VARCHAR_HDR_SIZE_4
+ : SQL_VARCHAR_HDR_SIZE))
+ : 0)
, CharInfo::minBytesPerChar(cs)
),
qualifier_ (CHARACTER_STRING_TYPE),
@@ -932,13 +934,14 @@ SQLVarChar::SQLVarChar(Lng32 maxLen,
CharInfo::CharSet cs,
CharInfo::Collation co,
CharInfo::Coercibility ce,
- CharInfo::CharSet encoding
+ CharInfo::CharSet encoding,
+ Lng32 vcIndLen
)
: CharType(LiteralVARCHAR,
maxLen, CharInfo::maxBytesPerChar(cs),
FALSE, allowSQLnull, isUpShifted, isCaseInsensitive,
TRUE, cs, co, ce,
- encoding),
+ encoding, vcIndLen),
clientDataType_(collHeap()) // Get heap from NABasicObject. Can't allocate on stack.
{}
#pragma warn(1506) // warning elimination
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1c52a1b4/core/sql/common/CharType.h
----------------------------------------------------------------------
diff --git a/core/sql/common/CharType.h b/core/sql/common/CharType.h
index 7d0c383..11369b6 100644
--- a/core/sql/common/CharType.h
+++ b/core/sql/common/CharType.h
@@ -125,7 +125,7 @@ CharType (const NAString& adtName,
CharInfo::Collation co = CharInfo::DefaultCollation,
CharInfo::Coercibility ce = CharInfo::COERCIBLE,
CharInfo::CharSet encoding = CharInfo::UnknownCharSet,
- Int32 iCharLen = 0
+ Lng32 vcIndLen = 0 // not passed in, need to be computed
);
CharType (const NAString& adtName,
const CharLenInfo & maxLenInfo,
@@ -500,7 +500,8 @@ public:
CharInfo::CharSet = CharInfo::DefaultCharSet,
CharInfo::Collation = CharInfo::DefaultCollation,
CharInfo::Coercibility = CharInfo::COERCIBLE,
- CharInfo::CharSet encoding = CharInfo::UnknownCharSet
+ CharInfo::CharSet encoding = CharInfo::UnknownCharSet,
+ Lng32 vcIndLen = 0
);
SQLVarChar(const CharLenInfo & maxLenInfo,
NABoolean allowSQLnull = TRUE,
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1c52a1b4/core/sql/executor/ExExeUtil.h
----------------------------------------------------------------------
diff --git a/core/sql/executor/ExExeUtil.h b/core/sql/executor/ExExeUtil.h
index d726a1f..78a1e9d 100755
--- a/core/sql/executor/ExExeUtil.h
+++ b/core/sql/executor/ExExeUtil.h
@@ -1008,7 +1008,8 @@ class ExExeUtilCleanupVolatileTablesTcb : public ExExeUtilVolatileTablesTcb
static short dropVolatileSchema(ContextCli * currContext,
char * schemaName,
CollHeap * heap,
- ex_globals *globals = NULL);
+ ex_globals *globals = NULL,
+ ComDiagsArea * diagsArea = NULL);
static short dropVolatileTables(ContextCli * currContext, CollHeap * heap);
private:
@@ -1031,6 +1032,7 @@ class ExExeUtilCleanupVolatileTablesTcb : public ExExeUtilVolatileTablesTcb
Queue * schemaNamesList_;
NABoolean someSchemasCouldNotBeDropped_;
+ char errorSchemas_[1010];
char * schemaQuery_;
};
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1c52a1b4/core/sql/executor/ExExeUtilVolTab.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/ExExeUtilVolTab.cpp b/core/sql/executor/ExExeUtilVolTab.cpp
index 053e6e0..278d1e3 100644
--- a/core/sql/executor/ExExeUtilVolTab.cpp
+++ b/core/sql/executor/ExExeUtilVolTab.cpp
@@ -437,6 +437,8 @@ short ExExeUtilCleanupVolatileTablesTcb::work()
case INITIAL_:
{
step_ = FETCH_SCHEMA_NAMES_;
+ errorSchemas_[0] = 0;
+
}
break;
@@ -537,15 +539,23 @@ short ExExeUtilCleanupVolatileTablesTcb::work()
char * schemaName = vi->get(0);
retcode =
dropVolatileSchema(masterGlob->getStatement()->getContext(),
- schemaName, getHeap(), getGlobals());
+ schemaName, getHeap(), getGlobals(),
+ getDiagsArea());
if (retcode < 0)
{
+ // changes errors to warnings and move on to next schema.
+ if (getDiagsArea())
+ getDiagsArea()->negateAllErrors();
+
// clear diags and move on to next schema.
// Remember that an error was returned, we will
// return a warning at the end.
SQL_EXEC_ClearDiagnostics(NULL);
retcode = 0;
+ if ((strlen(errorSchemas_) + strlen(schemaName)) < 1000)
+ strcat(errorSchemas_, schemaName);
+
someSchemasCouldNotBeDropped_ = TRUE;
}
@@ -561,7 +571,8 @@ short ExExeUtilCleanupVolatileTablesTcb::work()
// add a warning to indicate that some schemas were not
// dropped.
ComDiagsArea * diags = getDiagsArea();
- *diags << DgSqlCode(1069);
+ *diags << DgSqlCode(1069)
+ << DgSchemaName(errorSchemas_);
}
step_ = DONE_;
}
@@ -600,7 +611,8 @@ short ExExeUtilCleanupVolatileTablesTcb::dropVolatileSchema
(ContextCli * currContext,
char * schemaName,
CollHeap * heap,
- ex_globals *glob)
+ ex_globals *glob,
+ ComDiagsArea *diagsArea)
{
const char *parentQid = NULL;
if (glob)
@@ -643,7 +655,8 @@ short ExExeUtilCleanupVolatileTablesTcb::dropVolatileSchema
// issue the drop schema command
Lng32 cliRC = cliInterface.executeImmediate(dropSchema);
-
+ cliInterface.retrieveSQLDiagnostics(diagsArea);
+
// reset volatile schema bit
// currContext->resetSqlParserFlags(0x8000); // ALLOW_VOLATILE_SCHEMA_CREATION
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1c52a1b4/core/sql/executor/ExHdfsScan.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/ExHdfsScan.cpp b/core/sql/executor/ExHdfsScan.cpp
index 1593899..1278c3a 100644
--- a/core/sql/executor/ExHdfsScan.cpp
+++ b/core/sql/executor/ExHdfsScan.cpp
@@ -1440,8 +1440,8 @@ char * ExHdfsScanTcb::extractAndTransformAsciiSourceToSqlRow(int &err,
else
return sourceRowEnd+1;
}
- short len = 0;
- len = sourceColEnd - sourceData ;
+ Int32 len = 0;
+ len = (Int64)sourceColEnd - (Int64)sourceData;
if (rdSeen) {
sourceRowEnd = sourceColEnd + changedLen;
hdfsLoggingRowEnd_ = sourceRowEnd;
@@ -1456,7 +1456,13 @@ char * ExHdfsScanTcb::extractAndTransformAsciiSourceToSqlRow(int &err,
if (attr) // this is a needed column. We need to convert
{
- *(short*)&hdfsAsciiSourceData_[attr->getVCLenIndOffset()] = len;
+ if (attr->getVCIndicatorLength() == sizeof(short))
+ *(short*)&hdfsAsciiSourceData_[attr->getVCLenIndOffset()]
+ = (short)len;
+ else
+ *(Int32*)&hdfsAsciiSourceData_[attr->getVCLenIndOffset()]
+ = len;
+
if (attr->getNullFlag())
{
if (len == 0)
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1c52a1b4/core/sql/exp/exp_clause.cpp
----------------------------------------------------------------------
diff --git a/core/sql/exp/exp_clause.cpp b/core/sql/exp/exp_clause.cpp
index 1b5400e..da951d8 100644
--- a/core/sql/exp/exp_clause.cpp
+++ b/core/sql/exp/exp_clause.cpp
@@ -2005,6 +2005,18 @@ void ExFunctionHbaseVersion::displayContents(Space * space, const char * /*displ
ex_clause::displayContents(space, (const char *)NULL, clauseNum, constsArea);
}
+void ex_function_dateformat::displayContents(Space * space, const char * /*displayStr*/, Int32 clauseNum, char * constsArea)
+{
+ char buf[100];
+ str_sprintf(buf, " Clause #%d: ex_function_dateformat", clauseNum);
+ space->allocateAndCopyToAlignedSpace(buf, str_len(buf), sizeof(short));
+
+ str_sprintf(buf, " dateformat_ = %d", dateformat_);
+ space->allocateAndCopyToAlignedSpace(buf, str_len(buf), sizeof(short));
+
+ ex_clause::displayContents(space, (const char *)NULL, clauseNum, constsArea);
+}
+
// Function to compare two strings.
NA_EIDPROC Int32 charStringCompareWithPad(char* in_s1, Int32 length1,
char* in_s2, Int32 length2,
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1c52a1b4/core/sql/exp/exp_datetime.cpp
----------------------------------------------------------------------
diff --git a/core/sql/exp/exp_datetime.cpp b/core/sql/exp/exp_datetime.cpp
index deb8300..962c6ee 100644
--- a/core/sql/exp/exp_datetime.cpp
+++ b/core/sql/exp/exp_datetime.cpp
@@ -130,6 +130,7 @@ const ExpDatetime::DatetimeFormatInfo ExpDatetime::datetimeFormat[] =
{ExpDatetime::DATETIME_FORMAT_TS7, "MM/DD/YYYY HH24:MI:SS", 19, 19},
{ExpDatetime::DATETIME_FORMAT_TS8, "DD-MON-YYYY HH:MI:SS", 20, 20},
{ExpDatetime::DATETIME_FORMAT_TS9, "MONTH DD, YYYY, HH:MI", 19, 25},
+ {ExpDatetime::DATETIME_FORMAT_TS10, "DD.MM.YYYY HH24:MI:SS", 19, 19},
{ExpDatetime::DATETIME_FORMAT_NUM1, "99:99:99:99", 11, 11},
{ExpDatetime::DATETIME_FORMAT_NUM2, "-99:99:99:99", 12, 12}
@@ -2835,7 +2836,8 @@ ExpDatetime::convAsciiToDate(char *srcData,
};
break;
- case DATETIME_FORMAT_TS2: // DD.MM.YYYY:HH24:MI:SS
+ case DATETIME_FORMAT_TS2: // DD.MM.YYYY:HH24:MI:SS
+ case DATETIME_FORMAT_TS10: // DD.MM.YYYY:HH24:MI:SS
{
// the day
if (convSrcDataToDst(2, srcData, 1, &dstData[3], ".", heap, diagsArea))
@@ -2846,9 +2848,17 @@ ExpDatetime::convAsciiToDate(char *srcData,
return -1;
// the year
- if (convSrcDataToDst(4, srcData, 2, dstData, ":", heap, diagsArea))
- return -1;
-
+ if (srcFormat == DATETIME_FORMAT_TS2)
+ {
+ if (convSrcDataToDst(4, srcData, 2, dstData, ":", heap, diagsArea))
+ return -1;
+ }
+ else
+ {
+ if (convSrcDataToDst(4, srcData, 2, dstData, " ", heap, diagsArea))
+ return -1;
+ }
+
// the hour
if (convSrcDataToDst(2, srcData, 1, &dstData[4], ":", heap, diagsArea))
return -1;
@@ -3278,11 +3288,13 @@ ExpDatetime::convDatetimeToASCII(char *srcData,
case DATETIME_FORMAT_EUROPEAN4:
case DATETIME_FORMAT_TS2:
case DATETIME_FORMAT_TS8:
+ case DATETIME_FORMAT_TS10:
if (day) {
convertToAscii(day, dstDataPtr, 2);
if (startField < REC_DATE_DAY) {
if ((format == DATETIME_FORMAT_EUROPEAN) ||
- (format == DATETIME_FORMAT_TS2))
+ (format == DATETIME_FORMAT_TS2) ||
+ (format == DATETIME_FORMAT_TS10))
*dstDataPtr++ = '.';
else if (format != DATETIME_FORMAT_EUROPEAN4)
*dstDataPtr++ = '-';
@@ -3297,7 +3309,8 @@ ExpDatetime::convDatetimeToASCII(char *srcData,
convertToAscii(month, dstDataPtr, 2);
if (startField < REC_DATE_MONTH) {
if ((format == DATETIME_FORMAT_EUROPEAN) ||
- (format == DATETIME_FORMAT_TS2))
+ (format == DATETIME_FORMAT_TS2) ||
+ (format == DATETIME_FORMAT_TS10))
*dstDataPtr++ = '.';
else if (format != DATETIME_FORMAT_EUROPEAN4)
*dstDataPtr++ = '-';
@@ -3366,7 +3379,8 @@ ExpDatetime::convDatetimeToASCII(char *srcData,
// USA format uses AM|PM format.
//
- if (format == DATETIME_FORMAT_USA) {
+ if ((format == DATETIME_FORMAT_USA) ||
+ (format == DATETIME_FORMAT_TS7)) {
if (hour < 1)
hour += 12;
else if (hour > 12)
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1c52a1b4/core/sql/exp/exp_datetime.h
----------------------------------------------------------------------
diff --git a/core/sql/exp/exp_datetime.h b/core/sql/exp/exp_datetime.h
index 8f6fa1b..17123b8 100644
--- a/core/sql/exp/exp_datetime.h
+++ b/core/sql/exp/exp_datetime.h
@@ -84,7 +84,8 @@ public:
DATETIME_FORMAT_TS7, // MM/DD/YYYY HH24:MI:SS
DATETIME_FORMAT_TS8, // DD-MON-YYYY HH:MI:SS
DATETIME_FORMAT_TS9, // MONTH DD, YYYY, HH:MI AM|PM
- DATETIME_FORMAT_MAX_TS = DATETIME_FORMAT_TS9,
+ DATETIME_FORMAT_TS10, // DD.MM.YYYY HH24:MI:SS
+ DATETIME_FORMAT_MAX_TS = DATETIME_FORMAT_TS10,
DATETIME_FORMAT_MAX = DATETIME_FORMAT_MAX_TS,
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1c52a1b4/core/sql/exp/exp_eval.cpp
----------------------------------------------------------------------
diff --git a/core/sql/exp/exp_eval.cpp b/core/sql/exp/exp_eval.cpp
index c0a4a10..d841463 100644
--- a/core/sql/exp/exp_eval.cpp
+++ b/core/sql/exp/exp_eval.cpp
@@ -4210,7 +4210,7 @@ ex_expr::exp_return_type ex_expr::evalPCode(PCodeBinary* pCode32,
Int16 attrVCIndLen = (Int16)comboPtr1[1];
DEF_ASSIGN(Int16, alignment, 6);
- DEF_ASSIGN(Int16, rowLength, 7);
+ DEF_ASSIGN(Int32, rowLength, 7);
UInt32 copyLength = 0;
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1c52a1b4/core/sql/exp/exp_function.h
----------------------------------------------------------------------
diff --git a/core/sql/exp/exp_function.h b/core/sql/exp/exp_function.h
index 1c183f6..589975e 100644
--- a/core/sql/exp/exp_function.h
+++ b/core/sql/exp/exp_function.h
@@ -2377,6 +2377,8 @@ public:
Space * space, Int32 dateformat);
NA_EIDPROC ex_function_dateformat();
+ void displayContents(Space * space, const char * displayStr,
+ Int32 clauseNum, char * constsArea);
NA_EIDPROC inline Int32 getDateFormat() const { return dateformat_; }
NA_EIDPROC ex_expr::exp_return_type eval(char *op_data[], CollHeap*,
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1c52a1b4/core/sql/generator/GenPreCode.cpp
----------------------------------------------------------------------
diff --git a/core/sql/generator/GenPreCode.cpp b/core/sql/generator/GenPreCode.cpp
index 66ae65f..daf5d1c 100644
--- a/core/sql/generator/GenPreCode.cpp
+++ b/core/sql/generator/GenPreCode.cpp
@@ -2855,6 +2855,7 @@ short DDLExpr::ddlXnsInfo(NABoolean &isDDLxn, NABoolean &xnCanBeStarted)
if ((ddlNode && ddlNode->castToStmtDDLNode() &&
ddlNode->castToStmtDDLNode()->ddlXns()) &&
((ddlNode->getOperatorType() == DDL_CLEANUP_OBJECTS) ||
+ (ddlNode->getOperatorType() == DDL_DROP_SCHEMA) ||
(ddlNode->getOperatorType() == DDL_ALTER_TABLE_DROP_COLUMN) ||
(ddlNode->getOperatorType() == DDL_ALTER_TABLE_ALTER_COLUMN_DATATYPE)))
{
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1c52a1b4/core/sql/generator/GenRelScan.cpp
----------------------------------------------------------------------
diff --git a/core/sql/generator/GenRelScan.cpp b/core/sql/generator/GenRelScan.cpp
index 0f2d40c..2783e83 100644
--- a/core/sql/generator/GenRelScan.cpp
+++ b/core/sql/generator/GenRelScan.cpp
@@ -194,9 +194,10 @@ short FileScan::codeGen(Generator * generator)
}
int HbaseAccess::createAsciiColAndCastExpr(Generator * generator,
- const NAType &givenType,
- ItemExpr *&asciiValue,
- ItemExpr *&castValue)
+ const NAType &givenType,
+ ItemExpr *&asciiValue,
+ ItemExpr *&castValue,
+ NABoolean srcIsInt32Varchar)
{
int result = 0;
asciiValue = NULL;
@@ -216,41 +217,56 @@ int HbaseAccess::createAsciiColAndCastExpr(Generator * generator,
}
if (newGivenType->getTypeQualifier() == NA_CHARACTER_TYPE &&
- (CmpCommon::getDefaultString(HIVE_FILE_CHARSET) == "GBK" || CmpCommon::getDefaultString(HIVE_FILE_CHARSET) == "gbk") && CmpCommon::getDefaultString(HIVE_DEFAULT_CHARSET) == "UTF8" )
- needTranslate = TRUE;
-
+ (CmpCommon::getDefaultString(HIVE_FILE_CHARSET) == "GBK" ||
+ CmpCommon::getDefaultString(HIVE_FILE_CHARSET) == "gbk")
+ && CmpCommon::getDefaultString(HIVE_DEFAULT_CHARSET) == "UTF8" )
+ needTranslate = TRUE;
+
// source ascii row is a varchar where the data is a pointer to the source data
// in the hdfs buffer.
NAType *asciiType = NULL;
if (DFS2REC::isDoubleCharacter(newGivenType->getFSDatatype()))
- {
- asciiType = new (h) SQLVarChar(sizeof(Int64)/2, newGivenType->supportsSQLnull(),
- FALSE, FALSE, newGivenType->getCharSet());
- }
+ {
+ asciiType =
+ new (h) SQLVarChar(sizeof(Int64)/2, newGivenType->supportsSQLnull(),
+ FALSE, FALSE, newGivenType->getCharSet(),
+ CharInfo::DefaultCollation,
+ CharInfo::COERCIBLE,
+ CharInfo::UnknownCharSet,
+ (srcIsInt32Varchar ? sizeof(Int32) : 0));
+ }
// set the source charset to GBK if HIVE_FILE_CHARSET is set
// HIVE_FILE_CHARSET can only be empty or GBK
else if ( needTranslate == TRUE )
- {
- asciiType = new (h) SQLVarChar(sizeof(Int64), newGivenType->supportsSQLnull(),
- FALSE, FALSE, CharInfo::GBK);
- }
+ {
+ asciiType =
+ new (h) SQLVarChar(sizeof(Int64), newGivenType->supportsSQLnull(),
+ FALSE, FALSE, CharInfo::GBK,
+ CharInfo::DefaultCollation,
+ CharInfo::COERCIBLE,
+ CharInfo::UnknownCharSet,
+ (srcIsInt32Varchar ? sizeof(Int32) : 0));
+ }
else
- asciiType = new (h) SQLVarChar(sizeof(Int64), newGivenType->supportsSQLnull());
- if (asciiType)
{
- asciiValue = new (h) NATypeToItem(asciiType->newCopy(h));
- castValue = new(h) Cast(asciiValue, newGivenType);
- if (castValue)
- {
- ((Cast*)castValue)->setSrcIsVarcharPtr(TRUE);
-
- if (newGivenType->getTypeQualifier() == NA_INTERVAL_TYPE)
- ((Cast*)castValue)->setAllowSignInInterval(TRUE);
- }
-
+ asciiType =
+ new (h) SQLVarChar(sizeof(Int64), newGivenType->supportsSQLnull(),
+ FALSE, FALSE,
+ CharInfo::DefaultCharSet,
+ CharInfo::DefaultCollation,
+ CharInfo::COERCIBLE,
+ CharInfo::UnknownCharSet,
+ (srcIsInt32Varchar ? sizeof(Int32) : 0));
}
+ asciiValue = new (h) NATypeToItem(asciiType->newCopy(h));
+ castValue = new(h) Cast(asciiValue, newGivenType);
+ ((Cast*)castValue)->setSrcIsVarcharPtr(TRUE);
+
+ if (newGivenType->getTypeQualifier() == NA_INTERVAL_TYPE)
+ ((Cast*)castValue)->setAllowSignInInterval(TRUE);
+
if (castValue && asciiValue)
result = 1;
@@ -839,9 +855,10 @@ short FileScan::codeGenForHive(Generator * generator)
res = HbaseAccess::createAsciiColAndCastExpr(
generator, // for heap
- givenType, // [IN] Actual type of HDFS column
- asciiValue, // [OUT] Returned expression for ascii rep.
- castValue // [OUT] Returned expression for binary rep.
+ givenType, // [IN] Actual type of HDFS column
+ asciiValue, // [OUT] Returned expression for ascii rep.
+ castValue, // [OUT] Returned expression for binary rep.
+ TRUE // max src data len is sizeof(Int32)
);
GenAssert(res == 1 && asciiValue != NULL && castValue != NULL,
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1c52a1b4/core/sql/optimizer/BindItemExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/BindItemExpr.cpp b/core/sql/optimizer/BindItemExpr.cpp
index f348896..2e4d8e0 100644
--- a/core/sql/optimizer/BindItemExpr.cpp
+++ b/core/sql/optimizer/BindItemExpr.cpp
@@ -4181,9 +4181,9 @@ ItemExpr * DateFormat::bindNode(BindWA * bindWA)
if (frmt_ == ExpDatetime::DATETIME_FORMAT_DEFAULT)
frmt_ = ExpDatetime::DATETIME_FORMAT_TS3;// YYYY-MM-DD HH24:MI:SS
else if (frmt_ == ExpDatetime::DATETIME_FORMAT_USA)
- frmt_ = ExpDatetime::DATETIME_FORMAT_TS7;// MM/DD/YYYY HH24:MI:SS
- else
- frmt_ = ExpDatetime::DATETIME_FORMAT_TS2;// DD.MM.YYYY:HH24:MI:SS
+ frmt_ = ExpDatetime::DATETIME_FORMAT_TS7;// MM/DD/YYYY HH24:MI:SS AM|PM
+ else if (frmt_ == ExpDatetime::DATETIME_FORMAT_EUROPEAN)
+ frmt_ = ExpDatetime::DATETIME_FORMAT_TS10;// DD.MM.YYYY HH24:MI:SS
}
}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1c52a1b4/core/sql/optimizer/RelScan.h
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/RelScan.h b/core/sql/optimizer/RelScan.h
index cc69a69..6c02456 100644
--- a/core/sql/optimizer/RelScan.h
+++ b/core/sql/optimizer/RelScan.h
@@ -1350,9 +1350,10 @@ public:
static int createAsciiColAndCastExpr(Generator * generator,
const NAType &givenType,
ItemExpr *&asciiValue,
- ItemExpr *&castValue);
+ ItemExpr *&castValue,
+ NABoolean srcIsInt32Varchar = FALSE);
- static int createAsciiColAndCastExpr2(Generator * generator,
+ static int createAsciiColAndCastExpr2(Generator * generator,
ItemExpr * colNode,
const NAType &givenType,
ItemExpr *&asciiValue,
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1c52a1b4/core/sql/regress/compGeneral/TEST004
----------------------------------------------------------------------
diff --git a/core/sql/regress/compGeneral/TEST004 b/core/sql/regress/compGeneral/TEST004
index d3e465a..caf0794 100644
--- a/core/sql/regress/compGeneral/TEST004
+++ b/core/sql/regress/compGeneral/TEST004
@@ -31,7 +31,6 @@
#ifndef SEABASE_REGRESS
set schema $$TEST_CATALOG$$.sch;
#else
-cqd call_embedded_arkcmp 'OFF';
cqd seabase_volatile_tables 'ON';
set schema $$TEST_CATALOG$$.sch;
#endif
@@ -57,7 +56,8 @@ drop table "t4tab";
drop table "SCH.T4TAB";
drop table t4tab;
drop table t4ttt cascade;
-drop schema "t4sch";
+
+drop schema "t4sch" cascade;
drop table compgeneral.v_t1;
drop table compgeneral.v_t2;
@@ -857,3 +857,8 @@ explain options 'f' st1;
log;
obey test004(clean_up);
+--set parserflags 131072;
+--select object_name from "_MD_".objects where schema_name like 'VOLATILE_SCHEMA%';
+--drop implicit volatile schema cleanup cascade;
+
+
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1c52a1b4/core/sql/regress/executor/EXPECTED140
----------------------------------------------------------------------
diff --git a/core/sql/regress/executor/EXPECTED140 b/core/sql/regress/executor/EXPECTED140
index d31cd57..ae9f0ae 100644
--- a/core/sql/regress/executor/EXPECTED140
+++ b/core/sql/regress/executor/EXPECTED140
@@ -985,7 +985,6 @@ DESCRIPTION
HBASE_FILTER_PREDS ..... 2
TRAF_ALIGNED_ROW_FORMAT OFF
TRAF_INDEX_CREATE_OPT ON
- DDL_TRANSACTIONS ....... ON
SCHEMA ................. TRAFODION.SCH
HBASE_SMALL_SCANNER .... OFF
PARALLEL_NUM_ESPS ...... 1
@@ -1100,7 +1099,6 @@ DESCRIPTION
HBASE_FILTER_PREDS ..... 2
TRAF_ALIGNED_ROW_FORMAT OFF
TRAF_INDEX_CREATE_OPT ON
- DDL_TRANSACTIONS ....... ON
SCHEMA ................. TRAFODION.SCH
HBASE_SMALL_SCANNER .... OFF
PARALLEL_NUM_ESPS ...... 1
@@ -1223,7 +1221,6 @@ DESCRIPTION
HBASE_FILTER_PREDS ..... 2
TRAF_ALIGNED_ROW_FORMAT OFF
TRAF_INDEX_CREATE_OPT ON
- DDL_TRANSACTIONS ....... ON
SCHEMA ................. TRAFODION.SCH
GENERATE_EXPLAIN ....... ON
ObjectUIDs ............. 2948826545036618945
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1c52a1b4/core/sql/regress/seabase/EXPECTED030
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/EXPECTED030 b/core/sql/regress/seabase/EXPECTED030
index 94b6790..ebdc227 100644
--- a/core/sql/regress/seabase/EXPECTED030
+++ b/core/sql/regress/seabase/EXPECTED030
@@ -463,7 +463,7 @@ March 01, 2016, 10:11:12
(EXPR)
-----------------------
-01.03.2016:10:11:12.123
+01.03.2016 10:11:12.123
--- 1 row(s) selected.
>>select dateformat(timestamp '2016-03-01 10:11:12.12', usa) from (values(1)) x(a);
@@ -474,6 +474,22 @@ March 01, 2016, 10:11:12
03/01/2016 10:11:12.12 AM
--- 1 row(s) selected.
+>>select dateformat(timestamp '2016-03-01 20:11:12.12', usa) from (values(1)) x(a);
+
+(EXPR)
+-------------------------
+
+03/01/2016 08:11:12.12 PM
+
+--- 1 row(s) selected.
+>>select cast(DATEFORMAT (TIMESTAMP '1990-06-11 07:00:09.00', USA) as char(30)) from (values (1)) x(a);
+
+(EXPR)
+------------------------------
+
+06/11/1990 07:00:09.00 AM
+
+--- 1 row(s) selected.
>>
>>drop table if exists t030t1;
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1c52a1b4/core/sql/regress/seabase/TEST030
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/TEST030 b/core/sql/regress/seabase/TEST030
index aff9c7c..abe663a 100644
--- a/core/sql/regress/seabase/TEST030
+++ b/core/sql/regress/seabase/TEST030
@@ -86,6 +86,8 @@ select dateformat(timestamp '2016-03-01 10:11:12.1', default) from (values(1)) x
select dateformat(timestamp '2016-03-01 10:11:12', usa) from (values(1)) x(a);
select dateformat(timestamp '2016-03-01 10:11:12.123', european) from (values(1)) x(a);
select dateformat(timestamp '2016-03-01 10:11:12.12', usa) from (values(1)) x(a);
+select dateformat(timestamp '2016-03-01 20:11:12.12', usa) from (values(1)) x(a);
+select cast(DATEFORMAT (TIMESTAMP '1990-06-11 07:00:09.00', USA) as char(30)) from (values (1)) x(a);
drop table if exists t030t1;
create table t030t1 (a date, b char(30), c varchar(30));
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1c52a1b4/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp b/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp
index d37306b..967b534 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp
@@ -444,11 +444,14 @@ void CmpSeabaseDDL::dropSeabaseSchema(StmtDDLDropSchema * dropSchemaNode)
int32_t length = 0;
int32_t rowCount = 0;
bool someObjectsCouldNotBeDropped = false;
+ char errorObjs[1000];
Queue * objectsQueue = NULL;
Queue * otherObjectsQueue = NULL;
NABoolean dirtiedMetadata = FALSE;
+ errorObjs[0] = 0;
+
Int64 schemaUID = getObjectTypeandOwner(&cliInterface,catName.data(),schName.data(),
SEABASE_SCHEMA_OBJECTNAME,objectType,schemaOwnerID);
@@ -540,25 +543,6 @@ void CmpSeabaseDDL::dropSeabaseSchema(StmtDDLDropSchema * dropSchemaNode)
}
}
-#ifdef __ignore
- // Drop histogram tables first
- objectsQueue->position();
- for (size_t i = 0; i < objectsQueue->numEntries(); i++)
- {
- OutputInfo * vi = (OutputInfo*)objectsQueue->getNext();
- NAString objName = vi->get(0);
-
- if (isHistogramTable(objName))
- {
- dirtiedMetadata = TRUE;
- if (dropOneTable(cliInterface,(char*)catName.data(),
- (char*)schName.data(),(char*)objName.data(),
- isVolatile , FALSE,dropSchemaNode->ddlXns()))
- someObjectsCouldNotBeDropped = true;
- }
- }
-#endif
-
// Drop procedures (SPJs), UDFs (functions), and views
objectsQueue->position();
for (int idx = 0; idx < objectsQueue->numEntries(); idx++)
@@ -632,7 +616,11 @@ void CmpSeabaseDDL::dropSeabaseSchema(StmtDDLDropSchema * dropSchemaNode)
cliRC = cliInterface.executeImmediate(buf);
if (cliRC < 0 && cliRC != -CAT_OBJECT_DOES_NOT_EXIST_IN_TRAFODION)
- someObjectsCouldNotBeDropped = true;
+ {
+ strcat(errorObjs, objectTypeString.data());
+ strcat(errorObjs, " ");
+ someObjectsCouldNotBeDropped = true;
+ }
}
// Drop libraries in the schema
@@ -654,7 +642,12 @@ void CmpSeabaseDDL::dropSeabaseSchema(StmtDDLDropSchema * dropSchemaNode)
cliRC = cliInterface.executeImmediate(buf);
if (cliRC < 0 && cliRC != -CAT_OBJECT_DOES_NOT_EXIST_IN_TRAFODION)
- someObjectsCouldNotBeDropped = true;
+ {
+ strcat(errorObjs, objName);
+ strcat(errorObjs, " ");
+
+ someObjectsCouldNotBeDropped = true;
+ }
}
}
@@ -680,7 +673,12 @@ void CmpSeabaseDDL::dropSeabaseSchema(StmtDDLDropSchema * dropSchemaNode)
if (dropOneTable(cliInterface,(char*)catName.data(),
(char*)schName.data(),(char*)objName.data(),
isVolatile, FALSE,dropSchemaNode->ddlXns()))
- someObjectsCouldNotBeDropped = true;
+ {
+ strcat(errorObjs, objName.data());
+ strcat(errorObjs, " ");
+
+ someObjectsCouldNotBeDropped = true;
+ }
}
}
}
@@ -710,7 +708,12 @@ void CmpSeabaseDDL::dropSeabaseSchema(StmtDDLDropSchema * dropSchemaNode)
if (dropOneTable(cliInterface,(char*)catName.data(),
(char*)schName.data(),(char*)objName.data(),
isVolatile,TRUE, dropSchemaNode->ddlXns()))
- someObjectsCouldNotBeDropped = true;
+ {
+ strcat(errorObjs, objName.data());
+ strcat(errorObjs, " ");
+
+ someObjectsCouldNotBeDropped = true;
+ }
}
}
}
@@ -750,7 +753,12 @@ void CmpSeabaseDDL::dropSeabaseSchema(StmtDDLDropSchema * dropSchemaNode)
cliRC = cliInterface.executeImmediate(buf);
if (cliRC < 0 && cliRC != -CAT_OBJECT_DOES_NOT_EXIST_IN_TRAFODION)
- someObjectsCouldNotBeDropped = true;
+ {
+ strcat(errorObjs, objName);
+ strcat(errorObjs, " ");
+
+ someObjectsCouldNotBeDropped = true;
+ }
}
}
@@ -790,7 +798,12 @@ void CmpSeabaseDDL::dropSeabaseSchema(StmtDDLDropSchema * dropSchemaNode)
cliRC = cliInterface.executeImmediate(buf);
if (cliRC < 0 && cliRC != -CAT_OBJECT_DOES_NOT_EXIST_IN_TRAFODION)
- someObjectsCouldNotBeDropped = true;
+ {
+ strcat(errorObjs, objName);
+ strcat(errorObjs, " ");
+
+ someObjectsCouldNotBeDropped = true;
+ }
}
}
@@ -807,16 +820,33 @@ void CmpSeabaseDDL::dropSeabaseSchema(StmtDDLDropSchema * dropSchemaNode)
if (dropOneTable(cliInterface,(char*)catName.data(),
(char*)schName.data(),(char*)objName.data(),
isVolatile, FALSE, dropSchemaNode->ddlXns()))
- someObjectsCouldNotBeDropped = true;
+ {
+ strcat(errorObjs, objName.data());
+ strcat(errorObjs, " ");
+
+ someObjectsCouldNotBeDropped = true;
+ }
}
}
+ if (someObjectsCouldNotBeDropped)
+ {
+ NAString reason;
+ reason = "Reason: Some objects could not be dropped in schema "
+ + schName + ". ObjectsInSchema: "
+ + errorObjs;
+ *CmpCommon::diags() << DgSqlCode(-CAT_UNABLE_TO_DROP_SCHEMA)
+ << DgSchemaName(catName + "." + schName)
+ << DgString0(reason);
+ goto label_error;
+ }
+
// For volatile schemas, sometimes only the objects get dropped.
// If the dropObjectsOnly flag is set, just exit now, we are done.
if (dropSchemaNode->dropObjectsOnly())
return;
- // Verify all objects in the schema have been dropped.
+ // Verify all objects in the schema have been dropped.
str_sprintf(query,"SELECT COUNT(*) "
"FROM %s.\"%s\".%s "
"WHERE catalog_name = '%s' AND schema_name = '%s' AND "
@@ -834,13 +864,43 @@ void CmpSeabaseDDL::dropSeabaseSchema(StmtDDLDropSchema * dropSchemaNode)
}
if (rowCount > 0)
- {
- CmpCommon::diags()->clear();
-
- *CmpCommon::diags() << DgSqlCode(-CAT_UNABLE_TO_DROP_SCHEMA)
- << DgSchemaName(catName + "." + schName);
- goto label_error;
- }
+ {
+ CmpCommon::diags()->clear();
+
+ str_sprintf(query,"SELECT TRIM(object_name) "
+ "FROM %s.\"%s\".%s "
+ "WHERE catalog_name = '%s' AND schema_name = '%s' AND "
+ "object_name <> '"SEABASE_SCHEMA_OBJECTNAME"' AND "
+ "object_type <> 'PK' "
+ "FOR READ COMMITTED ACCESS",
+ getSystemCatalog(),SEABASE_MD_SCHEMA,SEABASE_OBJECTS,
+ (char*)catName.data(),(char*)schName.data());
+
+ cliRC = cliInterface.fetchAllRows(objectsQueue, query, 0, FALSE, FALSE, TRUE);
+ if (cliRC < 0)
+ {
+ cliInterface.retrieveSQLDiagnostics(CmpCommon::diags());
+ goto label_error;
+ }
+
+ for (int i = 0; i < objectsQueue->numEntries(); i++)
+ {
+ OutputInfo * vi = (OutputInfo*)objectsQueue->getNext();
+ NAString objName = vi->get(0);
+
+ strcat(errorObjs, objName.data());
+ strcat(errorObjs, " ");
+ }
+
+ NAString reason;
+ reason = "Reason: schema "
+ + schName + " is not empty. ObjectsInSchema: "
+ + errorObjs;
+ *CmpCommon::diags() << DgSqlCode(-CAT_UNABLE_TO_DROP_SCHEMA)
+ << DgSchemaName(catName + "." + schName)
+ << DgString0(reason);
+ goto label_error;
+ }
// After all objects in the schema have been dropped, drop the schema object itself.
@@ -855,8 +915,12 @@ void CmpSeabaseDDL::dropSeabaseSchema(StmtDDLDropSchema * dropSchemaNode)
cliRC = cliInterface.executeImmediate(buf);
if (cliRC < 0 && cliRC != -CAT_OBJECT_DOES_NOT_EXIST_IN_TRAFODION)
{
+ NAString reason;
+ reason = "Reason: Delete of object " +
+ NAString(SEABASE_SCHEMA_OBJECTNAME) + " failed.";
*CmpCommon::diags() << DgSqlCode(-CAT_UNABLE_TO_DROP_SCHEMA)
- << DgSchemaName(catName + "." + schName);
+ << DgSchemaName(catName + "." + schName)
+ << DgString0(reason);
goto label_error;
}