You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafodion.apache.org by db...@apache.org on 2016/07/29 21:44:33 UTC
[1/2] incubator-trafodion git commit: [TRAFODION-2131] Fix USTATS
cores + some other issues
Repository: incubator-trafodion
Updated Branches:
refs/heads/master c22962ca0 -> 5ee3cb396
[TRAFODION-2131] Fix USTATS cores + some other issues
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/ea655127
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/ea655127
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/ea655127
Branch: refs/heads/master
Commit: ea655127dbbce1447cae5e27664fd44252c7c5b8
Parents: 5cc5945
Author: Dave Birdsall <db...@apache.org>
Authored: Thu Jul 28 21:05:43 2016 +0000
Committer: Dave Birdsall <db...@apache.org>
Committed: Thu Jul 28 21:05:43 2016 +0000
----------------------------------------------------------------------
core/sql/generator/GenExpGenerator.cpp | 34 ++++++++++++++++++++---------
core/sql/ustat/hs_cli.cpp | 5 +++++
core/sql/ustat/hs_globals.cpp | 32 +++++++++++++++++++++++++++
core/sql/ustat/hs_update.cpp | 14 ++++++++++++
4 files changed, 75 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ea655127/core/sql/generator/GenExpGenerator.cpp
----------------------------------------------------------------------
diff --git a/core/sql/generator/GenExpGenerator.cpp b/core/sql/generator/GenExpGenerator.cpp
index bfdc65a..2be4c8b 100644
--- a/core/sql/generator/GenExpGenerator.cpp
+++ b/core/sql/generator/GenExpGenerator.cpp
@@ -848,19 +848,33 @@ short ExpGenerator::handleUnsupportedCast(Cast * castNode)
if ((srcFsType == REC_BIN8_SIGNED) ||
(srcFsType == REC_BIN8_UNSIGNED) ||
(tgtFsType == REC_BIN8_SIGNED) ||
- (tgtFsType == REC_BIN8_UNSIGNED))
+ (tgtFsType == REC_BIN8_UNSIGNED) ||
+ (DFS2REC::isInterval(srcFsType)) ||
+ (DFS2REC::isInterval(tgtFsType)))
{
// add a Cast node to convert from/to tinyint to/from small int.
- const NumericType &srcNum = (NumericType&)srcNAType;
- NumericType * newType;
- if (srcNum.getScale() == 0)
- newType = new (generator->wHeap())
- SQLSmall(NOT srcNum.isUnsigned(),
- srcNAType.supportsSQLnull());
+ NumericType * newType = NULL;
+ if (DFS2REC::isInterval(srcFsType))
+ {
+ const IntervalType &srcInt = (IntervalType&)srcNAType;
+ newType = new (generator->wHeap())
+ SQLNumeric(sizeof(short), srcInt.getTotalPrecision(),
+ srcInt.getFractionPrecision(),
+ TRUE, srcNAType.supportsSQLnull());
+ }
else
- newType = new (generator->wHeap())
- SQLNumeric(sizeof(short), srcNum.getPrecision(), srcNum.getScale(),
- NOT srcNum.isUnsigned(), srcNAType.supportsSQLnull());
+ {
+ const NumericType &srcNum = (NumericType&)srcNAType;
+ if (srcNum.getScale() == 0)
+ newType = new (generator->wHeap())
+ SQLSmall(NOT srcNum.isUnsigned(),
+ srcNAType.supportsSQLnull());
+ else
+ newType = new (generator->wHeap())
+ SQLNumeric(sizeof(short), srcNum.getPrecision(), srcNum.getScale(),
+ NOT srcNum.isUnsigned(), srcNAType.supportsSQLnull());
+ }
+
ItemExpr * newChild =
new (generator->wHeap())
Cast(castNode->child(0), newType);
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ea655127/core/sql/ustat/hs_cli.cpp
----------------------------------------------------------------------
diff --git a/core/sql/ustat/hs_cli.cpp b/core/sql/ustat/hs_cli.cpp
index d65eb0e..9e19a63 100644
--- a/core/sql/ustat/hs_cli.cpp
+++ b/core/sql/ustat/hs_cli.cpp
@@ -50,6 +50,7 @@
#include "CharType.h"
#include "DatetimeType.h"
#include "IntervalType.h"
+#include "MiscType.h"
#include "Int64.h"
#include "cli_stdh.h"
#include "sql_id.h"
@@ -3375,6 +3376,10 @@ Lng32 HSCursor::buildNAType()
break;
+ case REC_BOOLEAN:
+ type = new(heap_) SQLBooleanNative(nullflag,heap_);
+ break;
+
default:
HSFuncMergeDiags(- UERR_UNSUPPORTED_DATATYPE);
retcode_ = -1;
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ea655127/core/sql/ustat/hs_globals.cpp
----------------------------------------------------------------------
diff --git a/core/sql/ustat/hs_globals.cpp b/core/sql/ustat/hs_globals.cpp
index 32654db..aa1c860 100644
--- a/core/sql/ustat/hs_globals.cpp
+++ b/core/sql/ustat/hs_globals.cpp
@@ -291,6 +291,7 @@ Lng32 MCWrapper::setupMCColumnIterator (HSColGroupStruct *group, MCIterator** it
iter[currentLoc] = new (STMTHEAP) MCNonCharIterator<char>((char *)group->mcis_data);
break;
+ case REC_BOOLEAN:
case REC_BIN8_UNSIGNED:
iter[currentLoc] = new (STMTHEAP) MCNonCharIterator<unsigned char>((unsigned char *)group->mcis_data);
break;
@@ -4867,6 +4868,7 @@ void HSGlobalsClass::getMemoryRequirementsForOneGroup(HSColGroupStruct* group, I
switch (group->ISdatatype)
{
+ case REC_BOOLEAN:
case REC_BIN8_SIGNED:
case REC_BIN8_UNSIGNED:
elementSize = 1;
@@ -7067,6 +7069,7 @@ Int32 HSGlobalsClass::processIUSColumn(HSColGroupStruct* smplGroup,
case REC_BIN8_SIGNED:
return processIUSColumn((Int8*)smplGroup->data, L"%hd", smplGroup, delGroup, insGroup);
break;
+ case REC_BOOLEAN:
case REC_BIN8_UNSIGNED:
return processIUSColumn((UInt8*)smplGroup->data, L"%hu", smplGroup, delGroup, insGroup);
break;
@@ -10048,6 +10051,7 @@ Lng32 HSGlobalsClass::processInternalSortNulls(Lng32 rowsRead, HSColGroupStruct
processNullsForColumn(group, rowsRead, (Int8*)NULL);
break;
+ case REC_BOOLEAN:
case REC_BIN8_UNSIGNED:
processNullsForColumn(group, rowsRead, (UInt8*)NULL);
break;
@@ -10219,6 +10223,7 @@ bool isInternalSortType(HSColumnStruct &col)
switch (col.datatype)
{
+ case REC_BOOLEAN:
case REC_BIN8_SIGNED:
case REC_BIN8_UNSIGNED:
case REC_BIN16_SIGNED:
@@ -10937,6 +10942,7 @@ Lng32 doSort(HSColGroupStruct *group)
(Int8*)group->nextData - (Int8*)group->data - 1);
break;
+ case REC_BOOLEAN:
case REC_BIN8_UNSIGNED:
quicksort((UInt8*)group->data, 0,
(UInt8*)group->nextData - (UInt8*)group->data - 1);
@@ -11431,6 +11437,7 @@ Lng32 HSGlobalsClass::createStatsForColumn(HSColGroupStruct *group, Int64 rowsAl
createHistogram(group, intCount, sampleRowCount, samplingUsed, (Int8*)NULL);
break;
+ case REC_BOOLEAN:
case REC_BIN8_UNSIGNED:
createHistogram(group, intCount, sampleRowCount, samplingUsed, (UInt8*)NULL);
break;
@@ -12692,6 +12699,7 @@ Lng32 HSGlobalsClass::mergeDatasetsForIUS(
return mergeDatasetsForIUS((Int8*)smplGroup->data, (Int8*)NULL,
smplGroup, smplrows, delGroup, delrows, insGroup, insrows);
break;
+ case REC_BOOLEAN:
case REC_BIN8_UNSIGNED:
return mergeDatasetsForIUS((UInt8*)smplGroup->data, (UInt8*)NULL,
smplGroup, smplrows, delGroup, delrows, insGroup, insrows);
@@ -13350,6 +13358,15 @@ Int32 copyValue(Int64 value, char *valueBuff, const HSColumnStruct &colDesc, sho
(Int32)(value % 60)); // seconds
break;
+ case REC_BOOLEAN:
+ {
+ if (value)
+ strcpy(valueBuff,"TRUE");
+ else
+ strcpy(valueBuff,"FALSE");
+ }
+ break;
+
#pragma warning(default:4146)
// LCOV_EXCL_START :rfi
@@ -13657,6 +13674,7 @@ Lng32 setBufferValue(MCWrapper& value,
case REC_BIN8_SIGNED:
retcode = copyValue(*((MCNonCharIterator<Int8>*)(value.allCols_[i]))->getContent(value.index_), valueBuff, mgroup->colSet[i], len);
break;
+ case REC_BOOLEAN:
case REC_BIN8_UNSIGNED:
retcode = copyValue(*((MCNonCharIterator<UInt8>*)(value.allCols_[i]))->getContent(value.index_), valueBuff, mgroup->colSet[i], len);
break;
@@ -15035,6 +15053,19 @@ NAString HSColGroupStruct::generateTextForColumnCast()
if(isMCGroup)
textForColumnCast.append(replaceFuncLastPart);
}
+ else if (colSet[i].datatype == REC_BOOLEAN)
+ {
+ // CAST of boolean to VARCHAR UCS2 isn't supported in the
+ // engine yet (you get error 8414 at run-time if you try it),
+ // so work around this by CASTing to ISO88591 then CASTing
+ // to UCS2. Once the engine supports this cast we can
+ // delete this code and just use the "else" case below.
+ textForColumnCast.append("TRIM(TRAILING FROM CAST (CAST (");
+ textForColumnCast.append(columnName.data());
+ textForColumnCast.append(" AS CHAR(10)) AS VARCHAR(");
+ textForColumnCast.append(LongToNAString(maxCharBoundaryLen));
+ textForColumnCast.append(") CHARACTER SET UCS2))");
+ }
else
{
//CAST ALL OTHER DATATYPES TO UNICODE
@@ -15514,6 +15545,7 @@ Lng32 HSGlobalsClass::processFastStatsBatch(CollIndex numCols, HSColGroupStruct*
group->fastStatsHist = new(STMTHEAP) FastStatsHist<Int8>(group, cbf);
break;
+ case REC_BOOLEAN:
case REC_BIN8_UNSIGNED:
group->fastStatsHist = new(STMTHEAP) FastStatsHist<UInt8>(group, cbf);
break;
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ea655127/core/sql/ustat/hs_update.cpp
----------------------------------------------------------------------
diff --git a/core/sql/ustat/hs_update.cpp b/core/sql/ustat/hs_update.cpp
index 29f054b..e8ca28e 100644
--- a/core/sql/ustat/hs_update.cpp
+++ b/core/sql/ustat/hs_update.cpp
@@ -294,6 +294,20 @@ Lng32 UpdateStats(char *input, NABoolean requestedByCompiler)
retcode = HSFuncExecQuery("CONTROL QUERY DEFAULT WMS_QUERY_MONITORING 'ON'");
HSExitIfError(retcode);
}
+
+ // Set some CQDs to allow us to process TINYINT, BOOLEAN and LARGEINT UNSIGNED
+ // columns correctly. Without these, when we read data into memory for internal
+ // sort, there is a mismatch between how much space we think a column value will
+ // take and how much the Executor expects, and we get buffer overruns. (See
+ // JIRA TRAFODION-2131.) Someday all clients will support these datatypes and
+ // these CQDs can go away.
+ retcode = HSFuncExecQuery("CONTROL QUERY DEFAULT TRAF_TINYINT_RETURN_VALUES 'ON'");
+ HSExitIfError(retcode);
+ retcode = HSFuncExecQuery("CONTROL QUERY DEFAULT TRAF_BOOLEAN_IO 'ON'");
+ HSExitIfError(retcode);
+ retcode = HSFuncExecQuery("CONTROL QUERY DEFAULT TRAF_LARGEINT_UNSIGNED_IO 'ON'");
+ HSExitIfError(retcode);
+
LM->StopTimer();
LM->StartTimer("Parse statement");
[2/2] incubator-trafodion git commit: Merge [TRAFODION-2131] PR 626
Fix UPDATE STATS cores + some other issues
Posted by db...@apache.org.
Merge [TRAFODION-2131] PR 626 Fix UPDATE STATS cores + some other issues
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/5ee3cb39
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/5ee3cb39
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/5ee3cb39
Branch: refs/heads/master
Commit: 5ee3cb39624e6c27fb7c681e60270635f025e259
Parents: c22962c ea65512
Author: Dave Birdsall <db...@apache.org>
Authored: Fri Jul 29 21:42:59 2016 +0000
Committer: Dave Birdsall <db...@apache.org>
Committed: Fri Jul 29 21:42:59 2016 +0000
----------------------------------------------------------------------
core/sql/generator/GenExpGenerator.cpp | 34 ++++++++++++++++++++---------
core/sql/ustat/hs_cli.cpp | 5 +++++
core/sql/ustat/hs_globals.cpp | 32 +++++++++++++++++++++++++++
core/sql/ustat/hs_update.cpp | 14 ++++++++++++
4 files changed, 75 insertions(+), 10 deletions(-)
----------------------------------------------------------------------