From 641bcde2ff2ece4bbc1ccca9b7452ec0d55312d8 Mon Sep 17 00:00:00 2001 From: "wenjun.zhu" Date: Sat, 29 Sep 2018 20:11:36 +0800 Subject: [PATCH 1/2] refactor the usage of setDiagsArea() --- core/sql/cli/CliExpExchange.cpp | 427 +++++++++++----------- core/sql/comexe/PartInputDataDesc.cpp | 4 +- core/sql/executor/ExCancel.cpp | 6 +- core/sql/executor/ExCompoundStmt.cpp | 24 +- core/sql/executor/ExExeUtil.h | 2 +- core/sql/executor/ExExeUtilCommon.cpp | 14 +- core/sql/executor/ExExeUtilExplain.cpp | 64 ++-- core/sql/executor/ExExeUtilLoad.cpp | 15 +- core/sql/executor/ExExeUtilMisc.cpp | 71 ++-- core/sql/executor/ExExplain.cpp | 98 ++--- core/sql/executor/ExFastTransport.cpp | 76 ++-- core/sql/executor/ExHbaseAccess.cpp | 67 ++-- core/sql/executor/ExHbaseIUD.cpp | 53 ++- core/sql/executor/ExHdfsScan.cpp | 369 +++++++++---------- core/sql/executor/ExPack.cpp | 3 +- core/sql/executor/ExPackedRows.cpp | 65 ++-- core/sql/executor/ExProbeCache.cpp | 20 +- core/sql/executor/ExSequence.cpp | 35 +- core/sql/executor/ExStats.cpp | 6 +- core/sql/executor/ExUdr.cpp | 24 +- core/sql/executor/ex_control.cpp | 32 +- core/sql/executor/ex_ddl.cpp | 61 ++-- core/sql/executor/ex_error.cpp | 10 +- core/sql/executor/ex_ex.cpp | 48 +-- core/sql/executor/ex_exe_stmt_globals.cpp | 4 +- core/sql/executor/ex_hash_grby.cpp | 2 +- core/sql/executor/ex_hashj.cpp | 28 +- core/sql/executor/ex_mj.cpp | 4 +- core/sql/executor/ex_onlj.cpp | 185 +++++----- core/sql/executor/ex_queue.cpp | 20 +- core/sql/executor/ex_queue.h | 29 +- core/sql/executor/ex_root.cpp | 26 +- core/sql/executor/ex_send_bottom.cpp | 12 +- core/sql/executor/ex_send_top.cpp | 10 +- core/sql/executor/ex_sort.cpp | 34 +- core/sql/executor/ex_split_bottom.cpp | 28 +- core/sql/executor/ex_split_top.cpp | 10 +- core/sql/executor/ex_stored_proc.cpp | 29 +- core/sql/executor/ex_transaction.cpp | 18 +- core/sql/executor/ex_tuple.cpp | 4 +- core/sql/executor/ex_tuple_flow.cpp | 114 +++--- core/sql/executor/ex_union.cpp | 60 +-- core/sql/exp/ExpAtp.h | 37 +- core/sql/exp/exp_eval.cpp | 187 +++++----- core/sql/optimizer/EncodedKeyValue.cpp | 8 +- core/sql/optimizer/ValueDesc.cpp | 3 +- 46 files changed, 1201 insertions(+), 1245 deletions(-) diff --git a/core/sql/cli/CliExpExchange.cpp b/core/sql/cli/CliExpExchange.cpp index 7e39da5a7d..091d1d79f3 100644 --- a/core/sql/cli/CliExpExchange.cpp +++ b/core/sql/cli/CliExpExchange.cpp @@ -1058,28 +1058,28 @@ InputOutputExpr::outputValues(atp_struct *atp, char * targetIndPtr = NULL; char * targetVCLen = NULL; short targetVCLenSize = 0; - + // Size of an entry of the indicator array Lng32 indSize; - + Long tempTarget = 0; - + char * dataPtr = 0; short entry = 0; - + NABoolean byPassCheck = output_desc->isDescTypeWide(); if (!byPassCheck && (getNumEntries() != output_desc->getUsedEntryCount()) && - (!output_desc->thereIsACompoundStatement())) + (!output_desc->thereIsACompoundStatement())) { ExRaiseSqlError(heap, &diagsArea, CLI_STMT_DESC_COUNT_MISMATCH); if (diagsArea != atp->getDiagsArea()) - atp->setDiagsArea(diagsArea); + atp->setDiagsAreax(diagsArea); return ex_expr::EXPR_ERROR; } - + // If bulk move has not been disabled before, then check to see if bulk - // move could be done. This is done by comparing attributes of the + // move could be done. This is done by comparing attributes of the // executor items and the descriptor entries. See method // Descriptor::checkBulkMoveStatus() for details on when bulk move will // be disabled. @@ -1243,7 +1243,7 @@ InputOutputExpr::outputValues(atp_struct *atp, } } } // switch atpIndex - + // For rowsets, here we extract the number of elements in it. This // only happens for the SELECT .. INTO clause if (source && sourceCompiledWithRowsets) { @@ -1263,19 +1263,19 @@ InputOutputExpr::outputValues(atp_struct *atp, &diagsArea) != ex_expr::EXPR_OK) { if (diagsArea != atp->getDiagsArea()) - atp->setDiagsArea(diagsArea); - + atp->setDiagsAreax(diagsArea); + return ex_expr::EXPR_ERROR; } - + // Increment the location for the next element. source += sizeof(Lng32); - - // The offsets for rowset SQLVarChar attributes are set as follows. - // offset_ points to the start of the rowset info followed by four bytes + + // The offsets for rowset SQLVarChar attributes are set as follows. + // offset_ points to the start of the rowset info followed by four bytes // of the rowset size. nullIndOffset_ (if nullIndicatorLength_ is not set - // to 0) points to (offset_+4). vcLenIndOffset_ (if vcIndicatorLength_ - // is not set to 0) points to (offset_+nullIndicatorLength_). The first + // to 0) points to (offset_+4). vcLenIndOffset_ (if vcIndicatorLength_ + // is not set to 0) points to (offset_+nullIndicatorLength_). The first // data value stars at (offset_+nullIndicatorLength_+vcIndicatorLength_) // or (offset_+vcIndicatorLength_) depending on whether nullIndicatorLength_ // is valid. @@ -1284,12 +1284,12 @@ InputOutputExpr::outputValues(atp_struct *atp, if (operand->getNullFlag()) { source += operand->getNullIndicatorLength(); } - - if (operand->getVCIndicatorLength() > 0) { - source += operand->getVCIndicatorLength(); + + if (operand->getVCIndicatorLength() > 0) { + source += operand->getVCIndicatorLength(); } //Now source points to the start of the first data value of the rowset. - + if (tempSource < 0) { tempSource = 1; } @@ -1472,15 +1472,15 @@ InputOutputExpr::outputValues(atp_struct *atp, ExRaiseSqlError(heap, &diagsArea, EXE_MISSING_INDICATOR_VARIABLE); if (diagsArea != atp->getDiagsArea()) - atp->setDiagsArea(diagsArea); + atp->setDiagsAreax(diagsArea); return ex_expr::EXPR_ERROR; } } } - + if (! nullMoved) { targetVarPtr = (char *)tempTarget; - + if (targetVarPtr) { // bound column. Move value to user area. target = targetVarPtr; @@ -1491,9 +1491,9 @@ InputOutputExpr::outputValues(atp_struct *atp, target = new (heap) char[targetLen + 10]; // 10 extra bytes should do realTarget = target; } - + Lng32 tempDataConversionErrorFlag = ex_conv_clause::CONV_RESULT_OK; - + if ((DFS2REC::isSQLVarChar(targetType)) || (DFS2REC::isLOB(targetType))) { targetVCLen = target; @@ -1530,12 +1530,12 @@ InputOutputExpr::outputValues(atp_struct *atp, if (NOT areCompatible(sourceType, targetType)) { if ((NOT skipTypeCheck()) || - ((restrictedSkipTypeCheck()) && + ((restrictedSkipTypeCheck()) && (NOT implicitConversionSupported(sourceType,targetType)))) { ExRaiseSqlError(heap, &diagsArea,EXE_CONVERT_NOT_SUPPORTED); if (diagsArea != atp->getDiagsArea()) - atp->setDiagsArea(diagsArea); + atp->setDiagsAreax(diagsArea); return ex_expr::EXPR_ERROR; } @@ -1543,22 +1543,22 @@ InputOutputExpr::outputValues(atp_struct *atp, } else { if ( DFS2REC::isAnyCharacter(sourceType) && NOT CharInfo::isAssignmentCompatible(targetCharSet, sourceCharSet) - ) + ) { ExRaiseSqlError(heap, &diagsArea, CLI_ASSIGN_INCOMPATIBLE_CHARSET); if (diagsArea != atp->getDiagsArea()) - atp->setDiagsArea(diagsArea); + atp->setDiagsAreax(diagsArea); - *diagsArea - << DgString0(CharInfo::getCharSetName((CharInfo::CharSet)targetCharSet)) - << DgString1(CharInfo::getCharSetName((CharInfo::CharSet)sourceCharSet)); + *diagsArea + << DgString0(CharInfo::getCharSetName((CharInfo::CharSet)targetCharSet)) + << DgString1(CharInfo::getCharSetName((CharInfo::CharSet)sourceCharSet)); return ex_expr::EXPR_ERROR; } } - + // if the target is REC_DECIMAL_LS and the source is NOT // REC_DECIMAL_LSE, convert the source to REC_DECIMAL_LSE // first. This conversion already took place during compilation @@ -1570,7 +1570,7 @@ InputOutputExpr::outputValues(atp_struct *atp, if ((targetType == REC_DECIMAL_LS) && (operand->getDatatype() != REC_DECIMAL_LSE) && (targetRowsetSize == 0)) { - + if ( source ) { intermediate = new (heap) char[targetLen - 1]; if (::convDoIt(source, @@ -1588,21 +1588,21 @@ InputOutputExpr::outputValues(atp_struct *atp, heap, &diagsArea) != ex_expr::EXPR_OK) { if (diagsArea != atp->getDiagsArea()) - atp->setDiagsArea(diagsArea); - + atp->setDiagsAreax(diagsArea); + NADELETEBASIC(intermediate, heap); if (! targetVarPtr) NADELETEBASIC(realTarget, heap); return ex_expr::EXPR_ERROR; }; - + source = intermediate; sourceLen = targetLen - 1; - } - + } + sourceType = REC_DECIMAL_LSE; } - + // 5/18/98: added to handle SJIS encoding charset case. // This is used in ODBC where the target character set is still // ASCII but the actual character set used is SJIS. @@ -1612,7 +1612,7 @@ InputOutputExpr::outputValues(atp_struct *atp, ) { - if ( targetCharSet == CharInfo::SJIS ) + if ( targetCharSet == CharInfo::SJIS) { switch ( targetType ) { case REC_BYTE_F_ASCII: @@ -1657,7 +1657,7 @@ InputOutputExpr::outputValues(atp_struct *atp, intermediate = new (heap) char[57]; else intermediate = new (heap) char[8]; - if ( source ) + if ( source ) { // convert to largeint if (convDoIt(source, @@ -1667,48 +1667,48 @@ InputOutputExpr::outputValues(atp_struct *atp, sourceScale, intermediate, (DFS2REC::isBigNum(sourceType) ? 57 : 8), - (DFS2REC::isBigNum(sourceType) + (DFS2REC::isBigNum(sourceType) ? REC_NUM_BIG_SIGNED : REC_BIN64_SIGNED), targetPrecision, targetScale, NULL, 0, heap, - &diagsArea) != ex_expr::EXPR_OK) + &diagsArea) != ex_expr::EXPR_OK) { if (diagsArea != atp->getDiagsArea()) - atp->setDiagsArea(diagsArea); - + atp->setDiagsAreax(diagsArea); + NADELETEBASIC(intermediate, heap); return ex_expr::EXPR_ERROR; } - + // scale it if (scaleDoIt( intermediate, (DFS2REC::isBigNum(sourceType) ? 57 : 8), - (DFS2REC::isBigNum(sourceType) + (DFS2REC::isBigNum(sourceType) ? REC_NUM_BIG_SIGNED : REC_BIN64_SIGNED), sourceScale, targetScale, sourceType, - heap) != ex_expr::EXPR_OK) + heap) != ex_expr::EXPR_OK) { ExRaiseSqlError(heap, &diagsArea, EXE_NUMERIC_OVERFLOW); if (diagsArea != atp->getDiagsArea()) - atp->setDiagsArea(diagsArea); - + atp->setDiagsAreax(diagsArea); + NADELETEBASIC(intermediate, heap); return ex_expr::EXPR_ERROR; } } - - // if the target is REC_DECIMAL_LS, convert the source to + + // if the target is REC_DECIMAL_LS, convert the source to // REC_DECIMAL_LSE first. Conversion to LS is currently // only supported if source is LSE. if (targetType == REC_DECIMAL_LS) { - if ( source ) + if ( source ) { char * intermediate2 = new (heap) char[targetLen - 1]; if (::convDoIt(intermediate, @@ -1726,38 +1726,38 @@ InputOutputExpr::outputValues(atp_struct *atp, heap, &diagsArea) != ex_expr::EXPR_OK) { if (diagsArea != atp->getDiagsArea()) - atp->setDiagsArea(diagsArea); - + atp->setDiagsAreax(diagsArea); + NADELETEBASIC(intermediate, heap); NADELETEBASIC(intermediate2, heap); return ex_expr::EXPR_ERROR; }; - + NADELETEBASIC(intermediate, heap); intermediate = intermediate2; sourceLen = targetLen - 1; } - + sourceType = REC_DECIMAL_LSE; } // targetType == REC_DECIMAL_LS else { sourceLen = (DFS2REC::isBigNum(sourceType) ? 57 : 8); - sourceType = (DFS2REC::isBigNum(sourceType) + sourceType = (DFS2REC::isBigNum(sourceType) ? REC_NUM_BIG_SIGNED : REC_BIN64_SIGNED); } - + if ( source ) source = intermediate; - + // no more scaling is to be done. sourceScale = 0; targetScale = 0; } // exact numeric with scaling - + // if incompatible conversions are to be done, - // and the target is REC_BYTE_V_ANSI, - // and the source is not a string type, convert the source to + // and the target is REC_BYTE_V_ANSI, + // and the source is not a string type, convert the source to // REC_BYTE_V_ASCII first. Conversion to V_ANSI is currently // only supported if source is a string type. if (implicitConversion) @@ -1766,7 +1766,7 @@ InputOutputExpr::outputValues(atp_struct *atp, ((sourceType < REC_MIN_CHARACTER) || (sourceType > REC_MAX_CHARACTER))) { - if ( source ) + if ( source ) { intermediate = new (heap) char[targetLen]; short intermediateLen; @@ -1785,12 +1785,12 @@ InputOutputExpr::outputValues(atp_struct *atp, heap, &diagsArea) != ex_expr::EXPR_OK) { if (diagsArea != atp->getDiagsArea()) - atp->setDiagsArea(diagsArea); - + atp->setDiagsAreax(diagsArea); + NADELETEBASIC(intermediate, heap); return ex_expr::EXPR_ERROR; }; - + sourceType = REC_BYTE_F_ASCII; sourceLen = intermediateLen; sourceScale = 0; @@ -1807,7 +1807,7 @@ InputOutputExpr::outputValues(atp_struct *atp, targetPrecision = 0; } } // implicit conversion - + ConvInstruction case_index = CONV_UNKNOWN; ULng32 convFlags = 0; if ((source) && @@ -1825,18 +1825,17 @@ InputOutputExpr::outputValues(atp_struct *atp, // If the two interval types are not the same, then first // convert source to target interval type, and then convert // to its string external representation. - if (sourceType == REC_DATETIME) { if ((sourcePrecision != targetPrecision) || (sourceScale != targetScale)) { // source and target must have the same datetime_code, - // they must both be date, time or timestamp. + // they must both be date, time or timestamp. ExRaiseSqlError(heap, &diagsArea, EXE_CONVERT_NOT_SUPPORTED); if (diagsArea != atp->getDiagsArea()) - atp->setDiagsArea(diagsArea); + atp->setDiagsAreax(diagsArea); return ex_expr::EXPR_ERROR; } else @@ -1870,7 +1869,7 @@ InputOutputExpr::outputValues(atp_struct *atp, targetPrecision = 0; // TBD $$$$ add target max chars later targetScale = SQLCHARSETCODE_ISO88591; // assume target charset is ASCII compatible } - else + else { // interval type and source/target do not match. // Convert source to target interval type. @@ -1889,11 +1888,11 @@ InputOutputExpr::outputValues(atp_struct *atp, NULL, sizeof(short), heap, - &diagsArea) != ex_expr::EXPR_OK) + &diagsArea) != ex_expr::EXPR_OK) { if (diagsArea != atp->getDiagsArea()) - atp->setDiagsArea(diagsArea); - + atp->setDiagsAreax(diagsArea); + NADELETEBASIC(intermediate, heap); return ex_expr::EXPR_ERROR; }; @@ -1903,24 +1902,24 @@ InputOutputExpr::outputValues(atp_struct *atp, sourceScale = targetScale; sourcePrecision = targetPrecision; source = intermediate; - + targetType = REC_BYTE_F_ASCII; targetScale = 0; targetPrecision = 0; } - + // datetime and interval values are left blank padded. convFlags |= CONV_LEFT_PAD; } - if ( source ) + if ( source ) { if ( treatAnsivByteAsWideChar == TRUE ) { // We substract one here so that the first byte in the - // last wide char can be filled with single-byte - // null by convDoIt(). - // + // last wide char can be filled with single-byte + // null by convDoIt(). + // // Note the target length records the number of octets // in target hostvar. The value is even because // KANJI/KSC hostvars are wide characters. @@ -1945,8 +1944,8 @@ InputOutputExpr::outputValues(atp_struct *atp, convFlags); if (rc == ex_expr::EXPR_ERROR) { if (diagsArea != atp->getDiagsArea()) - atp->setDiagsArea(diagsArea); - + atp->setDiagsAreax(diagsArea); + NADELETEBASIC(intermediate, heap); if (!targetVarPtr) NADELETEBASIC(realTarget, heap); @@ -1956,13 +1955,12 @@ InputOutputExpr::outputValues(atp_struct *atp, if ( treatAnsivByteAsWideChar == TRUE ) { // Make the second byte in the last wide char - // a null so that the last wide char contains a wide-char + // a null so that the last wide char contains a wide-char // null. target[strlen(target)+1] = 0; } if (diagsArea ) { - // Indicator var is also used to test for truncated output value. // The Indicator variable is set to the length of the string in the // database if the character value is truncated.. @@ -1976,7 +1974,7 @@ InputOutputExpr::outputValues(atp_struct *atp, // not. If it is true, then we update the indicator. if ( DFS2REC::isAnyCharacter(targetType) && DFS2REC::isAnyCharacter(operand->getDatatype()) && - diagsArea -> containsWarning( numOfWarningsFoundSoFar, + diagsArea -> containsWarning( numOfWarningsFoundSoFar, EXE_STRING_OVERFLOW)) { @@ -1985,11 +1983,11 @@ InputOutputExpr::outputValues(atp_struct *atp, short * tempVCInd = (short *) targetIndPtr; if (DFS2REC::isANSIVarChar(sourceType)) { if ( CharInfo::maxBytesPerChar(sourceCharSet) == 2 ) { - *tempVCInd = (short) NAWstrlen((NAWchar *)source); + *tempVCInd = (short) NAWstrlen((NAWchar *)source); // we are guaranteed that source is - // null-terminated as the previous call to convdoit() + // null-terminated as the previous call to convdoit() //would have raised an error otherwise - } + } else { *tempVCInd = (short) strlen(source); } @@ -2001,18 +1999,17 @@ InputOutputExpr::outputValues(atp_struct *atp, *tempVCInd /= SQL_DBCHAR_SIZE; } } - if (diagsArea != atp->getDiagsArea()) - atp->setDiagsArea(diagsArea); + atp->setDiagsAreax(diagsArea); } // character datatype numOfWarningsFoundSoFar = diagsArea->getNumber(DgSqlCode::WARNING_); } - + NADELETEBASIC(intermediate, heap); - + // up- or down-scale target. - if (targetType >= REC_MIN_NUMERIC && + if (targetType >= REC_MIN_NUMERIC && targetType <= REC_MAX_NUMERIC && sourceScale != targetScale && ::scaleDoIt( @@ -2022,17 +2019,17 @@ InputOutputExpr::outputValues(atp_struct *atp, sourceScale, targetScale, sourceType, - heap) != ex_expr::EXPR_OK) + heap) != ex_expr::EXPR_OK) { ExRaiseSqlError(heap, &diagsArea, EXE_NUMERIC_OVERFLOW); if (diagsArea != atp->getDiagsArea()) - atp->setDiagsArea(diagsArea); - + atp->setDiagsAreax(diagsArea); + if (!targetVarPtr) NADELETEBASIC(realTarget, heap); return ex_expr::EXPR_ERROR; } - + if (!targetVarPtr) { // unbound column. Remember it in executor memory. // This value will(probably) be retrieved later by @@ -2785,40 +2782,39 @@ InputOutputExpr::inputSingleRowValue(atp_struct *atp, // convert for the conversions that are externally supported. // See usage of default IMPLICIT_HOSTVAR_CONVERSION in generator // (GenExpGenerator.cpp) for restricted conversions. - if (NOT areCompatible(sourceType, targetType)) { if ((NOT skipTypeCheck()) || - ((restrictedSkipTypeCheck()) && + ((restrictedSkipTypeCheck()) && (NOT implicitConversionSupported(sourceType, operand->getDatatype())))) { errorCode = EXE_CONVERT_NOT_SUPPORTED; goto error_return; } - + implicitConversion = TRUE; - } - else + } + else { // check charset for source and target if they are CHARACTER types. if ( DFS2REC::isAnyCharacter(sourceType) && NOT CharInfo::isAssignmentCompatible(sourceCharSet, targetCharSet) - ) + ) { ExRaiseSqlError(heap, &diagsArea, CLI_ASSIGN_INCOMPATIBLE_CHARSET); - + if (diagsArea != atp->getDiagsArea()) - atp->setDiagsArea(diagsArea); - + atp->setDiagsAreax(diagsArea); + *diagsArea << DgString0(CharInfo::getCharSetName((CharInfo::CharSet)sourceCharSet)) << DgString1(CharInfo::getCharSetName((CharInfo::CharSet)targetCharSet)); - + return ex_expr::EXPR_ERROR; } } - + // Check length limit for KANJI/KSC5601/UCS2 ANSI VARCHAR (i.e., there // should be a wchar_t typed NULL somewhere in the range [1, sourceLen/2] // in the source. We have to do this for KANJI/KSC because their FS type @@ -2862,19 +2858,19 @@ InputOutputExpr::inputSingleRowValue(atp_struct *atp, realSourceLen = sourceLen ; } realSourceLen /= SQL_DBCHAR_SIZE; - + if ( CharInfo::checkCodePoint((wchar_t*)source, realSourceLen, CharInfo::UNICODE ) == FALSE ) { // Error code 3400 falls in CLI error code area, but it is // a perfect fit to use here (as an exeutor error). ExRaiseSqlError(heap, &diagsArea, (ExeErrorCode)3400); - + if (diagsArea != atp->getDiagsArea()) - atp->setDiagsArea(diagsArea); - + atp->setDiagsAreax(diagsArea); + *diagsArea << DgString0(SQLCHARSETSTRING_UNICODE); - + return ex_expr::EXPR_ERROR; } } @@ -3056,19 +3052,19 @@ InputOutputExpr::inputSingleRowValue(atp_struct *atp, } } // if (! nullMoved) } // if clause == IN_OUT type - + next_clause: clause = clause->getNextClause(); } // while(clause) - + return ex_expr::EXPR_OK; - + error_return: if (errorCode != EXE_OK) ExRaiseSqlError(heap, &diagsArea, errorCode); if (diagsArea != atp->getDiagsArea()) - atp->setDiagsArea(diagsArea); - + atp->setDiagsAreax(diagsArea); + return ex_expr::EXPR_ERROR; } ex_expr::exp_return_type @@ -3370,7 +3366,7 @@ InputOutputExpr::inputRowwiseRowsetValues(atp_struct *atp, } // use internal buffer return ex_expr::EXPR_OK; - + error_return: if (errorCode != EXE_OK) ExRaiseSqlError(heap, &diagsArea, errorCode, @@ -3379,7 +3375,7 @@ InputOutputExpr::inputRowwiseRowsetValues(atp_struct *atp, (intParam2 != 0 ? &intParam2 : NULL), (intParam3 != 0 ? &intParam3 : NULL)); if (diagsArea != atp->getDiagsArea()) - atp->setDiagsArea(diagsArea); + atp->setDiagsAreax(diagsArea); return ex_expr::EXPR_ERROR; } @@ -3432,13 +3428,13 @@ InputOutputExpr::inputValues(atp_struct *atp, // can put a flag in the root to describe whether it is CALL statement. NABoolean useParamIdx = FALSE; - + if(!inputDesc) { if(getNumEntries() > 0) { ExRaiseSqlError(heap, &diagsArea, CLI_STMT_DESC_COUNT_MISMATCH); if (diagsArea != atp->getDiagsArea()) - atp->setDiagsArea(diagsArea); + atp->setDiagsAreax(diagsArea); return ex_expr::EXPR_ERROR; } else @@ -3452,16 +3448,16 @@ InputOutputExpr::inputValues(atp_struct *atp, { ExRaiseSqlError(heap, &diagsArea, CLI_STMT_DESC_COUNT_MISMATCH); if (diagsArea != atp->getDiagsArea()) - atp->setDiagsArea(diagsArea); + atp->setDiagsAreax(diagsArea); return ex_expr::EXPR_ERROR; } } - + if (inputDesc && inputDesc->rowwiseRowset()) { ExRaiseSqlError(heap, &diagsArea, CLI_ROWWISE_ROWSETS_NOT_SUPPORTED); if (diagsArea != atp->getDiagsArea()) - atp->setDiagsArea(diagsArea); + atp->setDiagsAreax(diagsArea); return ex_expr::EXPR_ERROR; } @@ -3618,25 +3614,25 @@ InputOutputExpr::inputValues(atp_struct *atp, // in the descriptor. This check was added since the pre-processor // have had generated different information for the module defintion // file and the cpp file. - + // Find rowset size, if any targetRowsetSize = operand->getRowsetSize(); - - if (targetRowsetSize > 0) { + + if (targetRowsetSize > 0) { // dynamicRowsetSize is specified with ROWSET FOR INPUT SIZE // or some other rowset syntax; can change at run time if (dynamicRowsetSize > targetRowsetSize) { ExRaiseSqlError(heap, &diagsArea, EXE_ROWSET_INDEX_OUTOF_RANGE); if (diagsArea != atp->getDiagsArea()) { - atp->setDiagsArea(diagsArea); + atp->setDiagsAreax(diagsArea); return ex_expr::EXPR_ERROR; } } - + if (dynamicRowsetSize > 0) { targetRowsetSize = dynamicRowsetSize; } - + // do the conversion source = (char *)&targetRowsetSize; if (::convDoIt(source, @@ -3654,21 +3650,21 @@ InputOutputExpr::inputValues(atp_struct *atp, ) != ex_expr::EXPR_OK) { if (diagsArea != atp->getDiagsArea()) - atp->setDiagsArea(diagsArea); - + atp->setDiagsAreax(diagsArea); + return ex_expr::EXPR_ERROR; } - - // Increment the location for the next element. - target += sizeof(Lng32); - if (operand->getNullFlag()) { + + // Increment the location for the next element. + target += sizeof(Lng32); + if (operand->getNullFlag()) { targetNullInd = target; target += operand->getNullIndicatorLength(); } - - if (operand->getVCIndicatorLength() > 0) { + + if (operand->getVCIndicatorLength() > 0) { target += operand->getVCIndicatorLength(); - } + } // save current source and target datatype attributes since // they may get changed later in this method. // Restore them for the next iteration of this for loop. @@ -3680,29 +3676,29 @@ InputOutputExpr::inputValues(atp_struct *atp, savedSourceLen = sourceLen; } // if (targetRowsetSize > 0) else { - inputDesc->getDescItem(entry, SQLDESC_ROWSET_VAR_LAYOUT_SIZE, &rowsetVarLayoutSize, + inputDesc->getDescItem(entry, SQLDESC_ROWSET_VAR_LAYOUT_SIZE, &rowsetVarLayoutSize, 0, 0, 0, 0); if (rowsetVarLayoutSize > 0) { ExRaiseSqlError(heap, &diagsArea, EXE_ROWSET_SCALAR_ARRAY_MISMATCH); if (diagsArea != atp->getDiagsArea()) { - atp->setDiagsArea(diagsArea); + atp->setDiagsAreax(diagsArea); return ex_expr::EXPR_ERROR; - // Raises an error when query was compiled with scalar param - // and array value is passed in at runtime. When query is compiled + // Raises an error when query was compiled with scalar param + // and array value is passed in at runtime. When query is compiled // with array params and some (not all) values are scalars at runtime // we do not raise an error and we duplicate the scalar value. } } } // else (targetRowsetSize > 0) - + Lng32 numToProcess = ((targetRowsetSize > 0) ? targetRowsetSize : 1); // Define and clear case indexes potentially used for rowsets ConvInstruction index1 = CONV_UNKNOWN; ConvInstruction index2 = CONV_UNKNOWN; ConvInstruction index3 = CONV_UNKNOWN; - - for (Lng32 RowNum = 0; RowNum < numToProcess; RowNum++) + + for (Lng32 RowNum = 0; RowNum < numToProcess; RowNum++) { // Increment the location for the next element. @@ -3720,20 +3716,20 @@ InputOutputExpr::inputValues(atp_struct *atp, sourceLen = savedSourceLen; } - + if (targetRowsetSize > 0) inputDesc->setDescItem(0, SQLDESC_ROWSET_HANDLE, RowNum, 0); inputDesc->getDescItem(entry, SQLDESC_IND_DATA, &indData, 0, 0, 0, 0); if (indData == 0) { - inputDesc->getDescItem(entry, SQLDESC_IND_PTR, &tempSource, + inputDesc->getDescItem(entry, SQLDESC_IND_PTR, &tempSource, 0, 0, 0, 0); - inputDesc->getDescItem(entry, SQLDESC_ROWSET_IND_LAYOUT_SIZE, &rowsetIndLayoutSize, + inputDesc->getDescItem(entry, SQLDESC_ROWSET_IND_LAYOUT_SIZE, &rowsetIndLayoutSize, 0, 0, 0, 0); if ((!tempSource) && (rowsetIndLayoutSize > 0)) { ExRaiseSqlError(heap, &diagsArea, EXE_ROWSET_VARDATA_OR_INDDATA_ERROR); if (diagsArea != atp->getDiagsArea()) - atp->setDiagsArea(diagsArea); + atp->setDiagsAreax(diagsArea); return ex_expr::EXPR_ERROR; } } @@ -3741,12 +3737,12 @@ InputOutputExpr::inputValues(atp_struct *atp, tempSource = (char *)&indData; sourceIndPtr = tempSource; - + NABoolean nullMoved = FALSE; if (sourceIndPtr) { short temp = 0; str_cpy_all((char *)&temp, sourceIndPtr, operand->getNullIndicatorLength()); - if (inputDesc && inputDesc->thereIsACompoundStatement() + if (inputDesc && inputDesc->thereIsACompoundStatement() && (temp > 0)) { // We may be processing input data with invalid indicators if we // are in an IF statement @@ -3759,31 +3755,31 @@ InputOutputExpr::inputValues(atp_struct *atp, // -ve (null value). ExRaiseSqlError(heap, &diagsArea, EXE_CONVERT_STRING_ERROR); if (diagsArea != atp->getDiagsArea()) - atp->setDiagsArea(diagsArea); - + atp->setDiagsAreax(diagsArea); + setRowNumberInCli(diagsArea, RowNum, targetRowsetSize) ; if (tolerateNonFatalError && diagsArea->canAcceptMoreErrors()) continue; else return ex_expr::EXPR_ERROR; } - + if (operand->getNullFlag()) { nullMoved = (temp < 0); //if null indicator is a negative //number, the value is null - + str_cpy_all (targetNullInd, sourceIndPtr, operand->getNullIndicatorLength()); } else { if (temp < 0) { // input is a null value - // error. Trying to move a null input value to a + // error. Trying to move a null input value to a // non-nullable buffer. ExRaiseSqlError(heap, &diagsArea, EXE_ASSIGNING_NULL_TO_NOT_NULL); if (diagsArea != atp->getDiagsArea()) - atp->setDiagsArea(diagsArea); - + atp->setDiagsAreax(diagsArea); + setRowNumberInCli(diagsArea, RowNum, targetRowsetSize) ; if (tolerateNonFatalError && diagsArea->canAcceptMoreErrors()) continue; @@ -3813,14 +3809,14 @@ InputOutputExpr::inputValues(atp_struct *atp, // 12/22/97: added for Unicode Vchar. if (! nullMoved) { - - ex_expr::exp_return_type retcode = ex_expr::EXPR_OK; + + ex_expr::exp_return_type retcode = ex_expr::EXPR_OK; Lng32 warningMark; if (diagsArea) warningMark= diagsArea->getNumber(DgSqlCode::WARNING_); else warningMark = 0; - + NABoolean implicitConversion = FALSE; // if the source and target are not compatible, then do implicit // conversion if skipTypeCheck is set. @@ -3832,14 +3828,14 @@ InputOutputExpr::inputValues(atp_struct *atp, if (NOT areCompatible(sourceType, targetType)) { if ((NOT skipTypeCheck()) || - ((restrictedSkipTypeCheck()) && + ((restrictedSkipTypeCheck()) && (NOT implicitConversionSupported(sourceType, operand->getDatatype())))) { ExRaiseSqlError(heap, &diagsArea,EXE_CONVERT_NOT_SUPPORTED); if (diagsArea != atp->getDiagsArea()) - atp->setDiagsArea(diagsArea); - + atp->setDiagsAreax(diagsArea); + setRowNumberInCli(diagsArea, RowNum, targetRowsetSize) ; if (tolerateNonFatalError && diagsArea->canAcceptMoreErrors()) continue; @@ -3853,17 +3849,17 @@ InputOutputExpr::inputValues(atp_struct *atp, // check charset for source and target if they are CHARACTER types. if ( DFS2REC::isAnyCharacter(sourceType) && NOT CharInfo::isAssignmentCompatible(sourceCharSet, targetCharSet) - ) + ) { ExRaiseSqlError(heap, &diagsArea, CLI_ASSIGN_INCOMPATIBLE_CHARSET); if (diagsArea != atp->getDiagsArea()) - atp->setDiagsArea(diagsArea); + atp->setDiagsAreax(diagsArea); *diagsArea << DgString0(CharInfo::getCharSetName((CharInfo::CharSet)sourceCharSet)) << DgString1(CharInfo::getCharSetName((CharInfo::CharSet)targetCharSet)); - + setRowNumberInCli(diagsArea, RowNum, targetRowsetSize) ; if (tolerateNonFatalError && diagsArea->canAcceptMoreErrors()) continue; @@ -3872,7 +3868,6 @@ InputOutputExpr::inputValues(atp_struct *atp, } } - // In the case of VARCHARS, we zero out remaining elements if (targetRowsetSize > 0) { Int32 i; @@ -3913,8 +3908,8 @@ InputOutputExpr::inputValues(atp_struct *atp, ExRaiseSqlError(heap, &diagsArea, EXE_MISSING_NULL_TERMINATOR); if (diagsArea != atp->getDiagsArea()) - atp->setDiagsArea(diagsArea); - + atp->setDiagsAreax(diagsArea); + setRowNumberInCli(diagsArea, RowNum, targetRowsetSize) ; if (tolerateNonFatalError && diagsArea->canAcceptMoreErrors()) continue; @@ -3946,7 +3941,7 @@ InputOutputExpr::inputValues(atp_struct *atp, ExRaiseSqlError(heap, &diagsArea, (ExeErrorCode)3400); if (diagsArea != atp->getDiagsArea()) - atp->setDiagsArea(diagsArea); + atp->setDiagsAreax(diagsArea); *diagsArea << DgString0(SQLCHARSETSTRING_UNICODE); @@ -3957,10 +3952,10 @@ InputOutputExpr::inputValues(atp_struct *atp, return ex_expr::EXPR_ERROR; } } - + // if incompatible conversions are to be done, - // and the source is REC_BYTE_V_ANSI, - // and the target is not a string type, convert the source to + // and the source is REC_BYTE_V_ANSI, + // and the target is not a string type, convert the source to // REC_BYTE_F_ASCII first. Conversion from V_ANSI is currently // only supported if target is a string type. if ((implicitConversion) && @@ -3996,8 +3991,8 @@ InputOutputExpr::inputValues(atp_struct *atp, &diagsArea, index1) != ex_expr::EXPR_OK) { if (diagsArea != atp->getDiagsArea()) - atp->setDiagsArea(diagsArea); - + atp->setDiagsAreax(diagsArea); + NADELETEBASIC(intermediate, heap); setRowNumberInCli(diagsArea, RowNum, targetRowsetSize) ; if (tolerateNonFatalError && diagsArea->canAcceptMoreErrors()) @@ -4005,11 +4000,11 @@ InputOutputExpr::inputValues(atp_struct *atp, else return ex_expr::EXPR_ERROR; }; - + sourceType = REC_BYTE_F_ASCII; source = intermediate; } // sourceType == REC_BYTE_V_ANSI - + if ((sourcePrecision > 0) && ((sourceType >= REC_MIN_BINARY) && (sourceType <= REC_MAX_BINARY) && @@ -4046,12 +4041,12 @@ InputOutputExpr::inputValues(atp_struct *atp, (sourceScale != operand->getScale())) { // source and target must have the same datetime_code, - // they must both be date, time or timestamp. + // they must both be date, time or timestamp. ExRaiseSqlError(heap, &diagsArea, EXE_CONVERT_NOT_SUPPORTED); if (diagsArea != atp->getDiagsArea()) - atp->setDiagsArea(diagsArea); - + atp->setDiagsAreax(diagsArea); + setRowNumberInCli(diagsArea, RowNum, targetRowsetSize) ; if (tolerateNonFatalError && diagsArea->canAcceptMoreErrors()) continue; @@ -4120,8 +4115,8 @@ InputOutputExpr::inputValues(atp_struct *atp, convFlags) != ex_expr::EXPR_OK) { if (diagsArea != atp->getDiagsArea()) - atp->setDiagsArea(diagsArea); - + atp->setDiagsAreax(diagsArea); + NADELETEBASIC(intermediate, heap); setRowNumberInCli(diagsArea, RowNum, targetRowsetSize) ; if (tolerateNonFatalError && diagsArea->canAcceptMoreErrors()) @@ -4179,8 +4174,8 @@ InputOutputExpr::inputValues(atp_struct *atp, if (retcode != ex_expr::EXPR_OK) { if (diagsArea != atp->getDiagsArea()) - atp->setDiagsArea(diagsArea); - + atp->setDiagsAreax(diagsArea); + setRowNumberInCli(diagsArea, RowNum, targetRowsetSize) ; if (tolerateNonFatalError && diagsArea->canAcceptMoreErrors()) continue; @@ -4191,12 +4186,12 @@ InputOutputExpr::inputValues(atp_struct *atp, { Int32 warningMark2 = diagsArea->getNumber(DgSqlCode::WARNING_); Int32 counter = warningMark2 - warningMark; - + diagsArea->deleteWarning(warningMark2-counter); ExRaiseSqlError(heap, &diagsArea, EXE_STRING_OVERFLOW); - + if (diagsArea != atp->getDiagsArea()) - atp->setDiagsArea(diagsArea); + atp->setDiagsAreax(diagsArea); setRowNumberInCli(diagsArea, RowNum, targetRowsetSize) ; if (tolerateNonFatalError && diagsArea->canAcceptMoreErrors()) @@ -4206,9 +4201,9 @@ InputOutputExpr::inputValues(atp_struct *atp, } // If the query contains ROWSET FOR INPUT SIZE or - // ROWSET ( ) then we get the number of entries + // ROWSET ( ) then we get the number of entries // from - if (operand->getHVRowsetForInputSize() || + if (operand->getHVRowsetForInputSize() || operand->getHVRowsetLocalSize()) { short targetType = operand->getDatatype(); switch (targetType) { @@ -4216,8 +4211,8 @@ InputOutputExpr::inputValues(atp_struct *atp, if (*((Int8 *) target) <= 0) { //raise error ExRaiseSqlError(heap, &diagsArea, EXE_ROWSET_NEGATIVE_SIZE); - if (diagsArea != atp->getDiagsArea()) - atp->setDiagsArea(diagsArea); + if (diagsArea != atp->getDiagsArea()) + atp->setDiagsAreax(diagsArea); return ex_expr::EXPR_ERROR; } else { @@ -4228,21 +4223,21 @@ InputOutputExpr::inputValues(atp_struct *atp, if (*((UInt8 *) target) == 0) { //raise error ExRaiseSqlError(heap, &diagsArea, EXE_ROWSET_NEGATIVE_SIZE); - if (diagsArea != atp->getDiagsArea()) - atp->setDiagsArea(diagsArea); + if (diagsArea != atp->getDiagsArea()) + atp->setDiagsAreax(diagsArea); return ex_expr::EXPR_ERROR; } else { dynamicRowsetSize = *((UInt8 *) target); break; } - + case REC_BIN16_SIGNED : if (*((short *) target) <= 0) { //raise error ExRaiseSqlError(heap, &diagsArea, EXE_ROWSET_NEGATIVE_SIZE); - if (diagsArea != atp->getDiagsArea()) - atp->setDiagsArea(diagsArea); + if (diagsArea != atp->getDiagsArea()) + atp->setDiagsAreax(diagsArea); return ex_expr::EXPR_ERROR; } else { @@ -4253,50 +4248,50 @@ InputOutputExpr::inputValues(atp_struct *atp, if (*((unsigned short *) target) == 0) { //raise error ExRaiseSqlError(heap, &diagsArea, EXE_ROWSET_NEGATIVE_SIZE); - if (diagsArea != atp->getDiagsArea()) - atp->setDiagsArea(diagsArea); + if (diagsArea != atp->getDiagsArea()) + atp->setDiagsAreax(diagsArea); return ex_expr::EXPR_ERROR; } else { dynamicRowsetSize = *((unsigned short *) target); break; } - + case REC_BIN32_SIGNED : if (*((Lng32 *) target) <= 0) { //raise error ExRaiseSqlError(heap, &diagsArea, EXE_ROWSET_NEGATIVE_SIZE); - if (diagsArea != atp->getDiagsArea()) - atp->setDiagsArea(diagsArea); + if (diagsArea != atp->getDiagsArea()) + atp->setDiagsAreax(diagsArea); return ex_expr::EXPR_ERROR; } else { dynamicRowsetSize = *((Lng32 *) target); //long is the same as int break; } - + case REC_BIN32_UNSIGNED : if (*((ULng32 *) target) == 0) { // unsigned long is the same as unsigned int //raise error ExRaiseSqlError(heap, &diagsArea, EXE_ROWSET_NEGATIVE_SIZE); - if (diagsArea != atp->getDiagsArea()) - atp->setDiagsArea(diagsArea); + if (diagsArea != atp->getDiagsArea()) + atp->setDiagsAreax(diagsArea); return ex_expr::EXPR_ERROR; } else { dynamicRowsetSize = *((ULng32 *) target); break; } - + default: //raise error ExRaiseSqlError(heap, &diagsArea,EXE_ROWSET_WRONG_SIZETYPE); - if (diagsArea != atp->getDiagsArea()) - atp->setDiagsArea(diagsArea); + if (diagsArea != atp->getDiagsArea()) + atp->setDiagsAreax(diagsArea); return ex_expr::EXPR_ERROR; } } - + // up- or down-scale target, if there is a difference // in scale, but be careful to ignore scale used as charset if ((operand->getDatatype() >= REC_MIN_NUMERIC) && @@ -4312,8 +4307,8 @@ InputOutputExpr::inputValues(atp_struct *atp, { ExRaiseSqlError(heap, &diagsArea, EXE_NUMERIC_OVERFLOW); if (diagsArea != atp->getDiagsArea()) - atp->setDiagsArea(diagsArea); - + atp->setDiagsAreax(diagsArea); + setRowNumberInCli(diagsArea, RowNum, targetRowsetSize) ; if (tolerateNonFatalError && diagsArea->canAcceptMoreErrors()) continue; diff --git a/core/sql/comexe/PartInputDataDesc.cpp b/core/sql/comexe/PartInputDataDesc.cpp index 61163921f5..d481b5dcdd 100644 --- a/core/sql/comexe/PartInputDataDesc.cpp +++ b/core/sql/comexe/PartInputDataDesc.cpp @@ -258,8 +258,8 @@ Lng32 ExRangePartInputData::evalExpressions(Space * space, workAtp->getTupp(partRangeExprAtpIndex_) = &td; if (workAtp->getDiagsArea() != *diags) - workAtp->setDiagsArea(*diags); - + workAtp->setDiagsAreax(*diags); + // loop over all expressions, fixing them up and evaluating them for (Lng32 i = 0; i <= getNumPartitions() AND result == 0; i++) { diff --git a/core/sql/executor/ExCancel.cpp b/core/sql/executor/ExCancel.cpp index b425ca429d..2fe689d1f4 100755 --- a/core/sql/executor/ExCancel.cpp +++ b/core/sql/executor/ExCancel.cpp @@ -502,9 +502,9 @@ void ExCancelTcb::reportError(ComDiagsArea *da, bool addCondition, if (addCondition) { - ComDiagsArea *diagsArea = + ComDiagsArea *diagsArea = ComDiagsArea::allocate(getGlobals()->getDefaultHeap()); - + *diagsArea << DgSqlCode(-SQLCode); if (nodeName) @@ -518,7 +518,7 @@ void ExCancelTcb::reportError(ComDiagsArea *da, bool addCondition, } diagsArea->mergeAfter(*da); - up_entry->setDiagsArea(diagsArea); + up_entry->setDiagsAreax(diagsArea); da->decrRefCount(); } else diff --git a/core/sql/executor/ExCompoundStmt.cpp b/core/sql/executor/ExCompoundStmt.cpp index f77577625c..b4d7fadebb 100644 --- a/core/sql/executor/ExCompoundStmt.cpp +++ b/core/sql/executor/ExCompoundStmt.cpp @@ -567,7 +567,7 @@ void ExCatpoundStmtTcb::processError(atp_struct *atp, ComDiagsArea *da) { ex_queue_entry *pdentry = qparent_.down->getHeadEntry(); ex_queue_entry *puentry = qparent_.up->getTailEntry(); - ExCatpoundStmtPrivateState &pstate = + ExCatpoundStmtPrivateState &pstate = *((ExCatpoundStmtPrivateState*)pdentry->pstate); // set up error entry for parent up-queue @@ -576,10 +576,10 @@ void ExCatpoundStmtTcb::processError(atp_struct *atp, ComDiagsArea *da) puentry->upState.parentIndex = pdentry->downState.parentIndex; puentry->upState.downIndex = qparent_.down->getHeadIndex(); puentry->upState.setMatchNo(pstate.rightrows_); - if (da) puentry->setDiagsArea(da); + if (da) puentry->setDiagsAreax(da); // insert entry into parent's up queue - qparent_.up->insert(); + qparent_.up->insert(); // cancel this request and all its children qparent_.down->cancelRequest(qparent_.down->getHeadIndex()); @@ -593,17 +593,17 @@ void ExCatpoundStmtTcb::processCardinalityError(ex_queue_entry *centry) // create error for diags ComDiagsArea *da = ExRaiseSqlError (getGlobals()->getDefaultHeap(), centry, - (ExeErrorCode)-EXE_BLOCK_CARDINALITY_VIOLATION); + (ExeErrorCode)-EXE_BLOCK_CARDINALITY_VIOLATION); processError(centry->getAtp(), da); } // ExCatpoundStmtTcb::processCardinalityError //This method is used to raise error -EXE_CS_EOD_ROLLBACK_ERROR or -// warning +EXE_CS_EOD. Raising this error or warning causes further processing of the -// CS to be stopped and if any updates were seen previously in this CS then the -// whole transaction is rolled back. Note that the warning EXE_CS_EOD is actually -//raised as an error here and and attached to a Q_SQLERROR entry. It is converted into a -//warning in the root::fetch or root::oltExecute method. This is done since it +// warning +EXE_CS_EOD. Raising this error or warning causes further processing of the +// CS to be stopped and if any updates were seen previously in this CS then the +// whole transaction is rolled back. Note that the warning EXE_CS_EOD is actually +//raised as an error here and and attached to a Q_SQLERROR entry. It is converted into a +//warning in the root::fetch or root::oltExecute method. This is done since it //is crucial that this warning be posted and further processing on the offending CS be stopped. //There is a possibility that warnings are not propogated correctly and we continue processing //on the CS once the warning has been raised as an actual warning. @@ -622,15 +622,15 @@ void ExCatpoundStmtTcb::processEODErrorOrWarning(NABoolean isWarning) da = ExRaiseSqlError(getGlobals()->getDefaultHeap(), puentry, (ExeErrorCode)-EXE_CS_EOD_ROLLBACK_ERROR); - puentry->setDiagsArea(da); + puentry->setDiagsAreax(da); puentry->upState.status = ex_queue::Q_SQLERROR; puentry->upState.parentIndex = pdentry->downState.parentIndex; puentry->upState.downIndex = qparent_.down->getHeadIndex(); puentry->upState.setMatchNo((Lng32)0); - + qparent_.up->insert(); } - + ////////////////////////////////////////////////////////////////////////////// // CatpoundStmtPrivateState methods. ////////////////////////////////////////////////////////////////////////////// diff --git a/core/sql/executor/ExExeUtil.h b/core/sql/executor/ExExeUtil.h index 435dfb5230..5bff3721b8 100644 --- a/core/sql/executor/ExExeUtil.h +++ b/core/sql/executor/ExExeUtil.h @@ -272,7 +272,7 @@ class ExExeUtilTcb : public ex_tcb ComDiagsArea *&getDiagsArea() { return diagsArea_; } - void setDiagsArea(ComDiagsArea * d) { diagsArea_ = d; } + void setDiagsAreax(ComDiagsArea * d) { diagsArea_ = d; } short setSchemaVersion(char * param1); diff --git a/core/sql/executor/ExExeUtilCommon.cpp b/core/sql/executor/ExExeUtilCommon.cpp index 6566f91f5d..b946a1fd18 100644 --- a/core/sql/executor/ExExeUtilCommon.cpp +++ b/core/sql/executor/ExExeUtilCommon.cpp @@ -427,8 +427,8 @@ Lng32 ExExeUtilTcb::changeAuditAttribute(char * tableName, ExMasterStmtGlobals *masterGlob = exeGlob->castToExMasterStmtGlobals(); // set sqlparserflags to allow change of audit attribute - masterGlob->getStatement()->getContext()->setSqlParserFlags(0x400); // ALLOW_AUDIT_CHANGE - + masterGlob->getStatement()->getContext()->setSqlParserFlags(0x400); // ALLOW_AUDIT_CHANGE + // make table unaudited char stmt[500]; strcpy(stmt, "alter "); @@ -447,10 +447,10 @@ Lng32 ExExeUtilTcb::changeAuditAttribute(char * tableName, strcat(stmt, ";"); ComDiagsArea *diagsArea = getDiagsArea(); retcode = cliInterface()->executeImmediate - (stmt, NULL, NULL, TRUE, NULL, 0, &diagsArea); - setDiagsArea(diagsArea); + (stmt, NULL, NULL, TRUE, NULL, 0, &diagsArea); + setDiagsAreax(diagsArea); masterGlob->getStatement()->getContext()->resetSqlParserFlags(0x400); // ALLOW_AUDIT_CHANGE - + if (retcode < 0) return retcode; @@ -465,7 +465,7 @@ Lng32 ExExeUtilTcb::changeAuditAttribute(char * tableName, } void ExExeUtilTcb::handleErrors(Lng32 rc) -{ +{ cliInterface()->allocAndRetrieveSQLDiagnostics(diagsArea_); } @@ -474,7 +474,7 @@ short ExExeUtilTcb::initializeInfoList(Queue* &infoList) return cliInterface()->initializeInfoList(infoList, infoListIsOutputInfo_); } -short ExExeUtilTcb::fetchAllRows(Queue * &infoList, +short ExExeUtilTcb::fetchAllRows(Queue * &infoList, char * query, Lng32 numOutputEntries, NABoolean varcharFormat, diff --git a/core/sql/executor/ExExeUtilExplain.cpp b/core/sql/executor/ExExeUtilExplain.cpp index 4bf3d9b0cf..00fda7c512 100644 --- a/core/sql/executor/ExExeUtilExplain.cpp +++ b/core/sql/executor/ExExeUtilExplain.cpp @@ -4045,7 +4045,7 @@ short ExExeUtilDisplayExplainComplexTcb::work() step_ = DONE_; } break; - + case ERROR_: { if (qparent_.up->isFull()) @@ -4053,27 +4053,27 @@ short ExExeUtilDisplayExplainComplexTcb::work() // Return EOF. ex_queue_entry * up_entry = qparent_.up->getTailEntry(); - - up_entry->upState.parentIndex = + + up_entry->upState.parentIndex = pentry_down->downState.parentIndex; - + up_entry->upState.setMatchNo(0); up_entry->upState.status = ex_queue::Q_SQLERROR; ComDiagsArea *diagsArea = up_entry->getDiagsArea(); - + if (diagsArea == NULL) - diagsArea = + diagsArea = ComDiagsArea::allocate(this->getGlobals()->getDefaultHeap()); - + if (getDiagsArea()) diagsArea->mergeAfter(*getDiagsArea()); - - up_entry->setDiagsArea (diagsArea); - + + up_entry->setDiagsAreax(diagsArea); + // insert into parent qparent_.up->insert(); - + pstate.matches_ = 0; step_ = DONE_; @@ -4087,16 +4087,16 @@ short ExExeUtilDisplayExplainComplexTcb::work() // Return EOF. ex_queue_entry * up_entry = qparent_.up->getTailEntry(); - - up_entry->upState.parentIndex = + + up_entry->upState.parentIndex = pentry_down->downState.parentIndex; - + up_entry->upState.setMatchNo(0); up_entry->upState.status = ex_queue::Q_NO_DATA; - + // insert into parent qparent_.up->insert(); - + pstate.matches_ = 0; step_ = EMPTY_; qparent_.down->removeHead(); @@ -4258,7 +4258,7 @@ short ExExeUtilDisplayExplainShowddlTcb::work() step_ = DONE_; } break; - + case ERROR_: { if (qparent_.up->isFull()) @@ -4266,27 +4266,27 @@ short ExExeUtilDisplayExplainShowddlTcb::work() // Return EOF. ex_queue_entry * up_entry = qparent_.up->getTailEntry(); - - up_entry->upState.parentIndex = + + up_entry->upState.parentIndex = pentry_down->downState.parentIndex; - + up_entry->upState.setMatchNo(0); up_entry->upState.status = ex_queue::Q_SQLERROR; ComDiagsArea *diagsArea = up_entry->getDiagsArea(); - + if (diagsArea == NULL) - diagsArea = + diagsArea = ComDiagsArea::allocate(this->getGlobals()->getDefaultHeap()); - + if (getDiagsArea()) diagsArea->mergeAfter(*getDiagsArea()); - - up_entry->setDiagsArea (diagsArea); - + + up_entry->setDiagsAreax(diagsArea); + // insert into parent qparent_.up->insert(); - + pstate.matches_ = 0; step_ = DONE_; @@ -4300,16 +4300,16 @@ short ExExeUtilDisplayExplainShowddlTcb::work() // Return EOF. ex_queue_entry * up_entry = qparent_.up->getTailEntry(); - - up_entry->upState.parentIndex = + + up_entry->upState.parentIndex = pentry_down->downState.parentIndex; - + up_entry->upState.setMatchNo(0); up_entry->upState.status = ex_queue::Q_NO_DATA; - + // insert into parent qparent_.up->insert(); - + pstate.matches_ = 0; step_ = EMPTY_; qparent_.down->removeHead(); diff --git a/core/sql/executor/ExExeUtilLoad.cpp b/core/sql/executor/ExExeUtilLoad.cpp index 7c051c4002..bd3720db5d 100644 --- a/core/sql/executor/ExExeUtilLoad.cpp +++ b/core/sql/executor/ExExeUtilLoad.cpp @@ -931,14 +931,14 @@ ExWorkProcRetcode ExExeUtilAqrWnrInsertTcb::work() { ComDiagsArea * da = ComDiagsArea::allocate( getGlobals()->getDefaultHeap()); - pentry_up->setDiagsArea(da); + pentry_up->setDiagsAreax(da); } pentry_up->getDiagsArea()->mergeAfter(*getDiagsArea()); getDiagsArea()->clear(); SQL_EXEC_ClearDiagnostics(NULL); } pentry_up->upState.status = ex_queue::Q_SQLERROR; - pentry_up->upState.parentIndex = + pentry_up->upState.parentIndex = pentry_down->downState.parentIndex; pentry_up->upState.downIndex = qparent_.down->getHeadIndex(); qparent_.up->insert(); @@ -953,13 +953,13 @@ ExWorkProcRetcode ExExeUtilAqrWnrInsertTcb::work() pentry_up->upState.parentIndex = pentry_down->downState.parentIndex; pentry_up->upState.setMatchNo(0); pentry_up->upState.status = ex_queue::Q_NO_DATA; - + // insert into parent qparent_.up->insert(); - + SETSTEP(INITIAL_); qparent_.down->removeHead(); - + break; } } // switch @@ -1371,7 +1371,7 @@ short ExExeUtilHBaseBulkLoadTcb::work() &diagsArea); if (parserFlagSet) masterGlob->getStatement()->getContext()->resetSqlParserFlags(0x20000); - setDiagsArea(diagsArea); + setDiagsAreax(diagsArea); if (cliRC < 0) { rowsAffected_ = 0; @@ -1854,8 +1854,9 @@ void ExExeUtilHBaseBulkUnLoadTcb::createHdfsFileError(Int32 hdfsClientRetCode) ExRaiseSqlError(getHeap(), &diagsArea, (ExeErrorCode)(8447), NULL, NULL, NULL, NULL, errorMsg, (char *)GetCliGlobals()->getJniErrorStr()); ex_queue_entry *pentry_up = qparent_.up->getTailEntry(); - pentry_up->setDiagsArea(diagsArea); + pentry_up->setDiagsAreax(diagsArea); } + //////////////////////////////////////////////////////////////// // Constructor for class ExExeUtilHbaseLoadTcb /////////////////////////////////////////////////////////////// diff --git a/core/sql/executor/ExExeUtilMisc.cpp b/core/sql/executor/ExExeUtilMisc.cpp index fd1477c548..77ea141a74 100644 --- a/core/sql/executor/ExExeUtilMisc.cpp +++ b/core/sql/executor/ExExeUtilMisc.cpp @@ -320,9 +320,9 @@ short ExExeUtilLongRunningTcb::work() { getDiagsArea()->clear(); } - + qparent_.down->removeHead(); - + return WORK_OK; } break; @@ -334,27 +334,28 @@ short ExExeUtilLongRunningTcb::work() // Return EOF. ex_queue_entry * up_entry = qparent_.up->getTailEntry(); - - up_entry->upState.parentIndex = + + up_entry->upState.parentIndex = pentry_down->downState.parentIndex; - + up_entry->upState.setMatchNo(0); up_entry->upState.status = ex_queue::Q_SQLERROR; // get rows deleted so far. getDiagsArea()->setRowCount(getRowsDeleted()); ComDiagsArea *diagsArea = up_entry->getDiagsArea(); - + if (diagsArea == NULL) - diagsArea = + diagsArea = ComDiagsArea::allocate(this->getGlobals()->getDefaultHeap()); else - diagsArea->incrRefCount (); // setDiagsArea call below will decr ref count - + diagsArea->incrRefCount(); // setDiagsArea call below will decr ref count + // is this needed anymore? + if (getDiagsArea()) diagsArea->mergeAfter(*getDiagsArea()); - - up_entry->setDiagsArea (diagsArea); - + + up_entry->setDiagsAreax(diagsArea); + // insert into parent qparent_.up->insert(); @@ -390,14 +391,14 @@ ComDiagsArea *ExExeUtilLongRunningTcb::getDiagAreaFromUpQueueTail() if (diagsArea == NULL) diagsArea = ComDiagsArea::allocate(this->getGlobals()->getDefaultHeap()); else - diagsArea->incrRefCount (); // setDiagsArea call below will decr ref count + diagsArea->incrRefCount(); // setDiagsArea call below will decr ref count // this is the side-effect of this function. Merge in this object's // diagsarea. if (getDiagsArea()) diagsArea->mergeAfter(*getDiagsArea()); - up_entry->setDiagsArea (diagsArea); + up_entry->setDiagsAreax(diagsArea); return diagsArea; } @@ -929,12 +930,12 @@ short ExExeUtilPopulateInMemStatsTcb::work() // if no parent request, return if (qparent_.down->isEmpty()) return WORK_OK; - + // if no room in up queue, won't be able to return data/status. // Come back later. if (qparent_.up->isFull()) return WORK_OK; - + ex_queue_entry * pentry_down = qparent_.down->getHeadEntry(); ExExeUtilPrivateState & pstate = *((ExExeUtilPrivateState*) pentry_down->pstate); @@ -955,8 +956,8 @@ short ExExeUtilPopulateInMemStatsTcb::work() getDiagsArea()->clear(); getDiagsArea()->deAllocate(); } - - setDiagsArea(ComDiagsArea::allocate(getHeap())); + + setDiagsAreax(ComDiagsArea::allocate(getHeap())); step_ = PROLOGUE_; } @@ -1177,27 +1178,27 @@ short ExExeUtilPopulateInMemStatsTcb::work() // Return EOF. ex_queue_entry * up_entry = qparent_.up->getTailEntry(); - - up_entry->upState.parentIndex = + + up_entry->upState.parentIndex = pentry_down->downState.parentIndex; - + up_entry->upState.setMatchNo(0); up_entry->upState.status = ex_queue::Q_SQLERROR; ComDiagsArea *diagsArea = up_entry->getDiagsArea(); - + if (diagsArea == NULL) - diagsArea = + diagsArea = ComDiagsArea::allocate(this->getGlobals()->getDefaultHeap()); - + if (getDiagsArea()) diagsArea->mergeAfter(*getDiagsArea()); - - up_entry->setDiagsArea (diagsArea); - + + up_entry->setDiagsAreax(diagsArea); + // insert into parent qparent_.up->insert(); - + step_ = DONE_; } break; @@ -1206,21 +1207,21 @@ short ExExeUtilPopulateInMemStatsTcb::work() { if (qparent_.up->isFull()) return WORK_OK; - + // Return EOF. ex_queue_entry * up_entry = qparent_.up->getTailEntry(); - - up_entry->upState.parentIndex = + + up_entry->upState.parentIndex = pentry_down->downState.parentIndex; - + up_entry->upState.setMatchNo(0); up_entry->upState.status = ex_queue::Q_NO_DATA; - + // insert into parent qparent_.up->insert(); - + qparent_.down->removeHead(); - + step_ = INITIAL_; return WORK_OK; } diff --git a/core/sql/executor/ExExplain.cpp b/core/sql/executor/ExExplain.cpp index 46731e3c63..028b2e2e4c 100644 --- a/core/sql/executor/ExExplain.cpp +++ b/core/sql/executor/ExExplain.cpp @@ -531,19 +531,19 @@ short ExExplainTcb::processExplainStmt() { explainFragLen_ = str_decoded_len(cliInterface.getExplainDataLen()); explainFrag_ = new(getHeap()) char[explainFragLen_]; - if (str_decode(explainFrag_, explainFragLen_, + if (str_decode(explainFrag_, explainFragLen_, cliInterface.getExplainDataPtr(), cliInterface.getExplainDataLen()) < 0) { diagsArea = pEntryDown->getAtp()->getDiagsArea(); ExRaiseSqlError(getGlobals()->getDefaultHeap(), &diagsArea, EXE_NO_EXPLAIN_INFO); if (diagsArea != pEntryDown->getAtp()->getDiagsArea()) - pEntryDown->getAtp()->setDiagsArea(diagsArea); + pEntryDown->getAtp()->setDiagsAreax(diagsArea); goto label_error2; } // skip ExplainReposInfo and point explainAddr to actual explain structures. - setExplainAddr((Int64)&explainFrag_[sizeof(ExplainReposInfo)]); + setExplainAddr((Int64)&explainFrag_[sizeof(ExplainReposInfo)]); } else { @@ -551,24 +551,24 @@ short ExExplainTcb::processExplainStmt() ExRaiseSqlError(getGlobals()->getDefaultHeap(), &diagsArea, EXE_NO_EXPLAIN_INFO); if (diagsArea != pEntryDown->getAtp()->getDiagsArea()) - pEntryDown->getAtp()->setDiagsArea(diagsArea); + pEntryDown->getAtp()->setDiagsAreax(diagsArea); goto label_error2; } label_return: cliInterface.executeImmediate("control session reset 'EXPLAIN';"); return 0; - + label_error: diagsArea = pEntryDown->getAtp()->getDiagsArea(); if (diagsArea == NULL) diagsArea = ComDiagsArea::allocate(getGlobals()->getDefaultHeap()); - + cliInterface.retrieveSQLDiagnostics(diagsArea); - + if (diagsArea != pEntryDown->getAtp()->getDiagsArea()) - pEntryDown->getAtp()->setDiagsArea(diagsArea); + pEntryDown->getAtp()->setDiagsAreax(diagsArea); label_error2: cliInterface.executeImmediate("control session reset 'EXPLAIN';"); @@ -849,7 +849,7 @@ short ExExplainTcb::work() default: return WORK_BAD_ERROR; } - + if (workState_ != EXPL_DONE) { if (qid_ != NULL) @@ -871,7 +871,7 @@ short ExExplainTcb::work() ExRaiseSqlError(getGlobals()->getDefaultHeap(), &diagsArea, EXE_NO_EXPLAIN_INFO); if (diagsArea != pEntryDown->getAtp()->getDiagsArea()) - pEntryDown->getAtp()->setDiagsArea(diagsArea); + pEntryDown->getAtp()->setDiagsAreax(diagsArea); workState_ = EXPL_ERROR; break; } @@ -906,11 +906,11 @@ short ExExplainTcb::work() { // ERROR during unpacking. // Most likely case is verison-unsupported. - ExRaiseSqlError(getGlobals()->getDefaultHeap(), + ExRaiseSqlError(getGlobals()->getDefaultHeap(), &diagsArea, EXE_NO_EXPLAIN_INFO); if (diagsArea != pEntryDown->getAtp()->getDiagsArea()) - pEntryDown->getAtp()->setDiagsArea(diagsArea); - + pEntryDown->getAtp()->setDiagsAreax(diagsArea); + workState_ = EXPL_ERROR; break; } @@ -924,13 +924,13 @@ short ExExplainTcb::work() } break; case EXPL_ERROR: - + // Must insert Q_SQLERROR in parent up queue. // If Parent can't take anymore, try again later. - + if (qParent_.up->isFull()) return WORK_OK; - + pEntryUp = qParent_.up->getTailEntry(); pEntryDown = qParent_.down->getHeadEntry(); @@ -987,15 +987,15 @@ ExExplainTcb::getNextExplainTree(Int64 explainFragAddr) { // Unpack the EXPLAIN Fragment char * explainFrag = (char*)explainFragAddr; - + ExplainDesc *expDesc = (ExplainDesc*)explainFrag; // Set up space for reallocating objects during unpacking when // there is a difference in image sizes at version migration. // - + ex_queue_entry *pEntryDown = qParent_.down->getHeadEntry(); - ComDiagsArea *diagsArea = + ComDiagsArea *diagsArea = pEntryDown->getAtp()->getDiagsArea(); ExplainDesc dummyExpDesc; if ( (expDesc = (ExplainDesc *) @@ -1003,11 +1003,11 @@ ExExplainTcb::getNextExplainTree(Int64 explainFragAddr) { // ERROR during unpacking. // Most likely case is verison-unsupported. - ExRaiseSqlError(getGlobals()->getDefaultHeap(), + ExRaiseSqlError(getGlobals()->getDefaultHeap(), &diagsArea, EXE_NO_EXPLAIN_INFO); if (diagsArea != pEntryDown->getAtp()->getDiagsArea()) - pEntryDown->getAtp()->setDiagsArea(diagsArea); - + pEntryDown->getAtp()->setDiagsAreax(diagsArea); + workState_ = EXPL_ERROR; return 0; } @@ -1017,13 +1017,13 @@ ExExplainTcb::getNextExplainTree(Int64 explainFragAddr) // due to a version upgrade. Return its new location. // explainFromAddrProcessed_ = TRUE; - + return expDesc; } } explainFromAddrProcessed_ = FALSE; - + workState_ = EXPL_DONE; return 0; @@ -1053,9 +1053,9 @@ ExExplainTcb::getNextExplainTree() { // Define the pattern string // The Wild Card character is '\' - LikePatternString - patternString(stmtPattern_, - (stmtPattern_ ? str_len(stmtPattern_) : 0), + LikePatternString + patternString(stmtPattern_, + (stmtPattern_ ? str_len(stmtPattern_) : 0), CharInfo::ISO88591, "\\", 1 ); @@ -1064,17 +1064,17 @@ ExExplainTcb::getNextExplainTree() if (pattern.error()) { ex_queue_entry *pEntryDown = qParent_.down->getHeadEntry(); - ComDiagsArea *diagsArea = + ComDiagsArea *diagsArea = pEntryDown->getAtp()->getDiagsArea(); - ExRaiseSqlError(getGlobals()->getDefaultHeap(), + ExRaiseSqlError(getGlobals()->getDefaultHeap(), &diagsArea, EXE_INVALID_ESCAPE_SEQUENCE); if (diagsArea != pEntryDown->getAtp()->getDiagsArea()) - pEntryDown->getAtp()->setDiagsArea(diagsArea); - + pEntryDown->getAtp()->setDiagsAreax(diagsArea); + workState_ = EXPL_ERROR; return 0; } - + // A pointer to the statement being considered for a match Statement *stmt; @@ -1091,7 +1091,7 @@ ExExplainTcb::getNextExplainTree() { if(stmt == currentStmt_) break; } - + // Starting at the next statement, search the statement list for // a statement that matches the module name and statement pattern while(stmt = (Statement *)stmtList_->getNext()) @@ -1200,13 +1200,13 @@ ExExplainTcb::getNextExplainTree() // error case. Add an error entry. // Pointer to request entry in parent down queue ex_queue_entry *pEntryDown = qParent_.down->getHeadEntry(); - ComDiagsArea *diagsArea = + ComDiagsArea *diagsArea = pEntryDown->getAtp()->getDiagsArea(); - ExRaiseSqlError(getGlobals()->getDefaultHeap(), + ExRaiseSqlError(getGlobals()->getDefaultHeap(), &diagsArea, EXE_NO_EXPLAIN_INFO); if (diagsArea != pEntryDown->getAtp()->getDiagsArea()) - pEntryDown->getAtp()->setDiagsArea(diagsArea); - + pEntryDown->getAtp()->setDiagsAreax(diagsArea); + workState_ = EXPL_ERROR; return 0; } @@ -1694,7 +1694,7 @@ short ExExplainTcb::getExplainFromRepos(char * qid, Lng32 qidLen) OutputInfo * vi = NULL; char * ptr = NULL; Lng32 len = 0; - + if (cliInterface.initializeInfoList(infoList, TRUE)) { goto label_error; @@ -1710,29 +1710,29 @@ short ExExplainTcb::getExplainFromRepos(char * qid, Lng32 qidLen) (infoList->numEntries() > 1)) { diagsArea = pEntryDown->getAtp()->getDiagsArea(); - ExRaiseSqlError(getGlobals()->getDefaultHeap(), + ExRaiseSqlError(getGlobals()->getDefaultHeap(), &diagsArea, EXE_NO_QID_EXPLAIN_INFO); if (diagsArea != pEntryDown->getAtp()->getDiagsArea()) - pEntryDown->getAtp()->setDiagsArea(diagsArea); + pEntryDown->getAtp()->setDiagsAreax(diagsArea); goto label_error2; } infoList->position(); vi = (OutputInfo*)infoList->getCurr(); - + if (vi->get(0, ptr, len)) goto label_error2; - + explainFragLen_ = str_decoded_len(len - 1); // remove trailing null terminator explainFrag_ = new(getHeap()) char[explainFragLen_]; if (str_decode(explainFrag_, explainFragLen_, ptr, len - 1) < 0) { diagsArea = pEntryDown->getAtp()->getDiagsArea(); - ExRaiseSqlError(getGlobals()->getDefaultHeap(), + ExRaiseSqlError(getGlobals()->getDefaultHeap(), &diagsArea, EXE_NO_EXPLAIN_INFO); if (diagsArea != pEntryDown->getAtp()->getDiagsArea()) - pEntryDown->getAtp()->setDiagsArea(diagsArea); + pEntryDown->getAtp()->setDiagsAreax(diagsArea); goto label_error2; } @@ -1747,9 +1747,9 @@ short ExExplainTcb::getExplainFromRepos(char * qid, Lng32 qidLen) // Return error. goto label_error; } - + // skip ExplainReposInfo and point explainAddr to actual explain structures. - setExplainAddr((Int64)&explainFrag_[sizeof(ExplainReposInfo)]); + setExplainAddr((Int64)&explainFrag_[sizeof(ExplainReposInfo)]); setReposQid(NULL, 0); NADELETEBASIC(queryBuf, getHeap()); @@ -1761,11 +1761,11 @@ short ExExplainTcb::getExplainFromRepos(char * qid, Lng32 qidLen) if (diagsArea == NULL) diagsArea = ComDiagsArea::allocate(getGlobals()->getDefaultHeap()); - + cliInterface.retrieveSQLDiagnostics(diagsArea); - + if (diagsArea != pEntryDown->getAtp()->getDiagsArea()) - pEntryDown->getAtp()->setDiagsArea(diagsArea); + pEntryDown->getAtp()->setDiagsAreax(diagsArea); label_error2: diff --git a/core/sql/executor/ExFastTransport.cpp b/core/sql/executor/ExFastTransport.cpp index a2eaa94d09..cb3d9fdeb7 100644 --- a/core/sql/executor/ExFastTransport.cpp +++ b/core/sql/executor/ExFastTransport.cpp @@ -220,7 +220,7 @@ void ExFastExtractTcb::insertUpQueueEntry(ex_queue::up_status status, ExFastExtractPrivateState &privateState = *((ExFastExtractPrivateState *) downEntry->pstate); - // Initialize the up queue entry. + // Initialize the up queue entry. // // copyAtp() will copy all tuple pointers and the diags area from // the down queue entry to the up queue entry. @@ -231,36 +231,35 @@ void ExFastExtractTcb::insertUpQueueEntry(ex_queue::up_status status, // if (status == ex_queue::Q_NO_DATA && privateState.matchCount_ > 0) { - downEntry->setDiagsArea(NULL); + downEntry->setDiagsAreax(NULL); upEntry->copyAtp(downEntry); } else { upEntry->copyAtp(downEntry); - downEntry->setDiagsArea(NULL); + downEntry->setDiagsAreax(NULL); } upEntry->upState.status = status; upEntry->upState.parentIndex = downEntry->downState.parentIndex; upEntry->upState.downIndex = qParent_.down->getHeadIndex(); upEntry->upState.setMatchNo(privateState.matchCount_); - + // Move any diags to the up queue entry if (diags != NULL) { ComDiagsArea *atpDiags = upEntry->getDiagsArea(); if (atpDiags == NULL) { - // setDiagsArea() does not increment the reference count - upEntry->setDiagsArea(diags); - diags->incrRefCount(); + // setDiagsAreax() does not increment the reference count + upEntry->shareDiagsArea(diags); } else { atpDiags->mergeAfter(*diags); } } - + // Insert into up queue qParent_.up->insert(); @@ -344,11 +343,11 @@ void ExFastExtractTcb::updateWorkATPDiagsArea(ComDiagsArea *da) else { ComDiagsArea * da1 = da; - workAtp_->setDiagsArea(da1); - da1->incrRefCount(); + workAtp_->shareDiagsAreax(da1); } } } + void ExFastExtractTcb::updateWorkATPDiagsArea(ex_queue_entry * centry) { if (centry->getDiagsArea()) @@ -360,9 +359,8 @@ void ExFastExtractTcb::updateWorkATPDiagsArea(ex_queue_entry * centry) else { ComDiagsArea * da = centry->getDiagsArea(); - workAtp_->setDiagsArea(da); - da->incrRefCount(); - centry->setDiagsArea(0); + workAtp_->shareDiagsArea(da); + centry->setDiagsAreax(0); } } } @@ -373,7 +371,7 @@ void ExFastExtractTcb::updateWorkATPDiagsArea(ExeErrorCode rc, const char *msg) if(!da) { da = ComDiagsArea::allocate(getHeap()); - workAtp_->setDiagsArea(da); + workAtp_->setDiagsAreax(da); } if(msg != NULL) { @@ -387,16 +385,16 @@ void ExFastExtractTcb::updateWorkATPDiagsArea(ExeErrorCode rc, const char *msg) } -void ExFastExtractTcb::updateWorkATPDiagsArea(const char *file, +void ExFastExtractTcb::updateWorkATPDiagsArea(const char *file, int line, const char *msg) { ComDiagsArea *da = workAtp_->getDiagsArea(); if(!da) { da = ComDiagsArea::allocate(getHeap()); - workAtp_->setDiagsArea(da); + workAtp_->setDiagsAreax(da); } - + *da << DgSqlCode(-1001) << DgString0(file) << DgInt0(line) @@ -676,47 +674,47 @@ ExWorkProcRetcode ExHdfsFastExtractTcb::work() Int64 failedModTS = -1; Lng32 failedLocBufLen = 1000; char failedLocBuf[failedLocBufLen]; - retcode = + retcode = lobInterfaceDataModCheck(failedModTS, failedLocBuf, failedLocBufLen); if (retcode < 0) { Lng32 cliError = 0; - + Lng32 intParam1 = -retcode; ComDiagsArea * diagsArea = NULL; - ExRaiseSqlError(getHeap(), &diagsArea, + ExRaiseSqlError(getHeap(), &diagsArea, (ExeErrorCode)(EXE_ERROR_FROM_LOB_INTERFACE), - NULL, &intParam1, - &cliError, - NULL, + NULL, &intParam1, + &cliError, + NULL, "HDFS", (char*)"ExpLOBInterfaceDataModCheck", getLobErrStr(intParam1)); - pentry_down->setDiagsArea(diagsArea); + pentry_down->setDiagsAreax(diagsArea); pstate.step_ = EXTRACT_ERROR; break; } - + if (retcode == 1) // check failed { char errStr[200]; - str_sprintf(errStr, "genModTS = %ld, failedModTS = %ld", + str_sprintf(errStr, "genModTS = %ld, failedModTS = %ld", myTdb().getModTSforDir(), failedModTS); - + ComDiagsArea * diagsArea = NULL; - ExRaiseSqlError(getHeap(), &diagsArea, + ExRaiseSqlError(getHeap(), &diagsArea, (ExeErrorCode)(EXE_HIVE_DATA_MOD_CHECK_ERROR), NULL, NULL, NULL, NULL, errStr); - pentry_down->setDiagsArea(diagsArea); + pentry_down->setDiagsAreax(diagsArea); pstate.step_ = EXTRACT_ERROR; break; } - + pstate.step_= EXTRACT_INITIALIZE; } break; - + case EXTRACT_INITIALIZE: { pstate.processingStarted_ = FALSE; @@ -1026,7 +1024,7 @@ ExWorkProcRetcode ExHdfsFastExtractTcb::work() { ComDiagsArea *diagsArea = pentry_down->getDiagsArea(); diagsArea = ComDiagsArea::allocate(getGlobals()->getDefaultHeap()); - pentry_down->setDiagsArea(diagsArea); + pentry_down->setDiagsAreax(diagsArea); pentry_down->getDiagsArea()->mergeAfter(*centry->getDiagsArea()); } @@ -1127,10 +1125,10 @@ ExWorkProcRetcode ExHdfsFastExtractTcb::work() if (diagsArea == NULL) { diagsArea = ComDiagsArea::allocate(getGlobals()->getDefaultHeap()); - pentry_up->setDiagsArea(diagsArea); + pentry_up->setDiagsAreax(diagsArea); } pentry_up->getDiagsArea()->mergeAfter(*workAtp_->getDiagsArea()); - workAtp_->setDiagsArea(NULL); + workAtp_->setDiagsAreax(NULL); } pentry_up->upState.status = ex_queue::Q_SQLERROR; pentry_up->upState.parentIndex @@ -1154,7 +1152,7 @@ ExWorkProcRetcode ExHdfsFastExtractTcb::work() if (isSequenceFile()) { - if (sequenceFileWriter_) + if (sequenceFileWriter_) { sfwRetCode = sequenceFileWriter_->close(); if (!errorOccurred_ && sfwRetCode != SFW_OK ) @@ -1228,13 +1226,13 @@ void ExHdfsFastExtractTcb::insertUpQueueEntry(ex_queue::up_status status, ComDia // if (status == ex_queue::Q_NO_DATA && privateState.matchCount_ > 0) { - downEntry->setDiagsArea(NULL); + downEntry->setDiagsAreax(NULL); upEntry->copyAtp(downEntry); } else { upEntry->copyAtp(downEntry); - downEntry->setDiagsArea(NULL); + downEntry->setDiagsAreax(NULL); } upEntry->upState.status = status; @@ -1250,7 +1248,7 @@ void ExHdfsFastExtractTcb::insertUpQueueEntry(ex_queue::up_status status, ComDia if (da == NULL) { da = ComDiagsArea::allocate(getGlobals()->getDefaultHeap()); - upEntry->setDiagsArea(da); + upEntry->setDiagsAreax(da); } da->addRowCount(privateState.matchCount_); } @@ -1293,8 +1291,6 @@ void ExHdfsFastExtractTcb::createSequenceFileError(Int32 sfwRetCode) NULL, NULL, NULL, NULL, errorMsg, (char *)GetCliGlobals()->getJniErrorStr()); - //ex_queue_entry *pentry_down = qParent_.down->getHeadEntry(); - //pentry_down->setDiagsArea(diagsArea); updateWorkATPDiagsArea(diagsArea); } diff --git a/core/sql/executor/ExHbaseAccess.cpp b/core/sql/executor/ExHbaseAccess.cpp index 461c5dcc19..4f8c51fb46 100644 --- a/core/sql/executor/ExHbaseAccess.cpp +++ b/core/sql/executor/ExHbaseAccess.cpp @@ -706,24 +706,24 @@ short ExHbaseAccessTcb::setupError(NAHeap *heap, ex_queue_pair &qparent, Lng32 r // Make sure retcode is positive. if (retcode < 0) retcode = -retcode; - + if ((ABS(retcode) >= HBASE_MIN_ERROR_NUM) && (ABS(retcode) <= HBASE_MAX_ERROR_NUM)) { ex_queue_entry *pentry_down = qparent.down->getHeadEntry(); - + Lng32 cliError = 0; - + Lng32 intParam1 = -retcode; ComDiagsArea * diagsArea = NULL; - ExRaiseSqlError(heap, &diagsArea, - (ExeErrorCode)(8448), NULL, &intParam1, - &cliError, NULL, + ExRaiseSqlError(heap, &diagsArea, + (ExeErrorCode)(8448), NULL, &intParam1, + &cliError, NULL, (str ? (char*)str : (char*)" "), getHbaseErrStr(retcode), - (str2 ? (char*)str2 : - (char *)GetCliGlobals()->getJniErrorStr())); - pentry_down->setDiagsArea(diagsArea); + (str2 ? (char*)str2 : + (char *)GetCliGlobals()->getJniErrorStr())); + pentry_down->setDiagsAreax(diagsArea); return -1; } @@ -736,47 +736,47 @@ short ExHbaseAccessTcb::setupError(Lng32 retcode, const char * str, const char * // Make sure retcode is positive. if (retcode < 0) retcode = -retcode; - + if ((ABS(retcode) >= HBASE_MIN_ERROR_NUM) && (ABS(retcode) <= HBASE_MAX_ERROR_NUM)) { ex_queue_entry *pentry_down = qparent_.down->getHeadEntry(); - + Lng32 cliError = 0; - + Lng32 intParam1 = -retcode; ComDiagsArea * diagsArea = NULL; - ExRaiseSqlError(getHeap(), &diagsArea, - (ExeErrorCode)(8448), NULL, &intParam1, - &cliError, NULL, + ExRaiseSqlError(getHeap(), &diagsArea, + (ExeErrorCode)(8448), NULL, &intParam1, + &cliError, NULL, (str ? (char*)str : (char*)" "), getHbaseErrStr(retcode), - (str2 ? (char*)str2 : - (char *)GetCliGlobals()->getJniErrorStr())); - pentry_down->setDiagsArea(diagsArea); + (str2 ? (char*)str2 : + (char *)GetCliGlobals()->getJniErrorStr())); + pentry_down->setDiagsAreax(diagsArea); return -1; } return 0; } -short ExHbaseAccessTcb::raiseError(Lng32 errcode, +short ExHbaseAccessTcb::raiseError(Lng32 errcode, Lng32 * intParam1, - const char * str1, + const char * str1, const char * str2) { // Make sure retcode is positive. if (errcode < 0) errcode = -errcode; - + ex_queue_entry *pentry_down = qparent_.down->getHeadEntry(); - + ComDiagsArea * diagsArea = NULL; - ExRaiseSqlError(getHeap(), &diagsArea, + ExRaiseSqlError(getHeap(), &diagsArea, (ExeErrorCode)(errcode), NULL, intParam1, NULL, NULL, str1, str2, NULL); - pentry_down->setDiagsArea(diagsArea); + pentry_down->setDiagsAreax(diagsArea); return 0; } @@ -833,15 +833,15 @@ short ExHbaseAccessTcb::handleDone(ExWorkProcRetcode &rc, Int64 rowsAffected) ComDiagsArea * diagsArea = up_entry->getDiagsArea(); if (!diagsArea) { - diagsArea = + diagsArea = ComDiagsArea::allocate(getGlobals()->getDefaultHeap()); - up_entry->setDiagsArea(diagsArea); + up_entry->setDiagsAreax(diagsArea); } diagsArea->addRowCount(rowsAffected); } } qparent_.up->insert(); - + qparent_.down->removeHead(); return 0; @@ -857,7 +857,7 @@ short ExHbaseAccessTcb::createColumnwiseRow() ExpTupleDesc * asciiSourceTD = hbaseAccessTdb().workCriDesc_->getTupleDescriptor (hbaseAccessTdb().asciiTuppIndex_); - + for (Lng32 i = 0; i < asciiSourceTD->numAttrs(); i++) { Attributes * attr = asciiSourceTD->getAttr(i); @@ -1346,18 +1346,18 @@ Lng32 ExHbaseAccessTcb::createSQRowFromHbaseFormat(Int64 *latestRowTimestamp) v = *(UInt16*)colName.data(); else if (colName.length() == sizeof(ULng32)) v = *(ULng32*)colName.data(); - + str_sprintf(buf, "%ld", v); } - + ComDiagsArea * diagsArea = NULL; ExRaiseSqlError( getHeap(), &diagsArea, (ExeErrorCode) EXE_DEFAULT_VALUE_INCONSISTENT_ERROR, - NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, (hbaseAccessTdb().hbaseMapTable() ? colName.data() : buf), hbaseAccessTdb().getTableName()); - pentry_down->setDiagsArea(diagsArea); + pentry_down->setDiagsAreax(diagsArea); return -1; } @@ -1367,10 +1367,9 @@ Lng32 ExHbaseAccessTcb::createSQRowFromHbaseFormat(Int64 *latestRowTimestamp) { nullVal = *(short*)defVal; *(short*)&asciiRow_[attr->getNullIndOffset()] = nullVal; - defValPtr += 2; } - + Lng32 copyLen; if (! nullVal) { diff --git a/core/sql/executor/ExHbaseIUD.cpp b/core/sql/executor/ExHbaseIUD.cpp index bad439dd7f..b61ebbc55b 100644 --- a/core/sql/executor/ExHbaseIUD.cpp +++ b/core/sql/executor/ExHbaseIUD.cpp @@ -549,19 +549,19 @@ ExWorkProcRetcode ExHbaseAccessInsertSQTcb::work() if (retcode == HBASE_DUP_ROW_ERROR) // row exists, return error { ComDiagsArea * diagsArea = NULL; - ExRaiseSqlError(getHeap(), &diagsArea, + ExRaiseSqlError(getHeap(), &diagsArea, (ExeErrorCode)(8102)); - pentry_down->setDiagsArea(diagsArea); + pentry_down->setDiagsAreax(diagsArea); step_ = HANDLE_ERROR; break; } - + if (setupError(retcode, "ExpHbaseInterface::checkAndInsertRow")) { step_ = HANDLE_ERROR; break; } - + if (getHbaseAccessStats()) getHbaseAccessStats()->incUsedRows(); @@ -587,7 +587,7 @@ ExWorkProcRetcode ExHbaseAccessInsertSQTcb::work() if (asyncCompleteRetryCount_ < 10) timeout = -1; else { - asyncOperationTimeout_ = asyncOperationTimeout_ * 2; + asyncOperationTimeout_ = asyncOperationTimeout_ * 2; timeout = asyncOperationTimeout_; } retcode = ehi_->completeAsyncOperation(timeout, resultArray_, 1); @@ -602,7 +602,7 @@ ExWorkProcRetcode ExHbaseAccessInsertSQTcb::work() } if (resultArray_[0] == FALSE) { ComDiagsArea * diagsArea = NULL; - ExRaiseSqlError(getHeap(), &diagsArea, + ExRaiseSqlError(getHeap(), &diagsArea, (ExeErrorCode)(8102)); pentry_down->setDiagsArea(diagsArea); step_ = HANDLE_ERROR; @@ -1050,7 +1050,7 @@ ExWorkProcRetcode ExHbaseAccessUpsertVsbbSQTcb::work() ComDiagsArea * diagsArea = NULL; ExRaiseSqlError(getHeap(), &diagsArea, (ExeErrorCode)(8102)); - pentry_down->setDiagsArea(diagsArea); + pentry_down->setDiagsAreax(diagsArea); step_ = HANDLE_ERROR; break; } @@ -1412,7 +1412,6 @@ ExWorkProcRetcode ExHbaseAccessBulkLoadPrepSQTcb::work() srand(time(0)); // Set up HDFS file for sample table. - ContextCli *currContext = getGlobals()->castToExExeStmtGlobals()->getCliGlobals()->currContext(); Text samplePath = std::string(((ExHbaseAccessTdb&)hbaseAccessTdb()).getSampleLocation()) + ((ExHbaseAccessTdb&)hbaseAccessTdb()).getTableName() ; @@ -1428,12 +1427,12 @@ ExWorkProcRetcode ExHbaseAccessBulkLoadPrepSQTcb::work() NADELETE(sampleFileHdfsClient_, HdfsClient, getHeap()); sampleFileHdfsClient_ = NULL; } - } + } if (hdfsClientRetcode != HDFS_CLIENT_OK) { ComDiagsArea * diagsArea = NULL; ExRaiseSqlError(getHeap(), &diagsArea, (ExeErrorCode)(8110)); - pentry_down->setDiagsArea(diagsArea); + pentry_down->setDiagsAreax(diagsArea); step_ = HANDLE_ERROR; break; } @@ -1525,13 +1524,13 @@ ExWorkProcRetcode ExHbaseAccessBulkLoadPrepSQTcb::work() if (memcmp(prevRowId_, rowId_.val, rowId_.len) == 0) { if (((ExHbaseAccessTdb&) hbaseAccessTdb()).getNoDuplicates() || - ((NOT ((ExHbaseAccessTdb&) hbaseAccessTdb()).getNoDuplicates()) && - hbaseAccessTdb().getContinueOnError())) { + ((NOT ((ExHbaseAccessTdb&) hbaseAccessTdb()).getNoDuplicates()) && + hbaseAccessTdb().getContinueOnError())) { //8110 Duplicate rows detected. ComDiagsArea * diagsArea = NULL; ExRaiseSqlError(getHeap(), &diagsArea, (ExeErrorCode)(8110)); - pentry_down->setDiagsArea(diagsArea); + pentry_down->setDiagsAreax(diagsArea); if (hbaseAccessTdb().getContinueOnError()) { if (pentry_down->getDiagsArea()) { Lng32 errorCount = pentry_down->getDiagsArea()->getNumber(DgSqlCode::ERROR_); @@ -1633,7 +1632,7 @@ ExWorkProcRetcode ExHbaseAccessBulkLoadPrepSQTcb::work() case HANDLE_EXCEPTION: { exceptionCount = 0; - ExHbaseAccessTcb::incrErrorCount( ehi_,exceptionCount, hbaseAccessTdb().getErrCountTab(), + ExHbaseAccessTcb::incrErrorCount( ehi_,exceptionCount, hbaseAccessTdb().getErrCountTab(), hbaseAccessTdb().getErrCountRowId()); if (hbaseAccessTdb().getMaxErrorRows() > 0) { @@ -1650,7 +1649,7 @@ ExWorkProcRetcode ExHbaseAccessBulkLoadPrepSQTcb::work() //8113 max number of error rows exceeded. ExRaiseSqlError(getHeap(), &diagsArea, (ExeErrorCode)(EXE_MAX_ERROR_ROWS_EXCEEDED)); - pentry_down->setDiagsArea(diagsArea); + pentry_down->setDiagsAreax(diagsArea); step_ = HANDLE_ERROR; break; } @@ -1719,7 +1718,7 @@ ExWorkProcRetcode ExHbaseAccessBulkLoadPrepSQTcb::work() { rc = 0; // moveRowToUpQueue also increments matches_ - if (moveRowToUpQueue(convertRow_, hbaseAccessTdb().convertRowLen(), + if (moveRowToUpQueue(convertRow_, hbaseAccessTdb().convertRowLen(), &rc, FALSE)) return rc; } @@ -1735,26 +1734,26 @@ ExWorkProcRetcode ExHbaseAccessBulkLoadPrepSQTcb::work() { if (step_ == ALL_DONE && eodSeen) { exceptionCount = 0; - ExHbaseAccessTcb::getErrorCount( ehi_,exceptionCount, hbaseAccessTdb().getErrCountTab(), + ExHbaseAccessTcb::getErrorCount( ehi_,exceptionCount, hbaseAccessTdb().getErrCountTab(), hbaseAccessTdb().getErrCountRowId()); errorRowCount = (Lng32) exceptionCount; if (errorRowCount != 0 || loggingErrorDiags_ != NULL) { ex_queue_entry * down_entry = qparent_.down->getHeadEntry(); ComDiagsArea * diagsArea = down_entry->getDiagsArea(); if (!diagsArea) { - diagsArea = ComDiagsArea::allocate(getGlobals()->getDefaultHeap()); - down_entry->setDiagsArea(diagsArea); + diagsArea = ComDiagsArea::allocate(getGlobals()->getDefaultHeap()); + down_entry->setDiagsAreax(diagsArea); } if (loggingErrorDiags_ != NULL) { diagsArea->mergeAfter(*loggingErrorDiags_); loggingErrorDiags_->clear(); } - if (errorRowCount > 0) + if (errorRowCount > 0) ExRaiseSqlWarning((NAMemory *)getHeap(), &diagsArea, (ExeErrorCode)(EXE_ERROR_ROWS_FOUND), (ComCondition **)NULL, &errorRowCount); } } - + if (handleDone(rc, (step_ == ALL_DONE ? matches_ : 0))) return rc; lastHandledStep_ = step_; @@ -2273,14 +2272,14 @@ ExWorkProcRetcode ExHbaseUMDtrafUniqueTaskTcb::work(short &rc) tcb_->hbaseAccessTdb().useRegionXn(), -1, // colTS tcb_->asyncOperation_, - tcb_->hbaseAccessTdb().getColIndexOfPK1()); + tcb_->hbaseAccessTdb().getColIndexOfPK1()); if (retcode == HBASE_DUP_ROW_ERROR) { ComDiagsArea * diagsArea = NULL; - ExRaiseSqlError(tcb_->getHeap(), &diagsArea, + ExRaiseSqlError(tcb_->getHeap(), &diagsArea, (ExeErrorCode)(8102)); - pentry_down->setDiagsArea(diagsArea); + pentry_down->setDiagsAreax(diagsArea); step_ = HANDLE_ERROR; break; } @@ -2289,7 +2288,7 @@ ExWorkProcRetcode ExHbaseUMDtrafUniqueTaskTcb::work(short &rc) step_ = HANDLE_ERROR; break; } - + if (tcb_->getHbaseAccessStats()) tcb_->getHbaseAccessStats()->incUsedRows(); @@ -2304,7 +2303,7 @@ ExWorkProcRetcode ExHbaseUMDtrafUniqueTaskTcb::work(short &rc) case NEXT_ROW_AFTER_UPDATE: { tcb_->currRowidIdx_++; - + if (tcb_->hbaseAccessTdb().returnRow()) { step_ = EVAL_RETURN_ROW_EXPRS; @@ -4370,7 +4369,7 @@ ExWorkProcRetcode ExHbaseAccessSQRowsetTcb::work() ComDiagsArea * diagsArea = NULL; ExRaiseSqlError(getHeap(), &diagsArea, (ExeErrorCode)(8102)); - pentry_down->setDiagsArea(diagsArea); + pentry_down->setDiagsAreax(diagsArea); step_ = HANDLE_ERROR; break; } diff --git a/core/sql/executor/ExHdfsScan.cpp b/core/sql/executor/ExHdfsScan.cpp index c49a6a0c95..4ce92574f1 100644 --- a/core/sql/executor/ExHdfsScan.cpp +++ b/core/sql/executor/ExHdfsScan.cpp @@ -382,26 +382,26 @@ Int32 ExHdfsScanTcb::fixup() void brkpoint() {} -short ExHdfsScanTcb::setupError(Lng32 exeError, Lng32 retcode, +short ExHdfsScanTcb::setupError(Lng32 exeError, Lng32 retcode, const char * str, const char * str2, const char * str3) { // Make sure retcode is positive. if (retcode < 0) retcode = -retcode; - + ex_queue_entry *pentry_down = qparent_.down->getHeadEntry(); - + Lng32 intParam1 = retcode; Lng32 intParam2 = 0; ComDiagsArea * diagsArea = NULL; - ExRaiseSqlError(getHeap(), &diagsArea, - (ExeErrorCode)(exeError), NULL, &intParam1, - &intParam2, NULL, + ExRaiseSqlError(getHeap(), &diagsArea, + (ExeErrorCode)(exeError), NULL, &intParam1, + &intParam2, NULL, (str ? (char*)str : (char*)" "), (str2 ? (char*)str2 : (char*)" "), (str3 ? (char*)str3 : (char*)" ")); - - pentry_down->setDiagsArea(diagsArea); + + pentry_down->setDiagsAreax(diagsArea); return -1; } @@ -498,7 +498,7 @@ ExWorkProcRetcode ExHdfsScanTcb::work() { // TBD } - + Int64 failedModTS = -1; Lng32 failedLocBufLen = 1000; char failedLocBuf[failedLocBufLen]; @@ -511,38 +511,38 @@ ExWorkProcRetcode ExHdfsScanTcb::work() numOfPartLevels, failedModTS, failedLocBuf, failedLocBufLen); - + if (retcode < 0) { Lng32 cliError = 0; - + Lng32 intParam1 = -retcode; ComDiagsArea * diagsArea = NULL; - ExRaiseSqlError(getHeap(), &diagsArea, + ExRaiseSqlError(getHeap(), &diagsArea, (ExeErrorCode)(EXE_ERROR_FROM_LOB_INTERFACE), - NULL, &intParam1, - &cliError, - NULL, + NULL, &intParam1, + &cliError, + NULL, "HDFS", (char*)"ExpLOBInterfaceDataModCheck", getLobErrStr(intParam1)); - pentry_down->setDiagsArea(diagsArea); + pentry_down->setDiagsAreax(diagsArea); step_ = HANDLE_ERROR_AND_DONE; break; - } + } if (retcode == 1) // check failed { char errStr[200]; - str_sprintf(errStr, "genModTS = %ld, failedModTS = %ld", + str_sprintf(errStr, "genModTS = %ld, failedModTS = %ld", modTS, failedModTS); ComDiagsArea * diagsArea = NULL; - ExRaiseSqlError(getHeap(), &diagsArea, + ExRaiseSqlError(getHeap(), &diagsArea, (ExeErrorCode)(EXE_HIVE_DATA_MOD_CHECK_ERROR), NULL, NULL, NULL, NULL, errStr); - pentry_down->setDiagsArea(diagsArea); + pentry_down->setDiagsAreax(diagsArea); step_ = HANDLE_ERROR_AND_DONE; break; } @@ -709,7 +709,7 @@ ExWorkProcRetcode ExHdfsScanTcb::work() currRangeNum_++; hdfo_ = getRange(currRangeNum_); } - + hdfsOffset_ = hdfo_->getStartOffset(); bytesLeft_ = hdfo_->getBytesToRead(); @@ -720,7 +720,7 @@ ExWorkProcRetcode ExHdfsScanTcb::work() step_ = OPEN_HDFS_CURSOR; } - + break; case OPEN_HDFS_CURSOR: @@ -728,44 +728,44 @@ ExWorkProcRetcode ExHdfsScanTcb::work() retcode = 0; if (isSequenceFile() && !sequenceFileReader_) { - sequenceFileReader_ = new(getHeap()) + sequenceFileReader_ = new(getHeap()) SequenceFileReader((NAHeap *)getHeap()); sfrRetCode = sequenceFileReader_->init(); - + if (sfrRetCode != JNI_OK) { ComDiagsArea * diagsArea = NULL; - ExRaiseSqlError(getHeap(), &diagsArea, (ExeErrorCode)(8447), NULL, + ExRaiseSqlError(getHeap(), &diagsArea, (ExeErrorCode)(8447), NULL, NULL, NULL, NULL, sequenceFileReader_->getErrorText(sfrRetCode), NULL); - pentry_down->setDiagsArea(diagsArea); + pentry_down->setDiagsAreax(diagsArea); step_ = HANDLE_ERROR; break; } } - + if (isSequenceFile()) { sfrRetCode = sequenceFileReader_->open(hdfsFileName_); - + if (sfrRetCode == JNI_OK) { // Seek to start offset sfrRetCode = sequenceFileReader_->seeknSync(hdfsOffset_); } - + if (sfrRetCode != JNI_OK) { ComDiagsArea * diagsArea = NULL; - ExRaiseSqlError(getHeap(), &diagsArea, (ExeErrorCode)(8447), NULL, + ExRaiseSqlError(getHeap(), &diagsArea, (ExeErrorCode)(8447), NULL, NULL, NULL, NULL, sequenceFileReader_->getErrorText(sfrRetCode), NULL); - pentry_down->setDiagsArea(diagsArea); + pentry_down->setDiagsAreax(diagsArea); step_ = HANDLE_ERROR; break; } } else { - Int64 rangeTail = hdfo_->fileIsSplitEnd() ? + Int64 rangeTail = hdfo_->fileIsSplitEnd() ? hdfsScanTdb().rangeTailIOSize_ : 0; openType = 2; // must open retcode = ExpLOBInterfaceSelectCursor @@ -783,8 +783,8 @@ ExWorkProcRetcode ExHdfsScanTcb::work() requestTag_, Lob_Memory, 0, // not check status (NOT hdfsScanTdb().hdfsPrefetch()), //1, // waited op - - hdfsOffset_, + + hdfsOffset_, hdfsScanBufMaxSize_, bytesRead_, NULL, @@ -792,7 +792,7 @@ ExWorkProcRetcode ExHdfsScanTcb::work() openType, // &hdfsErrorDetail ); - + if ((retcode < 0) && ((hdfsErrorDetail == ENOENT) || (hdfsErrorDetail == EAGAIN))) { @@ -803,31 +803,31 @@ ExWorkProcRetcode ExHdfsScanTcb::work() char errBuf[len]; snprintf(errBuf, len, "%s (fileLoc: %s)", hdfsScanTdb().tableName(), hdfsFileName_); - ExRaiseSqlError(getHeap(), &diagsArea, + ExRaiseSqlError(getHeap(), &diagsArea, (ExeErrorCode)(EXE_TABLE_NOT_FOUND), NULL, NULL, NULL, NULL, errBuf); } else - ExRaiseSqlError(getHeap(), &diagsArea, + ExRaiseSqlError(getHeap(), &diagsArea, (ExeErrorCode)(EXE_HIVE_DATA_MOD_CHECK_ERROR)); - pentry_down->setDiagsArea(diagsArea); + pentry_down->setDiagsAreax(diagsArea); step_ = HANDLE_ERROR_AND_DONE; break; } - // preopen next range. - if ( (currRangeNum_ + 1) < (beginRangeNum_ + numRanges_) ) + // preopen next range. + if ( (currRangeNum_ + 1) < (beginRangeNum_ + numRanges_) ) { hdfo = getRange(currRangeNum_ + 1); - + hdfsFileName_ = hdfo->fileName(); sprintf(cursorId, "%d", currRangeNum_ + 1); - rangeTail = hdfo->fileIsSplitEnd() ? + rangeTail = hdfo->fileIsSplitEnd() ? hdfsScanTdb().rangeTailIOSize_ : 0; openType = 1; // preOpen - + retcode = ExpLOBInterfaceSelectCursor (lobGlob_, (getStatsEntry() != NULL ? getStatsEntry()->castToExHdfsScanStats() : NULL), @@ -838,13 +838,13 @@ ExWorkProcRetcode ExHdfsScanTcb::work() hdfsScanTdb().port_, 0, NULL,//handle not relevant for non lob access hdfo->getBytesToRead() + rangeTail, // max bytes - cursorId, - + cursorId, + requestTag_, Lob_Memory, 0, // not check status (NOT hdfsScanTdb().hdfsPrefetch()), //1, // waited op - - hdfo->getStartOffset(), + + hdfo->getStartOffset(), hdfsScanBufMaxSize_, bytesRead_, NULL, @@ -852,36 +852,36 @@ ExWorkProcRetcode ExHdfsScanTcb::work() openType, &hdfsErrorDetail ); - + hdfsFileName_ = hdfo_->fileName(); - } + } } - + if (retcode < 0) { Lng32 cliError = 0; - + Lng32 intParam1 = -retcode; ComDiagsArea * diagsArea = NULL; - ExRaiseSqlError(getHeap(), &diagsArea, - (ExeErrorCode)(EXE_ERROR_FROM_LOB_INTERFACE), NULL, - &intParam1, - &hdfsErrorDetail, - NULL, + ExRaiseSqlError(getHeap(), &diagsArea, + (ExeErrorCode)(EXE_ERROR_FROM_LOB_INTERFACE), NULL, + &intParam1, + &hdfsErrorDetail, + NULL, "HDFS", (char*)"ExpLOBInterfaceSelectCursor/open", getLobErrStr(intParam1)); - - pentry_down->setDiagsArea(diagsArea); + + pentry_down->setDiagsAreax(diagsArea); step_ = HANDLE_ERROR; break; - } - trailingPrevRead_ = 0; + } + trailingPrevRead_ = 0; firstBufOfFile_ = true; numBytesProcessedInRange_ = 0; step_ = GET_HDFS_DATA; - } + } break; case GET_HDFS_DATA: @@ -890,8 +890,8 @@ ExWorkProcRetcode ExHdfsScanTcb::work() ex_assert(bytesToRead >= 0, "bytesToRead less than zero."); if (hdfo_->fileIsSplitEnd() && !isSequenceFile()) { - if (bytesLeft_ > 0) - bytesToRead = min(bytesToRead, + if (bytesLeft_ > 0) + bytesToRead = min(bytesToRead, (bytesLeft_ + hdfsScanTdb().rangeTailIOSize_)); else bytesToRead = hdfsScanTdb().rangeTailIOSize_; @@ -913,21 +913,21 @@ ExWorkProcRetcode ExHdfsScanTcb::work() hdfsStats_->getHdfsTimer().start(); retcode = 0; - + if (isSequenceFile()) { - sfrRetCode = sequenceFileReader_->fetchRowsIntoBuffer(stopOffset_, - hdfsScanBuffer_, - hdfsScanBufMaxSize_, //bytesToRead, + sfrRetCode = sequenceFileReader_->fetchRowsIntoBuffer(stopOffset_, + hdfsScanBuffer_, + hdfsScanBufMaxSize_, //bytesToRead, bytesRead_, hdfsScanTdb().recordDelimiter_); if (sfrRetCode != JNI_OK && sfrRetCode != SFR_NOMORE) { ComDiagsArea * diagsArea = NULL; - ExRaiseSqlError(getHeap(), &diagsArea, (ExeErrorCode)(8447), NULL, + ExRaiseSqlError(getHeap(), &diagsArea, (ExeErrorCode)(8447), NULL, NULL, NULL, NULL, sequenceFileReader_->getErrorText(sfrRetCode), NULL); - pentry_down->setDiagsArea(diagsArea); + pentry_down->setDiagsAreax(diagsArea); step_ = HANDLE_ERROR_WITH_CLOSE; break; } @@ -943,17 +943,15 @@ ExWorkProcRetcode ExHdfsScanTcb::work() (lobGlob_, (getStatsEntry() != NULL ? getStatsEntry()->castToExHdfsScanStats() : NULL), hdfsFileName_, - NULL, + NULL, (Lng32)Lob_External_HDFS_File, hdfsScanTdb().hostName_, hdfsScanTdb().port_, - 0, NULL, + 0, NULL, 0, cursorId_, - requestTag_, Lob_Memory, 0, // not check status (NOT hdfsScanTdb().hdfsPrefetch()), //1, // waited op - hdfsOffset_, bytesToRead, bytesRead_, @@ -962,32 +960,32 @@ ExWorkProcRetcode ExHdfsScanTcb::work() 0 // openType, not applicable for read &hdfsErrorDetail ); - + if (hdfsStats_) { hdfsStats_->incMaxHdfsIOTime(hdfsStats_->getHdfsTimer().stop()); hdfsStats_->incHdfsCalls(); - } + } if (retcode < 0) { Lng32 cliError = 0; - + Lng32 intParam1 = -retcode; ComDiagsArea * diagsArea = NULL; - ExRaiseSqlError(getHeap(), &diagsArea, - (ExeErrorCode)(EXE_ERROR_FROM_LOB_INTERFACE), NULL, - &intParam1, - &hdfsErrorDetail, - NULL, + ExRaiseSqlError(getHeap(), &diagsArea, + (ExeErrorCode)(EXE_ERROR_FROM_LOB_INTERFACE), NULL, + &intParam1, + &hdfsErrorDetail, + NULL, "HDFS", (char*)"ExpLOBInterfaceSelectCursor/read", getLobErrStr(intParam1)); - pentry_down->setDiagsArea(diagsArea); + pentry_down->setDiagsAreax(diagsArea); step_ = HANDLE_ERROR_WITH_CLOSE; break; } } - + if (bytesRead_ <= 0) { // Finished with this file. Unexpected? Warning/event? @@ -1007,7 +1005,7 @@ ExWorkProcRetcode ExHdfsScanTcb::work() bytesRead_++; } if (bytesRead_ > bytesLeft_) - { + { if (isSequenceFile()) endOfRequestedRange_ = hdfsScanBuffer_ + bytesRead_; else @@ -1037,10 +1035,10 @@ ExWorkProcRetcode ExHdfsScanTcb::work() // first record delimiter. hdfsBufNextRow_ = hdfs_strchr(hdfsScanBuffer_, - hdfsScanTdb().recordDelimiter_, - hdfsScanBuffer_+trailingPrevRead_+ - min(bytesRead_, hdfo_->bytesToRead_), - checkRangeDelimiter_, + hdfsScanTdb().recordDelimiter_, + hdfsScanBuffer_+trailingPrevRead_+ + min(bytesRead_, hdfo_->bytesToRead_), + checkRangeDelimiter_, hdfsScanTdb().getHiveScanMode(), &changedLen); // May be that the record is too long? Or data isn't ascii? // Or delimiter is incorrect. @@ -1055,39 +1053,39 @@ ExWorkProcRetcode ExHdfsScanTcb::work() // is less than buffer size. step_ = CLOSE_HDFS_CURSOR; } - else + else { ComDiagsArea *diagsArea = NULL; - ExRaiseSqlError(getHeap(), &diagsArea, - (ExeErrorCode)(8446), NULL, + ExRaiseSqlError(getHeap(), &diagsArea, + (ExeErrorCode)(8446), NULL, NULL, NULL, NULL, (char*)"No record delimiter found in buffer from hdfsRead.", NULL); // no need to log errors in this case (bulk load) since // this is a major issue and needs to be corrected - pentry_down->setDiagsArea(diagsArea); + pentry_down->setDiagsAreax(diagsArea); step_ = HANDLE_ERROR_WITH_CLOSE; } break; } - + hdfsBufNextRow_ += 1 + changedLen; // point past record delimiter. //add changedLen since hdfs_strchr will remove the pointer ahead to remove the \r } else hdfsBufNextRow_ = hdfsScanBuffer_; - + debugPrevRow_ = hdfsScanBuffer_; // By convention, at // beginning of scan, the // prev is set to next. - debugtrailingPrevRead_ = 0; + debugtrailingPrevRead_ = 0; debugPenultimatePrevRow_ = NULL; firstBufOfFile_ = false; hdfsOffset_ += bytesRead_; step_ = PROCESS_HDFS_ROW; - } + } break; case PROCESS_HDFS_ROW: @@ -1095,7 +1093,7 @@ ExWorkProcRetcode ExHdfsScanTcb::work() if (!useLibhdfsScan_ && hdfsBufNextRow_ == NULL) { step_ = TRAF_HDFS_READ; break; - } + } exception_ = FALSE; nextStep_ = NOT_STARTED; debugPenultimatePrevRow_ = debugPrevRow_; @@ -1106,7 +1104,7 @@ ExWorkProcRetcode ExHdfsScanTcb::work() int err = 0; char *startOfNextRow = extractAndTransformAsciiSourceToSqlRow(err, transformDiags, hdfsScanTdb().getHiveScanMode()); - QRLogger::log(CAT_SQL_EXE, LL_DEBUG, "HdfsBufRow 0x%lx StartOfNextRow 0x%lx RowLength %ld ", hdfsBufNextRow_, startOfNextRow, + QRLogger::log(CAT_SQL_EXE, LL_DEBUG, "HdfsBufRow 0x%lx StartOfNextRow 0x%lx RowLength %ld ", hdfsBufNextRow_, startOfNextRow, startOfNextRow-hdfsBufNextRow_); bool rowWillBeSelected = true; lastErrorCnd_ = NULL; @@ -1123,7 +1121,7 @@ ExWorkProcRetcode ExHdfsScanTcb::work() else { if (transformDiags) - pentry_down->setDiagsArea(transformDiags); + pentry_down->setDiagsAreax(transformDiags); step_ = HANDLE_ERROR_WITH_CLOSE; break; } @@ -1131,11 +1129,11 @@ ExWorkProcRetcode ExHdfsScanTcb::work() if (startOfNextRow == NULL) { - if (useLibhdfsScan_) + if (useLibhdfsScan_) step_ = REPOS_HDFS_DATA; else { - if (retArray_[IS_EOF]) { - headRoomCopied_ = 0; + if (retArray_[IS_EOF]) { + headRoomCopied_ = 0; step_ = TRAF_HDFS_READ; } else @@ -1328,11 +1326,11 @@ ExWorkProcRetcode ExHdfsScanTcb::work() { diagsArea = ComDiagsArea::allocate(getGlobals()->getDefaultHeap()); - pentry_down->setDiagsArea (diagsArea); + pentry_down->setDiagsAreax(diagsArea); } pentry_down->getDiagsArea()-> mergeAfter(*up_entry->getDiagsArea()); - up_entry->setDiagsArea(NULL); + up_entry->setDiagsAreax(NULL); step_ = HANDLE_ERROR_WITH_CLOSE; break; } @@ -1399,11 +1397,11 @@ ExWorkProcRetcode ExHdfsScanTcb::work() { diagsArea = ComDiagsArea::allocate(getGlobals()->getDefaultHeap()); - pentry_down->setDiagsArea (diagsArea); + pentry_down->setDiagsAreax(diagsArea); } pentry_down->getDiagsArea()-> mergeAfter(*up_entry->getDiagsArea()); - up_entry->setDiagsArea(NULL); + up_entry->setDiagsAreax(NULL); if (useLibhdfsScan_) step_ = HANDLE_ERROR_WITH_CLOSE; else @@ -1428,7 +1426,7 @@ ExWorkProcRetcode ExHdfsScanTcb::work() if (getStatsEntry()) getStatsEntry()->incActualRowsReturned(); - workAtp_->setDiagsArea(NULL); // get rid of warnings. + workAtp_->setDiagsAreax(NULL); // get rid of warnings. if (((pentry_down->downState.request == ex_queue::GET_N) && (pentry_down->downState.requestValue == matches_)) || (pentry_down->downState.request == ex_queue::GET_NOMORE)) { @@ -1439,7 +1437,7 @@ ExWorkProcRetcode ExHdfsScanTcb::work() } else step_ = PROCESS_HDFS_ROW; - break; + break; } case REPOS_HDFS_DATA: { @@ -1453,7 +1451,7 @@ ExWorkProcRetcode ExHdfsScanTcb::work() if (numBytesProcessedInRange_ < hdfo_->getBytesToRead()) scanAgain = true; } - else + else if (bytesLeft_ > 0) scanAgain = true; } @@ -1475,17 +1473,17 @@ ExWorkProcRetcode ExHdfsScanTcb::work() // Finally, trailingPrevRead_ is used in the // extractSourceFields method to keep from processing // bytes left in the buffer from the previous read. - if ((trailingPrevRead_ > 0) && + if ((trailingPrevRead_ > 0) && (hdfsBufNextRow_[0] == RANGE_DELIMITER)) { checkRangeDelimiter_ = FALSE; step_ = CLOSE_HDFS_CURSOR; break; - } - memmove(hdfsScanBuffer_, hdfsBufNextRow_, + } + memmove(hdfsScanBuffer_, hdfsBufNextRow_, (size_t)trailingPrevRead_); step_ = GET_HDFS_DATA; - } + } else { trailingPrevRead_ = 0; @@ -1494,7 +1492,7 @@ ExWorkProcRetcode ExHdfsScanTcb::work() break; } case CLOSE_HDFS_CURSOR: - { + { retcode = 0; if (isSequenceFile()) { @@ -1502,9 +1500,9 @@ ExWorkProcRetcode ExHdfsScanTcb::work() if (sfrRetCode != JNI_OK) { ComDiagsArea * diagsArea = NULL; - ExRaiseSqlError(getHeap(), &diagsArea, (ExeErrorCode)(8447), NULL, + ExRaiseSqlError(getHeap(), &diagsArea, (ExeErrorCode)(8447), NULL, NULL, NULL, NULL, sequenceFileReader_->getErrorText(sfrRetCode), NULL); - pentry_down->setDiagsArea(diagsArea); + pentry_down->setDiagsAreax(diagsArea); step_ = HANDLE_ERROR; break; } @@ -1514,36 +1512,33 @@ ExWorkProcRetcode ExHdfsScanTcb::work() retcode = ExpLOBInterfaceSelectCursor (lobGlob_, (getStatsEntry() != NULL ? getStatsEntry()->castToExHdfsScanStats() : NULL), - hdfsFileName_, + hdfsFileName_, NULL, (Lng32)Lob_External_HDFS_File, hdfsScanTdb().hostName_, hdfsScanTdb().port_, 0,NULL, //handle not relevant for non lob access 0, cursorId_, - requestTag_, Lob_Memory, 0, // not check status (NOT hdfsScanTdb().hdfsPrefetch()), //1, // waited op - - 0, + 0, hdfsScanBufMaxSize_, bytesRead_, hdfsScanBuffer_, 3, // close 0); // openType, not applicable for close - + if (retcode < 0) { Lng32 cliError = 0; - Lng32 intParam1 = -retcode; ComDiagsArea * diagsArea = NULL; - ExRaiseSqlError(getHeap(), &diagsArea, - (ExeErrorCode)(EXE_ERROR_FROM_LOB_INTERFACE), NULL, - &intParam1, - &errno, - NULL, + ExRaiseSqlError(getHeap(), &diagsArea, + (ExeErrorCode)(EXE_ERROR_FROM_LOB_INTERFACE), NULL, + &intParam1, + &errno, + NULL, "HDFS", (char*)"ExpLOBInterfaceSelectCursor/close", getLobErrStr(intParam1)); @@ -1555,13 +1550,14 @@ ExWorkProcRetcode ExHdfsScanTcb::work() step_ = CLOSE_FILE; } break; + case HANDLE_EXCEPTION: { step_ = nextStep_; exception_ = FALSE; Int64 exceptionCount = 0; - ExHbaseAccessTcb::incrErrorCount( ehi_,exceptionCount, - hdfsScanTdb().getErrCountTable(),hdfsScanTdb().getErrCountRowId()); + ExHbaseAccessTcb::incrErrorCount(ehi_,exceptionCount, + hdfsScanTdb().getErrCountTable(),hdfsScanTdb().getErrCountRowId()); if (hdfsScanTdb().getMaxErrorRows() > 0) { if (exceptionCount > hdfsScanTdb().getMaxErrorRows()) @@ -1575,7 +1571,7 @@ ExWorkProcRetcode ExHdfsScanTcb::work() if(!da) { da = ComDiagsArea::allocate(getHeap()); - workAtp_->setDiagsArea(da); + workAtp_->setDiagsAreax(da); } ExRaiseSqlError(getHeap(), &da, (ExeErrorCode)(EXE_MAX_ERROR_ROWS_EXCEEDED)); @@ -1588,8 +1584,6 @@ ExWorkProcRetcode ExHdfsScanTcb::work() int loggingRowLen = hdfsLoggingRowEnd_ - hdfsLoggingRow_ +1; handleException((NAHeap *)getHeap(), hdfsLoggingRow_, loggingRowLen, lastErrorCnd_ ); - - } if (pentry_down->getDiagsArea()) @@ -1613,21 +1607,21 @@ ExWorkProcRetcode ExHdfsScanTcb::work() if (workAtp_->getDiagsArea()) { ComDiagsArea *diagsArea = up_entry->getDiagsArea(); - + if (diagsArea == NULL) { - diagsArea = + diagsArea = ComDiagsArea::allocate(getGlobals()->getDefaultHeap()); - up_entry->setDiagsArea (diagsArea); + up_entry->setDiagsAreax(diagsArea); } up_entry->getDiagsArea()->mergeAfter(*workAtp_->getDiagsArea()); - workAtp_->setDiagsArea(NULL); + workAtp_->setDiagsAreax(NULL); } up_entry->upState.status = ex_queue::Q_SQLERROR; qparent_.up->insert(); - + if (useLibhdfsScan_) { if (step_ == HANDLE_ERROR_WITH_CLOSE) step_ = CLOSE_HDFS_CURSOR; @@ -1643,10 +1637,10 @@ ExWorkProcRetcode ExHdfsScanTcb::work() case CLOSE_FILE: case ERROR_CLOSE_FILE: { - // if next file is not same as current file, then close the current file. + // if next file is not same as current file, then close the current file. bool closeFile = true; - if ( (step_ == CLOSE_FILE) && + if ( (step_ == CLOSE_FILE) && ((currRangeNum_ + 1) < (beginRangeNum_ + numRanges_))) { @@ -1655,13 +1649,13 @@ ExWorkProcRetcode ExHdfsScanTcb::work() closeFile = false; } - if (closeFile) + if (closeFile) { retcode = ExpLOBinterfaceCloseFile (lobGlob_, (getStatsEntry() != NULL ? getStatsEntry()->castToExHdfsScanStats() : NULL), hdfsFileName_, - NULL, + NULL, (Lng32)Lob_External_HDFS_File, hdfsScanTdb().hostName_, hdfsScanTdb().port_); @@ -1670,20 +1664,20 @@ ExWorkProcRetcode ExHdfsScanTcb::work() (retcode < 0)) { Lng32 cliError = 0; - + Lng32 intParam1 = -retcode; ComDiagsArea * diagsArea = NULL; - ExRaiseSqlError(getHeap(), &diagsArea, - (ExeErrorCode)(EXE_ERROR_FROM_LOB_INTERFACE), NULL, - &intParam1, - &cliError, - NULL, + ExRaiseSqlError(getHeap(), &diagsArea, + (ExeErrorCode)(EXE_ERROR_FROM_LOB_INTERFACE), NULL, + &intParam1, + &cliError, + NULL, "HDFS", (char*)"ExpLOBinterfaceCloseFile", getLobErrStr(intParam1)); - pentry_down->setDiagsArea(diagsArea); + pentry_down->setDiagsAreax(diagsArea); } - } + } if (step_ == CLOSE_FILE) { currRangeNum_++; @@ -1697,11 +1691,9 @@ ExWorkProcRetcode ExHdfsScanTcb::work() step_ = INIT_HDFS_CURSOR; break; } - } + } step_ = DONE; } - - break; case DONE: @@ -1717,33 +1709,32 @@ ExWorkProcRetcode ExHdfsScanTcb::work() up_entry->upState.downIndex = qparent_.down->getHeadIndex(); up_entry->upState.status = ex_queue::Q_NO_DATA; up_entry->upState.setMatchNo(matches_); - if (loggingErrorDiags_ != NULL) + if (loggingErrorDiags_ != NULL) { ComDiagsArea * diagsArea = up_entry->getDiagsArea(); if (!diagsArea) { diagsArea = ComDiagsArea::allocate(getGlobals()->getDefaultHeap()); - up_entry->setDiagsArea(diagsArea); + up_entry->setDiagsAreax(diagsArea); } diagsArea->mergeAfter(*loggingErrorDiags_); loggingErrorDiags_->clear(); } qparent_.up->insert(); - + qparent_.down->removeHead(); step_ = NOT_STARTED; break; } - - default: + + default: { break; } - } // switch } // while - + return WORK_OK; } @@ -2411,13 +2402,13 @@ ExWorkProcRetcode ExOrcScanTcb::work() numOrcCols_); if (retcode < 0) { - setupError(EXE_ERROR_FROM_LOB_INTERFACE, retcode, "ORC", "scanFetch", + setupError(EXE_ERROR_FROM_LOB_INTERFACE, retcode, "ORC", "scanFetch", orci_->getErrorText(-retcode)); step_ = HANDLE_ERROR; break; } - + if (retcode == 100) { step_ = CLOSE_ORC_CURSOR; @@ -2427,7 +2418,7 @@ ExWorkProcRetcode ExOrcScanTcb::work() step_ = PROCESS_ORC_ROW; } break; - + case PROCESS_ORC_ROW: { int formattedRowLength = 0; @@ -2435,19 +2426,19 @@ ExWorkProcRetcode ExOrcScanTcb::work() short err = extractAndTransformOrcSourceToSqlRow(orcRow_, orcRowLen_, numOrcCols_, transformDiags); - + if (err) { if (transformDiags) - pentry_down->setDiagsArea(transformDiags); + pentry_down->setDiagsAreax(transformDiags); step_ = HANDLE_ERROR; break; - } - + } + if (hdfsStats_) hdfsStats_->incAccessedRows(); - - workAtp_->getTupp(hdfsScanTdb().workAtpIndex_) = + + workAtp_->getTupp(hdfsScanTdb().workAtpIndex_) = hdfsSqlTupp_; bool rowWillBeSelected = true; @@ -2462,11 +2453,11 @@ ExWorkProcRetcode ExOrcScanTcb::work() step_ = HANDLE_ERROR; break; } - else + else ex_assert(evalRetCode == ex_expr::EXPR_TRUE, "invalid return code from expr eval"); } - + if (rowWillBeSelected) { if (moveColsConvertExpr()) @@ -2494,19 +2485,19 @@ ExWorkProcRetcode ExOrcScanTcb::work() { if (qparent_.up->isFull()) return WORK_OK; - + ex_queue_entry *up_entry = qparent_.up->getTailEntry(); up_entry->copyAtp(pentry_down); - up_entry->upState.parentIndex = + up_entry->upState.parentIndex = pentry_down->downState.parentIndex; up_entry->upState.downIndex = qparent_.down->getHeadIndex(); up_entry->upState.status = ex_queue::Q_OK_MMORE; - + if (moveExpr()) { UInt32 maxRowLen = hdfsScanTdb().outputRowLength_; UInt32 rowLen = maxRowLen; - + if (hdfsScanTdb().useCifDefrag() && !pool_->currentBufferHasEnoughSpace((Lng32)hdfsScanTdb().outputRowLength_)) { @@ -2523,11 +2514,11 @@ ExWorkProcRetcode ExOrcScanTcb::work() { diagsArea = ComDiagsArea::allocate(getGlobals()->getDefaultHeap()); - pentry_down->setDiagsArea (diagsArea); + pentry_down->setDiagsAreax(diagsArea); } pentry_down->getDiagsArea()-> mergeAfter(*up_entry->getDiagsArea()); - up_entry->setDiagsArea(NULL); + up_entry->setDiagsAreax(NULL); step_ = HANDLE_ERROR; break; } @@ -2538,7 +2529,7 @@ ExWorkProcRetcode ExOrcScanTcb::work() str_cpy_all(up_entry->getTupp(hdfsScanTdb().tuppIndex_).getDataPointer(), defragTd_->getTupleAddress(), rowLen); - + } else { @@ -2557,11 +2548,11 @@ ExWorkProcRetcode ExOrcScanTcb::work() { diagsArea = ComDiagsArea::allocate(getGlobals()->getDefaultHeap()); - pentry_down->setDiagsArea (diagsArea); + pentry_down->setDiagsAreax(diagsArea); } pentry_down->getDiagsArea()-> mergeAfter(*up_entry->getDiagsArea()); - up_entry->setDiagsArea(NULL); + up_entry->setDiagsAreax(NULL); step_ = HANDLE_ERROR; break; } @@ -2572,19 +2563,19 @@ ExWorkProcRetcode ExOrcScanTcb::work() } } } - + up_entry->upState.setMatchNo(++matches_); if (matches_ == matchBrkPoint_) brkpoint(); qparent_.up->insert(); - - // use ExOperStats now, to cover OPERATOR stats as well as - // ALL stats. + + // use ExOperStats now, to cover OPERATOR stats as well as + // ALL stats. if (getStatsEntry()) getStatsEntry()->incActualRowsReturned(); - - workAtp_->setDiagsArea(NULL); // get rid of warnings. - + + workAtp_->setDiagsAreax(NULL); // get rid of warnings. + if ((pentry_down->downState.request == ex_queue::GET_N) && (pentry_down->downState.requestValue == matches_)) step_ = CLOSE_ORC_CURSOR; @@ -2600,13 +2591,13 @@ ExWorkProcRetcode ExOrcScanTcb::work() { setupError(EXE_ERROR_FROM_LOB_INTERFACE, retcode, "ORC", "scanClose", orci_->getErrorText(-retcode)); - + step_ = HANDLE_ERROR; break; } - + currRangeNum_++; - + if (currRangeNum_ < (beginRangeNum_ + numRanges_)) { // move to the next file. diff --git a/core/sql/executor/ExPack.cpp b/core/sql/executor/ExPack.cpp index 6bcce69081..0317814065 100644 --- a/core/sql/executor/ExPack.cpp +++ b/core/sql/executor/ExPack.cpp @@ -387,8 +387,7 @@ ExWorkProcRetcode ExPackRowsTcb::workUp() if(!cEntryUpAtp->getDiagsArea()); else if(!pEntryDown->getDiagsArea()) { - pEntryDown->setDiagsArea(cEntryUpAtp->getDiagsArea()); - pEntryDown->getDiagsArea()->incrRefCount(); + pEntryDown->shareDiagsArea(cEntryUpAtp->getDiagsArea()); } else pEntryDown->getDiagsArea()->mergeAfter(*cEntryUpAtp->getDiagsArea()); diff --git a/core/sql/executor/ExPackedRows.cpp b/core/sql/executor/ExPackedRows.cpp index 49d5bb1051..4d3252aac4 100644 --- a/core/sql/executor/ExPackedRows.cpp +++ b/core/sql/executor/ExPackedRows.cpp @@ -541,14 +541,14 @@ ExUnPackRowsTcb::workUp() // pState.numRows_ = numRows_; - // If the number of entries in the rowset is negative, we + // If the number of entries in the rowset is negative, we // signal an error if (numRows_ < 0) { ComDiagsArea * da = workAtp_->getDiagsArea(); - if (!da) + if (!da) { da = ComDiagsArea::allocate(getHeap()); - workAtp_->setDiagsArea(da); + workAtp_->setDiagsAreax(da); } *da << DgSqlCode(-EXE_ROWSET_INDEX_OUTOF_RANGE); processError(workAtp_,FALSE,0); @@ -617,41 +617,40 @@ ExUnPackRowsTcb::workUp() // Apply the unPack expression to this row. This will // generate the proper values for the generated columns. // - Lng32 markValue = 0; ComDiagsArea * da = workAtp_->getDiagsArea(); if (da) markValue = da->mark(); - retCode = (unPackColsExpr() ? + retCode = (unPackColsExpr() ? unPackColsExpr()->eval(workAtp_, childAtp) : ex_expr::EXPR_TRUE); - + switch(retCode) { case ex_expr::EXPR_TRUE: { // Get the entry on the parent up queue. // ex_queue_entry *pEntry = qParent_.up->getTailEntry(); - + pEntry->copyAtp(workAtp_); // for non-atomic rowsets do NOT flow digas area which we get from parent - // this diags area contains errors from the CLI. We do not want to flow them up - // with OK_MMORE replies as this will lead to duplication. + // this diags area contains errors from the CLI. We do not want to flow them up + // with OK_MMORE replies as this will lead to duplication. // We will flow them up with the Q_REC_SKIPPED replies. if (tolerateNonFatalError) - pEntry->setDiagsArea(NULL); - + pEntry->setDiagsAreax(NULL); + // Release the reference to the tupp in the workAtp_ // workAtp_->getTupp(unPackRowsTdb().unPackColsAtpIndex_).release(); - + // Set the flag to indicate that the tuple has been used and // a new tuple needs to be allocated. // needTuple = (unPackColsExpr() ? TRUE : FALSE); - + // Finialize the queue entry, then insert it // pEntry->upState.status = cEntry->upState.status; @@ -740,12 +739,12 @@ ExUnPackRowsTcb::processError(atp_struct *atp, NABoolean isNonFatalError, Lng32 ex_queue_entry * pEntryDown = qParent_.down->getHeadEntry(); ex_queue_entry * pEntry = qParent_.up->getTailEntry(); ExUnPackRowsPrivateState &pState = - *((ExUnPackRowsPrivateState*) pEntryDown->pstate); + *((ExUnPackRowsPrivateState*) pEntryDown->pstate); pEntry->upState.status = ex_queue::Q_SQLERROR; pEntry->upState.parentIndex = pEntryDown->downState.parentIndex; pEntry->upState.downIndex = qParent_.down->getHeadIndex(); - pEntry->upState.setMatchNo(pState.matchCount_); + pEntry->upState.setMatchNo(pState.matchCount_); if (!isNonFatalError) { pEntry->copyAtp(atp); @@ -754,8 +753,8 @@ ExUnPackRowsTcb::processError(atp_struct *atp, NABoolean isNonFatalError, Lng32 qParent_.down->cancelRequest(qParent_.down->getHeadIndex()); pState.childState_ = CANCELLED_; - while(!childQueue_.up->isEmpty() && - (childQueue_.up->getHeadEntry()->upState.status + while(!childQueue_.up->isEmpty() && + (childQueue_.up->getHeadEntry()->upState.status != ex_queue::Q_NO_DATA)) childQueue_.up->removeHead(); } @@ -764,8 +763,8 @@ ExUnPackRowsTcb::processError(atp_struct *atp, NABoolean isNonFatalError, Lng32 ex_assert(fromDa, "We have an expression error in UnPack but no diags area"); ComDiagsArea* toDa = ComDiagsArea::allocate(getHeap()); fromDa->rewindAndMergeIfDifferent(markValue, toDa); - pEntry->setDiagsArea(toDa); - toDa->setAllRowNumber(ComCondition::NONFATAL_ERROR) ; + pEntry->setDiagsAreax(toDa); + toDa->setAllRowNumber(ComCondition::NONFATAL_ERROR); } qParent_.up->insert(); } @@ -776,7 +775,7 @@ ExUnPackRowsTcb::processSkippedRow(atp_struct *atp) ex_queue_entry * pEntryDown = qParent_.down->getHeadEntry(); ex_queue_entry * pEntry = qParent_.up->getTailEntry(); ExUnPackRowsPrivateState &pState = - *((ExUnPackRowsPrivateState*) pEntryDown->pstate); + *((ExUnPackRowsPrivateState*) pEntryDown->pstate); pEntry->upState.status = ex_queue::Q_REC_SKIPPED; pEntry->upState.parentIndex = pEntryDown->downState.parentIndex; @@ -1040,14 +1039,14 @@ ExUnPackRowwiseRowsTcb::work() up_entry->upState.setMatchNo(1); qParent_.up->insert(); - + currentRowNum_++; if (currentRowNum_ == rwrsNumRows_) { step_ = DONE_; break; } - + } break; @@ -1058,24 +1057,24 @@ ExUnPackRowwiseRowsTcb::work() // Return EOF. ex_queue_entry * up_entry = qParent_.up->getTailEntry(); - - up_entry->upState.parentIndex = + + up_entry->upState.parentIndex = pentry_down->downState.parentIndex; - + up_entry->upState.setMatchNo(0); up_entry->upState.status = ex_queue::Q_SQLERROR; ComDiagsArea *diagsArea = pentry_down->getDiagsArea(); - + if (diagsArea != up_entry->getDiagsArea()) { - up_entry->setDiagsArea (diagsArea); + up_entry->setDiagsAreax(diagsArea); if (diagsArea != NULL) diagsArea->incrRefCount(); } // insert into parent qParent_.up->insert(); - + step_ = DONE_; } break; @@ -1087,16 +1086,16 @@ ExUnPackRowwiseRowsTcb::work() // Return EOF. ex_queue_entry * up_entry = qParent_.up->getTailEntry(); - - up_entry->upState.parentIndex = + + up_entry->upState.parentIndex = pentry_down->downState.parentIndex; - + up_entry->upState.setMatchNo(0); up_entry->upState.status = ex_queue::Q_NO_DATA; - + // insert into parent qParent_.up->insert(); - + step_ = INITIAL_; qParent_.down->removeHead(); diff --git a/core/sql/executor/ExProbeCache.cpp b/core/sql/executor/ExProbeCache.cpp index 97ec0628b0..32ed44552c 100644 --- a/core/sql/executor/ExProbeCache.cpp +++ b/core/sql/executor/ExProbeCache.cpp @@ -730,25 +730,25 @@ void ExProbeCacheTcb::makeReplyToParentUp(ex_queue_entry *pentry_down, if (rowQualifies) { // Initialize the upState. - up_entry->upState.parentIndex = + up_entry->upState.parentIndex = pentry_down->downState.parentIndex; up_entry->upState.downIndex = qparent_.down->getHeadIndex(); up_entry->upState.setMatchNo(pstate.matchCount_); up_entry->upState.status = reply_status; // Give the reply any diagsArea. Test pcEntry_ before using it - // because a request that went from CANCELED_NOT_STARTED to - // DONE will never be hooked up with a pcEntry_. + // because a request that went from CANCELED_NOT_STARTED to + // DONE will never be hooked up with a pcEntry_. if (pstate.pcEntry_ && - pstate.pcEntry_->diagsArea_) - { - ComDiagsArea *accumulatedDiagsArea = + pstate.pcEntry_->diagsArea_) + { + ComDiagsArea *accumulatedDiagsArea = up_entry->getDiagsArea(); if (accumulatedDiagsArea) accumulatedDiagsArea->mergeAfter(*pstate.pcEntry_->diagsArea_); else { - up_entry->setDiagsArea(pstate.pcEntry_->diagsArea_); + up_entry->setDiagsAreax(pstate.pcEntry_->diagsArea_); pstate.pcEntry_->diagsArea_->incrRefCount(); } } @@ -763,8 +763,8 @@ void ExProbeCacheTcb::makeReplyToParentUp(ex_queue_entry *pentry_down, /////////////////////////////////////////////////////////////////// -ExProbeCacheTcb::MoveStatus -ExProbeCacheTcb::moveReplyToCache(ex_queue_entry &reply, +ExProbeCacheTcb::MoveStatus +ExProbeCacheTcb::moveReplyToCache(ex_queue_entry &reply, ExPCE &pcEntry) { if (moveInnerExpr()) @@ -775,7 +775,7 @@ ExProbeCacheTcb::moveReplyToCache(ex_queue_entry &reply, if (pool_->getFreeTuple(pcEntry.innerRowTupp_)) return MOVE_BLOCKED; - workAtp_->getTupp(probeCacheTdb().innerRowDataIdx_) = + workAtp_->getTupp(probeCacheTdb().innerRowDataIdx_) = pcEntry.innerRowTupp_; // Evaluate the move expression on the reply. diff --git a/core/sql/executor/ExSequence.cpp b/core/sql/executor/ExSequence.cpp index bc29779791..5636b3d895 100644 --- a/core/sql/executor/ExSequence.cpp +++ b/core/sql/executor/ExSequence.cpp @@ -542,12 +542,11 @@ short ExSequenceTcb::work() // if (workAtp_->getDiagsArea()) { ComDiagsArea * da = workAtp_->getDiagsArea(); - pentry_up->setDiagsArea(da); - da->incrRefCount(); - workAtp_->setDiagsArea(0); + pentry_up->setDiagsAreax(da); + workAtp_->setDiagsAreax(0); } pentry_up->upState.status = ex_queue::Q_SQLERROR; - pentry_up->upState.parentIndex + pentry_up->upState.parentIndex = pentry_down->downState.parentIndex; pentry_up->upState.downIndex = qparent_.down->getHeadIndex(); pentry_up->upState.setMatchNo(pstate->matchCount_); @@ -563,8 +562,8 @@ short ExSequenceTcb::work() // // Transition to this state from ... // 1. ExSeq_EMPTY - If a request is started. - // 2. ExSeq_WORKING_RETURN - - // 3. ExSeq_OVERFLOW_WRITE - + // 2. ExSeq_WORKING_RETURN - + // 3. ExSeq_OVERFLOW_WRITE - // Remain in this state until ... // 1. All child replies including EOD have been processed. // 2. A SQLERROR row is received. @@ -1435,7 +1434,7 @@ void ExSequenceTcb::createCluster() cluster_ = new(heap_) Cluster(Cluster::IN_MEMORY, clusterDb_, - NULL, // ... &buckets_[bucketIdx], + NULL, // ... &buckets_[bucketIdx], 0, // ... bucketsPerCluster, myTdb().recLen_, // Row Length false, @@ -1445,24 +1444,23 @@ void ExSequenceTcb::createCluster() FALSE, // ... no bit map NULL, // next cluster, &rc_); - + ex_assert( cluster_ , "No memory available for OLAP Operator"); } void ExSequenceTcb::updateDiagsArea(ex_queue_entry * centry) { - if (centry->getDiagsArea()) + if (centry->getDiagsArea()) { if (workAtp_->getDiagsArea()) - { + { workAtp_->getDiagsArea()->mergeAfter(*centry->getDiagsArea()); } else { ComDiagsArea * da = centry->getDiagsArea(); - workAtp_->setDiagsArea(da); - da->incrRefCount(); - centry->setDiagsArea(0); + workAtp_->shareDiagsArea(da); + centry->setDiagsAreax(0); } } } @@ -1470,23 +1468,22 @@ void ExSequenceTcb::updateDiagsArea(ex_queue_entry * centry) void ExSequenceTcb::updateDiagsArea(ComDiagsArea *da) { if (workAtp_->getDiagsArea()) - { + { workAtp_->getDiagsArea()->mergeAfter(*da); } else { - workAtp_->setDiagsArea(da); - da->incrRefCount(); + workAtp_->shareDiagsArea(da); } } void ExSequenceTcb::updateDiagsArea( ExeErrorCode rc_) -{ +{ ComDiagsArea *da = workAtp_->getDiagsArea(); - if(!da) + if(!da) { da = ComDiagsArea::allocate(heap_); - workAtp_->setDiagsArea(da); + workAtp_->setDiagsAreax(da); } if (!da->contains((Lng32) -rc_)) { diff --git a/core/sql/executor/ExStats.cpp b/core/sql/executor/ExStats.cpp index d5aaf9ff3e..f9f052a502 100644 --- a/core/sql/executor/ExStats.cpp +++ b/core/sql/executor/ExStats.cpp @@ -7385,7 +7385,7 @@ short ExStatsTcb::work() ex_queue_entry *pentry_up = qparent_.up->getTailEntry(); pentry_up->copyAtp(pentry_down); pentry_up->upState.status = ex_queue::Q_NO_DATA; - pentry_up->upState.parentIndex = + pentry_up->upState.parentIndex = pentry_down->downState.parentIndex; pentry_up->upState.downIndex = qparent_.down->getHeadIndex(); pentry_up->upState.setMatchNo(pstate->matchCount_); @@ -7397,11 +7397,11 @@ short ExStatsTcb::work() else da->incrRefCount(); da->mergeAfter(*diagsArea_); - pentry_up->setDiagsArea(da); + pentry_up->setDiagsAreax(da); diagsArea_->clear(); diagsArea_->deAllocate(); diagsArea_ = NULL; - } + } qparent_.up->insert(); // remove the down entry qparent_.down->removeHead(); diff --git a/core/sql/executor/ExUdr.cpp b/core/sql/executor/ExUdr.cpp index 230aa42e38..421b830004 100644 --- a/core/sql/executor/ExUdr.cpp +++ b/core/sql/executor/ExUdr.cpp @@ -1097,7 +1097,7 @@ NABoolean ExUdrTcb::insertUpQueueEntry(ex_queue::up_status status, ExUdrPrivateState &privateState = *((ExUdrPrivateState *) downEntry->pstate); - // Initialize the up queue entry. + // Initialize the up queue entry. // // copyAtp() will copy all tuple pointers and the diags area from // the down queue entry to the up queue entry. @@ -1108,29 +1108,27 @@ NABoolean ExUdrTcb::insertUpQueueEntry(ex_queue::up_status status, // if (status == ex_queue::Q_NO_DATA && privateState.matchCount_ > 0) { - downEntry->setDiagsArea(NULL); + downEntry->setDiagsAreax(NULL); upEntry->copyAtp(downEntry); } else { upEntry->copyAtp(downEntry); - downEntry->setDiagsArea(NULL); + downEntry->setDiagsAreax(NULL); } upEntry->upState.status = status; upEntry->upState.parentIndex = downEntry->downState.parentIndex; upEntry->upState.downIndex = qParent_.down->getHeadIndex(); upEntry->upState.setMatchNo(privateState.matchCount_); - + // Move any diags to the up queue entry if (diags != NULL) { ComDiagsArea *atpDiags = upEntry->getDiagsArea(); if (atpDiags == NULL) { - // setDiagsArea() does not increment the reference count - upEntry->setDiagsArea(diags); - diags->incrRefCount(); + upEntry->shareDiagsArea(diags); } else if (atpDiags != diags) { @@ -2825,7 +2823,7 @@ ExWorkProcRetcode ExUdrTcb::returnSingleRow() UdrDebug1(" [WORK] outputExpr.eval() returned %s", GetExpStatusString(expStatus)); } - + workAtp_->getTupp(myTdb().getReplyTuppIndex()).release(); } @@ -2849,26 +2847,24 @@ ExWorkProcRetcode ExUdrTcb::returnSingleRow() // entry because the entry is about to be // abandoned. predSatisfied = FALSE; - upEntry->setDiagsArea(NULL); + upEntry->setDiagsAreax(NULL); } } - + // 4. Move server diags to the up queue entry if (predSatisfied && returnedDiags) { ComDiagsArea *atpDiags = upEntry->getDiagsArea(); if (atpDiags == NULL) { - // setDiagsArea() does not increment the reference count - upEntry->setDiagsArea(returnedDiags); - returnedDiags->incrRefCount(); + upEntry->shareDiagsArea(returnedDiags); } else { atpDiags->mergeAfter(*returnedDiags); } } - + // 5. Return an up queue entry if (predSatisfied) { diff --git a/core/sql/executor/ex_control.cpp b/core/sql/executor/ex_control.cpp index f33d241bef..e8a22e44c7 100644 --- a/core/sql/executor/ex_control.cpp +++ b/core/sql/executor/ex_control.cpp @@ -856,7 +856,7 @@ short ExSetSessionDefaultTcb::work() defaultName); goto all_ok; } - + currContext->beginSession(&defaultValue[strlen("BEGIN")+1]); } else @@ -867,12 +867,12 @@ short ExSetSessionDefaultTcb::work() else if (strcmp(defaultValue, "CONTINUE:CLEANUP_ESPS") == 0) { Lng32 numStoppedEsps = currContext->reduceEsps(); - ComDiagsArea *da = + ComDiagsArea *da = ComDiagsArea::allocate(getGlobals()->getDefaultHeap()); *da << DgSqlCode(EXE_CLEANUP_ESP) // a warning. << DgInt0(numStoppedEsps); ex_queue_entry * up_entry = getParentQueue().up->getTailEntry(); - up_entry->setDiagsArea(da); + up_entry->setDiagsAreax(da); } else if (strcmp(defaultValue, "END") == 0) { @@ -888,19 +888,19 @@ short ExSetSessionDefaultTcb::work() } // END:CLEANUP_ESPS else if (strcmp(defaultValue, "END:CLEANUP_OPENS") == 0) { - currContext->endSession(FALSE /*do not cleanup ESPs*/, + currContext->endSession(FALSE /*do not cleanup ESPs*/, FALSE,/*not esps only*/ TRUE /* cleanup opens*/); } // END:CLEANUP_OPENS else if (strcmp(defaultValue, "END:CLEANUP_ESPS:CLEANUP_OPENS") == 0) { - currContext->endSession(TRUE /*cleanup ESPs*/, + currContext->endSession(TRUE /*cleanup ESPs*/, FALSE,/*not esps only*/ TRUE/* cleanup opens*/); } // END:CLEANUP_ESPS & OPENS else if (strcmp(defaultValue, "END:CLEANUP_ESPS_ONLY") == 0) { - currContext->endSession(TRUE /*cleanup ESPs*/, + currContext->endSession(TRUE /*cleanup ESPs*/, TRUE /*only esps*/, FALSE); } // END:CLEANUP_ESPS @@ -1284,9 +1284,9 @@ short ExSetSessionDefaultTcb::work() if (changeEspPriority) { - IpcPriority p = - (espIsDelta ? - currContext->getSessionDefaults()->getEspPriorityDelta() : + IpcPriority p = + (espIsDelta ? + currContext->getSessionDefaults()->getEspPriorityDelta() : currContext->getSessionDefaults()->getEspPriority()); // adjust this, if altpri is to be done in esp. @@ -1305,13 +1305,13 @@ short ExSetSessionDefaultTcb::work() str_itoa(ABS(rc), &errMsg[strlen(errMsg)]); up_entry = qparent_.up->getTailEntry(); - ComDiagsArea * da = + ComDiagsArea * da = ExRaiseSqlError(getGlobals()->getDefaultHeap(), up_entry, (ExeErrorCode)(15371), NULL, errMsg); - up_entry->setDiagsArea(da); + up_entry->setDiagsAreax(da); } } @@ -1319,17 +1319,17 @@ short ExSetSessionDefaultTcb::work() all_ok: // all ok. Return EOF. up_entry = qparent_.up->getTailEntry(); - up_entry->upState.parentIndex = + up_entry->upState.parentIndex = pentry_down->downState.parentIndex; - + up_entry->upState.setMatchNo(0); up_entry->upState.status = ex_queue::Q_NO_DATA; - + // insert into parent getParentQueue().up->insert(); - + getParentQueue().down->removeHead(); - + return WORK_OK; } diff --git a/core/sql/executor/ex_ddl.cpp b/core/sql/executor/ex_ddl.cpp index 30181b9c52..7d161ee5d6 100644 --- a/core/sql/executor/ex_ddl.cpp +++ b/core/sql/executor/ex_ddl.cpp @@ -356,7 +356,7 @@ short ExDDLTcb::work() // restore mxcmp priority back to its original value if (cmp) { - cmpStatus = + cmpStatus = cmp->changePriority( currContext->getSessionDefaults()->getMxcmpPriorityDelta(), TRUE); if (cmpStatus != ExSqlComp::SUCCESS) @@ -375,30 +375,29 @@ short ExDDLTcb::work() ComDiagsArea *diagsArea = up_entry->getDiagsArea(); if (diagsArea == NULL) diagsArea = ComDiagsArea::allocate(this->getGlobals()->getDefaultHeap()); - + diagsArea->mergeAfter (*cpDiagsArea); - up_entry->setDiagsArea(diagsArea); + up_entry->setDiagsAreax(diagsArea); cpDiagsArea->decrRefCount(); } - up_entry->upState.parentIndex = + up_entry->upState.parentIndex = pentry_down->downState.parentIndex; - + up_entry->upState.setMatchNo(pstate.matches_); up_entry->upState.status = ex_queue::Q_NO_DATA; - + // insert into parent qparent_.up->insert(); - + pstate.init(); qparent_.down->removeHead(); - + if (ddlTdb().workCriDesc_) workAtp_->release(); currContext->ddlStmtsExecuted() = TRUE; - - } // while + } // while return WORK_OK; } @@ -835,19 +834,19 @@ void ExDDLTcb::handleErrors(ex_queue_entry *pentry_down, ComDiagsArea *da, Int32 if (error == ExSqlComp::ERROR) up_entry->upState.status = ex_queue::Q_SQLERROR; else - up_entry->upState.status = ex_queue::Q_OK_MMORE; + up_entry->upState.status = ex_queue::Q_OK_MMORE; // Merge the diagsArea and do no pass what is got from the // compiler. If the diagsArea from the compiler is passed - // thro' the queue entry the diagsArea gets deleted when - // its merged with the cli. So, when the next error occurs + // thro' the queue entry the diagsArea gets deleted when + // its merged with the cli. So, when the next error occurs // ExSqlComp uses the same diagArea pointer to insert the // the new error_. Only now the memory does not exist because // it was deleted by the previous error processing. // up_entry->setDiagsArea(diagsArea); ComDiagsArea *diagsArea = up_entry->getDiagsArea(); - + if (diagsArea == NULL) // refCount is set to 1 in allocate(), no need to call incrRefCount(). diagsArea = ComDiagsArea::allocate(this->getGlobals()->getDefaultHeap()); @@ -855,8 +854,8 @@ void ExDDLTcb::handleErrors(ex_queue_entry *pentry_down, ComDiagsArea *da, Int32 diagsArea->incrRefCount(); diagsArea->mergeAfter (*da); - up_entry->setDiagsArea(diagsArea); - + up_entry->setDiagsAreax(diagsArea); + // insert into parent qparent_.up->insert(); } @@ -1136,16 +1135,16 @@ short ExDescribeTcb::work() } char *dataPtr = up_entry->getTupp(describeTdb().tuppIndex_).getDataPointer(); - + // do the copy str_cpy_all(dataPtr, srcPtr, copyLen); // update the length if needed - if (copyLen != actualLen) + if (copyLen != actualLen) *(short *)dataPtr = copyLen - sizeof(short); pstate.matches_++; - + up_entry->upState.downIndex = qparent_.down->getHeadIndex(); up_entry->upState.parentIndex = pentry_down->downState.parentIndex; up_entry->upState.setMatchNo(pstate.matches_); @@ -1158,8 +1157,7 @@ short ExDescribeTcb::work() if (diagsArea == NULL) diagsArea = ComDiagsArea::allocate(this->getGlobals()->getDefaultHeap()); diagsArea->mergeAfter (*da); - up_entry->setDiagsArea(da); - up_entry->getAtp()->getDiagsArea()->incrRefCount(); + up_entry->shareDiagsArea(da); // Reset the da for the next error/warning. if (deleteTmpDa) da->decrRefCount(); @@ -1188,25 +1186,24 @@ short ExDescribeTcb::work() { if (qparent_.up->isFull()) return WORK_OK; - + ex_queue_entry * up_entry = qparent_.up->getTailEntry(); - + up_entry->upState.parentIndex = pentry_down->downState.parentIndex; up_entry->upState.setMatchNo(pstate.matches_); up_entry->upState.status = ex_queue::Q_SQLERROR; - + diagsArea = up_entry->getDiagsArea(); - + if (diagsArea == NULL) diagsArea = ComDiagsArea::allocate(this->getGlobals()->getDefaultHeap()); - + diagsArea->mergeAfter (*da); - up_entry->setDiagsArea(da); - up_entry->getAtp()->getDiagsArea()->incrRefCount(); - + up_entry->shareDiagsArea(da); + // insert into parent qparent_.up->insert(); - + if (deleteTmpDa) da->decrRefCount(); // reset the diagsArea for the next error to be set properly. @@ -1228,8 +1225,8 @@ short ExDescribeTcb::work() // all ok. Return EOF. ex_queue_entry * up_entry = qparent_.up->getTailEntry(); - - up_entry->upState.parentIndex = + + up_entry->upState.parentIndex = pentry_down->downState.parentIndex; up_entry->upState.setMatchNo(pstate.matches_); diff --git a/core/sql/executor/ex_error.cpp b/core/sql/executor/ex_error.cpp index 6390c2a0a6..302675d3c5 100644 --- a/core/sql/executor/ex_error.cpp +++ b/core/sql/executor/ex_error.cpp @@ -114,7 +114,7 @@ void ExHandleArkcmpErrors(ex_queue_pair &qparent, cond->setSQLCODE(err); diags_my->acceptNewCondition(); } - up_entry->setDiagsArea(diags_my); + up_entry->setDiagsAreax(diags_my); // insert into parent qparent.up->insert(); @@ -159,7 +159,7 @@ void ExHandleErrors(ex_queue_pair &qparent, cond->setNskCode(*nskErr); if (stringParam2) cond->setOptionalString(1, stringParam2); - + diags_my->acceptNewCondition(); } } @@ -176,11 +176,11 @@ void ExHandleErrors(ex_queue_pair &qparent, cond->setNskCode(*nskErr); if (stringParam2) cond->setOptionalString(1, stringParam2); - + diags_my->acceptNewCondition(); - + } - up_entry->setDiagsArea(diags_my); + up_entry->setDiagsAreax(diags_my); // insert into parent qparent.up->insert(); diff --git a/core/sql/executor/ex_ex.cpp b/core/sql/executor/ex_ex.cpp index 8e5b7a1d1c..6c3126b3d1 100644 --- a/core/sql/executor/ex_ex.cpp +++ b/core/sql/executor/ex_ex.cpp @@ -570,33 +570,33 @@ short ex_tcb::handleError(ex_queue_pair *qparent, ComDiagsArea *inDiagsArea) { if (qparent->up->isFull()) return 1; - + // Return EOF. ex_queue_entry * up_entry = qparent->up->getTailEntry(); ex_queue_entry * pentry_down = qparent->down->getHeadEntry(); - - up_entry->upState.parentIndex = + + up_entry->upState.parentIndex = pentry_down->downState.parentIndex; - + up_entry->upState.setMatchNo(0); up_entry->upState.status = ex_queue::Q_SQLERROR; - + ComDiagsArea *diagsArea = up_entry->getDiagsArea(); - + if (diagsArea == NULL) - diagsArea = + diagsArea = ComDiagsArea::allocate(this->getGlobals()->getDefaultHeap()); else diagsArea->incrRefCount (); // the setDiagsArea below will decr the ref count - + if (inDiagsArea) diagsArea->mergeAfter(*inDiagsArea); - - up_entry->setDiagsArea (diagsArea); - + + up_entry->setDiagsAreax(diagsArea); + // insert into parent qparent->up->insert(); - + return 0; } @@ -604,39 +604,39 @@ short ex_tcb::handleDone(ex_queue_pair *qparent, ComDiagsArea *inDiagsArea) { if (qparent->up->isFull()) return 1; - + // Return EOF. ex_queue_entry * up_entry = qparent->up->getTailEntry(); ex_queue_entry * pentry_down = qparent->down->getHeadEntry(); - + if (inDiagsArea && inDiagsArea->getNumber(DgSqlCode::WARNING_) > 0) { ComDiagsArea *diagsArea = up_entry->getDiagsArea(); - + if (diagsArea == NULL) - diagsArea = + diagsArea = ComDiagsArea::allocate(this->getGlobals()->getDefaultHeap()); else diagsArea->incrRefCount (); // the setDiagsArea below will decr the ref count - + if (inDiagsArea) diagsArea->mergeAfter(*inDiagsArea); - - up_entry->setDiagsArea (diagsArea); + + up_entry->setDiagsAreax(diagsArea); } - up_entry->upState.parentIndex = + up_entry->upState.parentIndex = pentry_down->downState.parentIndex; - + up_entry->upState.setMatchNo(0); up_entry->upState.status = ex_queue::Q_NO_DATA; - + // insert into parent qparent->up->insert(); - + // pstate.matches_ = 0; qparent->down->removeHead(); - + return 0; } diff --git a/core/sql/executor/ex_exe_stmt_globals.cpp b/core/sql/executor/ex_exe_stmt_globals.cpp index 8c06612cc4..787163c129 100644 --- a/core/sql/executor/ex_exe_stmt_globals.cpp +++ b/core/sql/executor/ex_exe_stmt_globals.cpp @@ -425,8 +425,8 @@ ExEspStmtGlobals * ExExeStmtGlobals::castToExEspStmtGlobals() /* -- -- Calls to this method should not be confused with calls --- to method atp_struct::setDiagsArea. Callers of this --- method should make sure to decrement the reference +-- to method atp_struct::setDiagsArea. Callers of this +-- method should make sure to decrement the reference -- counter of the Diags if the latter was just created -- prior to calling this method. The code fragment below -- presents an example: diff --git a/core/sql/executor/ex_hash_grby.cpp b/core/sql/executor/ex_hash_grby.cpp index e0835b9537..d8664b0c3c 100644 --- a/core/sql/executor/ex_hash_grby.cpp +++ b/core/sql/executor/ex_hash_grby.cpp @@ -666,7 +666,7 @@ short ex_hash_grby_tcb::work() { else diags = ExRaiseSqlError(heap_, downParentEntry, (ExeErrorCode)-rc_); - downParentEntry->setDiagsArea(diags); + downParentEntry->setDiagsAreax(diags); workHandleError(downParentEntry->getAtp()); } break; }; diff --git a/core/sql/executor/ex_hashj.cpp b/core/sql/executor/ex_hashj.cpp index a7c98ff818..68e22a9607 100644 --- a/core/sql/executor/ex_hashj.cpp +++ b/core/sql/executor/ex_hashj.cpp @@ -773,7 +773,7 @@ short ex_hashj_tcb::insertResult(HashRow * hashRow) { upParentEntry->upState.status = ex_queue::Q_OK_MMORE; upParentEntry->upState.parentIndex = downParentEntry->downState.parentIndex; upParentEntry->upState.downIndex = parentQueue_.down->getHeadIndex(); - + // we got another result row pstate.matchCount_++; upParentEntry->upState.setMatchNo(pstate.matchCount_); @@ -781,17 +781,14 @@ short ex_hashj_tcb::insertResult(HashRow * hashRow) { // move left and/or right warnings to parent if (pstate.accumDiags_) { - ComDiagsArea *accumulatedDiagsArea = + ComDiagsArea *accumulatedDiagsArea = upParentEntry->getDiagsArea(); if (accumulatedDiagsArea) accumulatedDiagsArea->mergeAfter(*pstate.accumDiags_); else { - upParentEntry->setDiagsArea(pstate.accumDiags_); - - // incr ref count after set so it doesn't get deallocated. - pstate.accumDiags_->incrRefCount(); + upParentEntry->shareDiagsArea(pstate.accumDiags_); } pstate.accumDiags_ = NULL; @@ -799,11 +796,11 @@ short ex_hashj_tcb::insertResult(HashRow * hashRow) { // insert into parent up queue parentQueue_.up->insert(); - + // update operator stats if (bmoStats_) bmoStats_-> incActualRowsReturned(); - + // we can forget about the row in the workAtp releaseResultTupps(); @@ -1071,14 +1068,13 @@ ExWorkProcRetcode ex_hashj_tcb::workUp() { (ExeErrorCode) -rc_, NULL, msg); - } else diags = ExRaiseSqlError(heap_, downParentEntry, (ExeErrorCode) -rc_); - downParentEntry->setDiagsArea(diags); + downParentEntry->setDiagsAreax(diags); } processError(downParentEntry->getAtp()); } break; @@ -1099,7 +1095,7 @@ NABoolean ex_hashj_tcb::isSameInputAgain( ex_queue_entry * downParentEntry ) { // insert the previous input into the appropriate tupp in the workAtp workAtp_->getTupp(hashJoinTdb().prevInputTuppIndex_) = prevInputValues_; - + NABoolean haveMark = FALSE; Lng32 oldDiagsAreaMark = 0; ComDiagsArea * da = downParentEntry->getAtp()->getDiagsArea(); @@ -1107,7 +1103,7 @@ NABoolean ex_hashj_tcb::isSameInputAgain( ex_queue_entry * downParentEntry ) { oldDiagsAreaMark = da->mark(); haveMark = TRUE; } - + // match the current input with the previous switch ( checkInputPred_->eval(downParentEntry->getAtp(), workAtp_ ) ) { case ex_expr::EXPR_TRUE : @@ -3577,23 +3573,23 @@ ExWorkProcRetcode ExUniqueHashJoinTcb::workUp() return WORK_OK; } - ex_assert( rc_ , "Missing error code"); + ex_assert( rc_ , "Missing error code"); // we ran into a serious runtime error. Create Condition and // pass it to parent. rc_ has the error code. ComDiagsArea *da = downParentEntry->getDiagsArea(); if(!da) { da = ComDiagsArea::allocate(heap_); - downParentEntry->setDiagsArea(da); + downParentEntry->setDiagsAreax(da); } - + if (!da->contains((Lng32) -rc_)) { *da << DgSqlCode(-rc_); } processError(downParentEntry->getAtp()); - break; + break; } } } diff --git a/core/sql/executor/ex_mj.cpp b/core/sql/executor/ex_mj.cpp index 05e8227c48..2cbea73ba8 100644 --- a/core/sql/executor/ex_mj.cpp +++ b/core/sql/executor/ex_mj.cpp @@ -381,7 +381,7 @@ ex_mj_tcb::createDiags(Int16 sqlCode) sysError = tspace_->getLastError(); } *diags << DgSqlCode(-sqlCode) << DgInt0(sysError) << DgString0("Merge join"); - downEntry->setDiagsArea(diags); + downEntry->setDiagsAreax(diags); // The Q_SQLERROR entry that will return the diagnostics information doesn't // match any rows, so reset matchCount_. @@ -421,7 +421,7 @@ ex_mj_tcb::processError(atp_struct* entryAtp) diagsArea->incrRefCount(); // to offset the decrRefCount done on setDiagsArea call } diagsArea->mergeAfter(*prevDiagsArea); - upEntry->setDiagsArea(diagsArea); + upEntry->setDiagsAreax(diagsArea); } upEntry->upState.status = ex_queue::Q_SQLERROR; diff --git a/core/sql/executor/ex_onlj.cpp b/core/sql/executor/ex_onlj.cpp index 12ec582001..54f0b9a9dc 100644 --- a/core/sql/executor/ex_onlj.cpp +++ b/core/sql/executor/ex_onlj.cpp @@ -646,9 +646,9 @@ ExWorkProcRetcode ExOnljTcb::work_phase2() if (lda && (lda->mainSQLCODE() < 0)) { // This will be true if an insert into index raises a nonfatal error - // In that case, don't want to pass this to the right tree - // which in this case will be a union of undos. This is - // because we don't want to see the same diags twice. + // In that case, don't want to pass this to the right tree + // which in this case will be a union of undos. This is + // because we don't want to see the same diags twice. // save the diags from the left in the pstate if (pstate.accumDiags_) { @@ -657,29 +657,26 @@ ExWorkProcRetcode ExOnljTcb::work_phase2() else { pstate.accumDiags_ = ComDiagsArea::allocate(getGlobals()->getDefaultHeap()); - pstate.accumDiags_->mergeAfter(*lda); - - } - + pstate.accumDiags_->mergeAfter(*lda); + } } - // Note: SET behavior (ignore dup rows for indexes is not enabled so + // Note: SET behavior (ignore dup rows for indexes is not enabled so // the case where (lda->mainSQLCODE == 0) won't get executed. // If it is enabled in the future, we would get an empty diags // with the OK_MMORE reply. In that case, don't merge anything into - // pstate diags but send the entry to the undo tree to be - // undone from base table and possibly other indices. + // pstate diags but send the entry to the undo tree to be + // undone from base table and possibly other indices. if (lda && ((lda->mainSQLCODE() <0) || (lda->mainSQLCODE()) == 0)) { // Don't pass diags area to right - lentry->setDiagsArea(NULL); + lentry->setDiagsAreax(NULL); // Adjust the rowcount in the statement globals // Subtract the rows that were "undone" - //if we have already subtracted rowcount once for this + //if we have already subtracted rowcount once for this // parent entry don't do it again. We only have to do it once per parent entry row. if (!pstate.rowAlreadyRaisedNFError_) { - ExMasterStmtGlobals *g = getGlobals()-> castToExExeStmtGlobals()->castToExMasterStmtGlobals(); Int64 rowsAffected = g->getRowsAffected(); @@ -688,7 +685,6 @@ ExWorkProcRetcode ExOnljTcb::work_phase2() g->setRowsAffected(rowsAffected - 1); pstate.rowAlreadyRaisedNFError_ = TRUE; } - else ex_assert(g, "Rowset insert has a flow node that is not in the master executor"); } @@ -948,31 +944,30 @@ ExWorkProcRetcode ExOnljTcb::work_phase2() { ex_queue_entry * uentry = qparent_.up->getTailEntry(); ComDiagsArea *da = uentry->getDiagsArea(); - if (da == NULL) + if (da == NULL) { da = ComDiagsArea::allocate(getGlobals()->getDefaultHeap()); - uentry->setDiagsArea(da); + uentry->setDiagsAreax(da); } - da->insertIntoRowsetRowCountArray(((Lng32) pstate.srcRequestCount_), + da->insertIntoRowsetRowCountArray(((Lng32) pstate.srcRequestCount_), 0, onljTdb().getRowsetRowCountArraySize(), getGlobals()->getDefaultHeap()); } } - if (onljTdb().isRowsetIterator() && + if (onljTdb().isRowsetIterator() && onljTdb().isNonFatalErrorTolerated()) { // These maybe nonfatal errors which need to be consumed // schedule work phase 3 for this - exceptionEvent3_->schedule(); + exceptionEvent3_->schedule(); } break; case ex_queue::Q_INVALID: ex_assert(0,"ExOnljTcb::work_phase2() INVALID returned by left queue"); break; - } // end of switch on status from right } // end of for @@ -1072,30 +1067,29 @@ ExWorkProcRetcode ExOnljTcb::work_phase3() continue; if (request == ex_queue::GET_N && - pentry->downState.requestValue <= (Lng32)pstate.matchCount_) + pentry->downState.requestValue <= (Lng32)pstate.matchCount_) { cancelParentRequest(pentry); continue; } rda = rentry->getDiagsArea(); - // The Insert operator returns a OK_MMORE with a DA that contains a - //negative sqlcode only in case of non fatal errors. - //Until then, this assumption is fine - if (rda && onljTdb().isRowsetIterator() && - onljTdb().isNonFatalErrorTolerated() && + // The Insert operator returns a OK_MMORE with a DA that contains a + //negative sqlcode only in case of non fatal errors. + //Until then, this assumption is fine + if (rda && onljTdb().isRowsetIterator() && + onljTdb().isNonFatalErrorTolerated() && rda->mainSQLCODE() < 0) { // Project this NF error to the parent as a Q_SQLERROR - // set the row index to NONFATAL_ERROR and allow the parent node - // to set the actual row index - rda->setAllRowNumber(ComCondition::NONFATAL_ERROR) ; + // set the row index to NONFATAL_ERROR and allow the parent node + // to set the actual row index + rda->setAllRowNumber(ComCondition::NONFATAL_ERROR); if (!qparent_.up->isFull()) { // set the non fatal error tobe set flag rda->setNonFatalErrorIndexToBeSet(TRUE); - uentry->setDiagsArea(rda); - rda->incrRefCount(); + uentry->shareDiagsArea(rda); uentry->upState.status = ex_queue::Q_SQLERROR; uentry->upState.downIndex = phaseThree; uentry->upState.parentIndex = pentry->downState.parentIndex; @@ -1107,21 +1101,20 @@ ExWorkProcRetcode ExOnljTcb::work_phase3() return WORK_OK; } - //in some cases when we are ignoring dup keys, we may get diags // with no sqlcode - i.e an empty diags area. - // In that case, project the entry to the TSJ2 as a - // Q_REC_SKIPPED. This way in phase2 of TSJ2 the counting will be + // In that case, project the entry to the TSJ2 as a + // Q_REC_SKIPPED. This way in phase2 of TSJ2 the counting will be // accurate for any other NF errors other than dup that unpack or // the PA have raised. // In phase 3 of TSJ2 it will get consumed. - if (rda && onljTdb().isRowsetIterator() && - onljTdb().isNonFatalErrorTolerated() && + if (rda && onljTdb().isRowsetIterator() && + onljTdb().isNonFatalErrorTolerated() && (rda->mainSQLCODE() == 0)) - { + { if (!qparent_.up->isFull()) { - uentry->setDiagsArea(NULL); + uentry->setDiagsAreax(NULL); uentry->upState.status = ex_queue::Q_REC_SKIPPED; uentry->upState.downIndex = phaseThree; uentry->upState.parentIndex = pentry->downState.parentIndex; @@ -1132,8 +1125,7 @@ ExWorkProcRetcode ExOnljTcb::work_phase3() else return WORK_OK; } - - + // row returned from right. Give to parent ex_assert(!isSemiJoin() || rentry->upState.getMatchNo() == 1, "ex_queue::work3() Right returned > 1 row for Semi-join"); @@ -1272,10 +1264,10 @@ ExWorkProcRetcode ExOnljTcb::work_phase3() if (onljTdb().getRowsetRowCountArraySize() > 0) { da = uentry->getDiagsArea(); - if (da == NULL) + if (da == NULL) { da = ComDiagsArea::allocate(getGlobals()->getDefaultHeap()); - uentry->setDiagsArea(da); + uentry->setDiagsAreax(da); } Int64 rowsAffected = 0; if (rentry->getDiagsArea()) { @@ -1283,7 +1275,7 @@ ExWorkProcRetcode ExOnljTcb::work_phase3() rentry->getDiagsArea()->setRowCount(0); } - da->insertIntoRowsetRowCountArray(((Lng32) pstate.tgtRequestCount_+1), + da->insertIntoRowsetRowCountArray(((Lng32) pstate.tgtRequestCount_+1), rowsAffected, onljTdb().getRowsetRowCountArraySize(), getGlobals()->getDefaultHeap()); @@ -1420,7 +1412,7 @@ ExWorkProcRetcode ExOnljTcb::work_phase3() pstate.outerMatched_ = ExConstants::EX_FALSE; break; - + case ex_queue::Q_SQLERROR: // if parent doesn't want any more rows then ignore this row @@ -1443,8 +1435,7 @@ ExWorkProcRetcode ExOnljTcb::work_phase3() if (isLeftJoin()) { uentry->copyAtp(qleft_.up->getHeadEntry()); - uentry->setDiagsArea(rentry->getDiagsArea()); - rentry->getDiagsArea()->incrRefCount(); + uentry->shareDiagsArea(rentry->getDiagsArea()); } else { @@ -1462,10 +1453,10 @@ ExWorkProcRetcode ExOnljTcb::work_phase3() ex_assert(da, "To set RowNumber, an error condition must be present in the diags area"); da->setAllRowNumber((Lng32)(pstate.tgtRequestCount_)+1); } - + // insert into parent up queue qparent_.up->insert(); - + if (! onljTdb().isNonFatalErrorTolerated()) cancelParentRequest(pentry); @@ -1550,7 +1541,7 @@ ExWorkProcRetcode ExOnljTcb::work_phase3() { if (qparent_.up->isFull()) return WORK_OK; - + uentry->copyAtp(lentry); uentry->upState.status = lentry->upState.status; uentry->upState.downIndex = phaseThree; @@ -1567,23 +1558,21 @@ ExWorkProcRetcode ExOnljTcb::work_phase3() else if (lentry->upState.status == ex_queue::Q_NO_DATA) { // if a warning was returned from left with EOD, return that - // warning to parent. - + // warning to parent. + ComDiagsArea *da = lentry->getDiagsArea(); - if (da) - { + if (da) + { ComDiagsArea *accumulatedDiagsArea = uentry->getDiagsArea(); if (accumulatedDiagsArea) accumulatedDiagsArea->mergeAfter(*da); else { - uentry->setDiagsArea(da); - da->incrRefCount(); + uentry->shareDiagsArea(da); } - } } // EOD from left - + // BertBert VVV if (lentry->upState.status == ex_queue::Q_GET_DONE) { @@ -1624,16 +1613,14 @@ ExWorkProcRetcode ExOnljTcb::work_phase3() if (qparent_.up->isFull()) return WORK_OK; - - ComDiagsArea *parentDiagsArea = pentry->getDiagsArea(); // pentry contains all the errors sent in the parent GET_ALL request - // If there are errors raised in the CLI they will be here. Merge these - // into the upentry's diags area + // If there are errors raised in the CLI they will be here. Merge these + // into the upentry's diags area if (onljTdb().isRowsetIterator() && onljTdb().isNonFatalErrorTolerated() ) { - if (parentDiagsArea) // This may have been set by the right child - // TSJ1 in the daigs below if there were nonfatal errors + if (parentDiagsArea) // This may have been set by the right child + // TSJ1 in the daigs below if there were nonfatal errors { // remove the EXE_NONFATAL.. condition/s if any parentDiagsArea->removeLastNonFatalCondition(); @@ -1641,25 +1628,23 @@ ExWorkProcRetcode ExOnljTcb::work_phase3() if (upDiags) { upDiags->mergeAfter(*parentDiagsArea); - } else { - uentry->setDiagsArea(parentDiagsArea); - parentDiagsArea->incrRefCount(); + uentry->shareDiagsArea(parentDiagsArea); } } } - // merge any diags from the upentry with any diags that may be in the + // merge any diags from the upentry with any diags that may be in the // parent entry diags area. NABoolean anyRowsAffected = FALSE; ExMasterStmtGlobals *g = getGlobals()-> castToExExeStmtGlobals()->castToExMasterStmtGlobals(); - - // if a split-top is returning a diags area, - // set the accumulated diags in the parent entry. + + // if a split-top is returning a diags area, + // set the accumulated diags in the parent entry. // It could also be that the IM and undo nodes raised a few nonfatal errors // and all these are being returned in the IM and undo tree's parent node // TSJ3's pstate.accumDiags_ with a Q_NO_DATA. @@ -1672,30 +1657,30 @@ ExWorkProcRetcode ExOnljTcb::work_phase3() // TSJ1 TSJ3 // / \ /\ // Unpack Insert IM Undo - // base + // base - if (pstate.accumDiags_ ) - { - ComDiagsArea *upDiags = uentry->getDiagsArea(); + if (pstate.accumDiags_ ) + { + ComDiagsArea *upDiags = uentry->getDiagsArea(); if (upDiags) - { + { upDiags->mergeAfter(*pstate.accumDiags_); pstate.accumDiags_->decrRefCount(); } else // move diags area to the ATP, reference count // in the diags area stays the same - uentry->setDiagsArea(pstate.accumDiags_); + uentry->setDiagsAreax(pstate.accumDiags_); } pstate.accumDiags_ = NULL; // Compute the rows affected and set the NF warning for any errors coming from the left or right. if (onljTdb().isRowsetIterator() && onljTdb().isNonFatalErrorTolerated() && onljTdb().isSetNFErrorJoin()) { if (g) - { - Int64 rowsAffected = g->getRowsAffected(); + { + Int64 rowsAffected = g->getRowsAffected(); if (g->getRowsAffected() > 0) - anyRowsAffected = TRUE; + anyRowsAffected = TRUE; } else ex_assert(g, "Rowset insert has a flow node that is not in the master executor"); @@ -1706,15 +1691,13 @@ ExWorkProcRetcode ExOnljTcb::work_phase3() if ((mergedDiags) && (mergedDiags->mainSQLCODE() < 0)) { if (anyRowsAffected) - *mergedDiags << DgSqlCode(EXE_NONFATAL_ERROR_SEEN); - else + *mergedDiags << DgSqlCode(EXE_NONFATAL_ERROR_SEEN); + else *mergedDiags << DgSqlCode(EXE_NONFATAL_ERROR_ON_ALL_ROWS); mergedDiags->setNonFatalErrorSeen(TRUE); - } - } //if (onljTdb().isRowsetIterator() && onljTdb().isNonFatalErrorTolerated()) - - + } //if (onljTdb().isRowsetIterator() && onljTdb().isNonFatalErrorTolerated()) + uentry->upState.status = ex_queue::Q_NO_DATA; uentry->upState.downIndex = phaseThree; uentry->upState.setMatchNo(pstate.rowCount_); @@ -1723,9 +1706,9 @@ ExWorkProcRetcode ExOnljTcb::work_phase3() // insert into parent up queue qparent_.up->insert(); // done with this parent row. -} // end of for while rows in the parent down queue - -return WORK_OK; + } // end of for while rows in the parent down queue + + return WORK_OK; } // end of ExOnljTcb::work_phase3() @@ -1770,56 +1753,52 @@ ExWorkProcRetcode ExOnljTcb::workCancel() NABoolean ExOnljTcb::processNonFatalErrorsInLeftUpQueue(NABoolean &project, NABoolean &consumed) { - - queue_index phaseThree; + + queue_index phaseThree; project = FALSE; consumed = FALSE; phaseThree = qparent_.down->getHeadIndex(); ex_queue_entry * uentry = qparent_.up->getTailEntry(); ex_queue_entry * pentry = qparent_.down->getHeadEntry(); ExOnljPrivateState &pstate = *((ExOnljPrivateState*) pentry->pstate); - if ((onljTdb().isRowsetIterator() && + if ((onljTdb().isRowsetIterator() && onljTdb().isNonFatalErrorTolerated())) { - - while (!qleft_.up->isEmpty() && pstate.leftOnlyRows_ && + + while (!qleft_.up->isEmpty() && pstate.leftOnlyRows_ && ((qleft_.up->getHeadEntry()->upState.status == ex_queue::Q_SQLERROR) || (qleft_.up->getHeadEntry()->upState.status == ex_queue::Q_REC_SKIPPED) ) ) { - - ComDiagsArea *lentryDa = qleft_.up->getHeadEntry()->getDiagsArea(); // If this error has not yet been projected to the top TSJ for setting // the correct row index, project it (This is done by the first level // TSJ - if ( lentryDa && !lentryDa->getNonFatalErrorIndexToBeSet() ) - { + if ( lentryDa && !lentryDa->getNonFatalErrorIndexToBeSet() ) + { if (!qparent_.up->isFull()) { if ( qleft_.up->getHeadEntry()->upState.status== ex_queue::Q_REC_SKIPPED) - uentry->setDiagsArea(NULL); + uentry->setDiagsAreax(NULL); else { lentryDa->setNonFatalErrorIndexToBeSet(TRUE); - uentry->setDiagsArea(lentryDa); - lentryDa->incrRefCount(); + uentry->shareDiagsArea(lentryDa); } uentry->upState.status = qleft_.up->getHeadEntry()->upState.status; uentry->upState.downIndex = phaseThree; uentry->upState.parentIndex = pentry->downState.parentIndex; // insert into parent up queue qparent_.up->insert(); - - // consume the left up entry - it's no longer needed + + // consume the left up entry - it's no longer needed qleft_.up->removeHead(); pstate.leftOnlyRows_--; project = TRUE; // restore a good value for uentry uentry = qparent_.up->getTailEntry(); - } else return FALSE; diff --git a/core/sql/executor/ex_queue.cpp b/core/sql/executor/ex_queue.cpp index 2d746da350..4ff4968b22 100644 --- a/core/sql/executor/ex_queue.cpp +++ b/core/sql/executor/ex_queue.cpp @@ -817,26 +817,26 @@ void ex_queue::injectErrorOrCancel() newQNODATA->upState.status = Q_NO_DATA; newQNODATA->getAtp()->copyAtp(qe->getAtp()); tail_++; - cerr << "Injecting a Q_SQLERROR before a Q_NO_DATA, from " + cerr << "Injecting a Q_SQLERROR before a Q_NO_DATA, from " << NodeTypeToString(unblockSubtask_->getTcb()->getNodeType()) - << "(" << unblockSubtask_->getTcb() << ")" + << "(" << unblockSubtask_->getTcb() << ")" << " to " << NodeTypeToString(insertSubtask_->getTcb()->getNodeType()) - << "(" << insertSubtask_->getTcb() << ")" + << "(" << insertSubtask_->getTcb() << ")" << endl; } break; default: break; - } + } if (needsError) { ComDiagsArea * da = qe->getDiagsArea(); - if (!da) + if (!da) da = ComDiagsArea::allocate(insertSubtask_->getTcb()->getHeap()); else da = da->copy(); - qe->setDiagsArea(da); + qe->setDiagsAreax(da); *da << DgSqlCode(-EXE_ERROR_INJECTED) << DgString0(__FILE__) @@ -852,18 +852,18 @@ void ex_queue::logHeader() { if (upDown_ == UP_QUEUE) { - cerr + cerr << NodeTypeToString(unblockSubtask_->getTcb()->getNodeType()) - << "(" << unblockSubtask_->getTcb() << ")" + << "(" << unblockSubtask_->getTcb() << ")" << " up to " << NodeTypeToString(insertSubtask_->getTcb()->getNodeType()) - << "(" << insertSubtask_->getTcb() << ")" + << "(" << insertSubtask_->getTcb() << ")" ; } else { cerr << NodeTypeToString(unblockSubtask_->getTcb()->getNodeType()) - << "(" << unblockSubtask_->getTcb() << ")" + << "(" << unblockSubtask_->getTcb() << ")" << " down to " << NodeTypeToString(insertSubtask_->getTcb()->getNodeType()) << "(" << insertSubtask_->getTcb() << ")" diff --git a/core/sql/executor/ex_queue.h b/core/sql/executor/ex_queue.h index cd586da738..94e722b91b 100644 --- a/core/sql/executor/ex_queue.h +++ b/core/sql/executor/ex_queue.h @@ -542,31 +542,30 @@ class ex_queue_entry }; ex_tcb_private_state * pstate; // private (reader's) state - - + inline ex_cri_desc * criDesc() const; - + inline unsigned short numTuples() const; - + inline tupp & getTupp(Lng32 i) const; - + void passAtp(const ex_queue_entry *from); - + void passAtp(atp_struct *from); - + inline void copyAtp(const ex_queue_entry *from); - + inline void copyAtp(atp_struct *from); - + inline atp_struct * getAtp() const; - // + // // Routines to get and set diagnostics area. // - + inline ComDiagsArea *getDiagsArea() const; - - inline void setDiagsArea(ComDiagsArea* diagsArea); + + inline void setDiagsAreax(ComDiagsArea* diagsArea); private: @@ -639,9 +638,9 @@ inline ComDiagsArea *ex_queue_entry::getDiagsArea() const return atp_->getDiagsArea(); } -inline void ex_queue_entry::setDiagsArea(ComDiagsArea* diagsArea) +inline void ex_queue_entry::setDiagsAreax(ComDiagsArea* diagsArea) { - atp_->setDiagsArea(diagsArea); + atp_->setDiagsAreax(diagsArea); } ///////////////////////////////////////////////////////////////////////////// diff --git a/core/sql/executor/ex_root.cpp b/core/sql/executor/ex_root.cpp index aa1b8705c1..7c5c9eb2a3 100644 --- a/core/sql/executor/ex_root.cpp +++ b/core/sql/executor/ex_root.cpp @@ -716,17 +716,17 @@ Int32 ex_root_tcb::execute(CliGlobals *cliGlobals, if (input_desc) { input_desc->setCompoundStmtsInfo(((ComTdbRoot *) &tdb)->getCompoundStmtsInfo()); } - // + // // This entry may not have a diags area yet. - // If diags area is not available, allocate + // If diags area is not available, allocate // one for the entry. // - if (root_tdb().isNonFatalErrorTolerated()) + if (root_tdb().isNonFatalErrorTolerated()) { - if (!(entry->getDiagsArea())) + if (!(entry->getDiagsArea())) { ComDiagsArea * da = ComDiagsArea::allocate(getHeap()); - entry->setDiagsArea(da); + entry->setDiagsAreax(da); } entry->getDiagsArea()->setLengthLimit(root_tdb().getNotAtomicFailureLimit()); } @@ -734,7 +734,7 @@ Int32 ex_root_tcb::execute(CliGlobals *cliGlobals, // after automatic recompilation. The original input tupp will // be used at this time. if ((! reExecute) && (inputExpr())) - { + { UInt32 flags = 0; inputExpr()->setIsODBC(flags, root_tdb().odbcQuery()); inputExpr()->setIsRWRS(flags, root_tdb().rowwiseRowsetInput()); @@ -746,7 +746,7 @@ Int32 ex_root_tcb::execute(CliGlobals *cliGlobals, (flags, master_glob->getStatement()->getContext()->getSessionDefaults()-> getDbtrProcess()); - + // move the values from user area to internal area ex_expr::exp_return_type rc; if ((input_desc) && @@ -2374,7 +2374,7 @@ short ex_root_tcb::work() // a certain exit status from the work procedure to the root. if (!cancelStarted_) return 1; - + // For async cancel. // Remove all entries except Q_NO_DATA for the cancel request. while (qchild.up->getLength() > 1) @@ -2391,13 +2391,13 @@ short ex_root_tcb::work() // Attach -EXE_CANCELED error to Q_NO_DATA entry. // Return 1 to exit the scheduler loop. ex_queue_entry *centry = qchild.up->getHeadEntry(); - - ComDiagsArea *diagsArea = + + ComDiagsArea *diagsArea = ex_root_tcb::moveDiagsAreaFromEntry(centry); if (diagsArea == NULL) { diagsArea = ComDiagsArea::allocate(getHeap()); - centry->setDiagsArea(diagsArea); + centry->setDiagsAreax(diagsArea); } if (cpuLimitExceeded_) { @@ -2419,9 +2419,9 @@ short ex_root_tcb::work() localCpuTime = fragRootStats->getLocalCpuTime(); else if ((measRootStats = rootStats->castToExMeasStats()) != NULL) localCpuTime = measRootStats->getLocalCpuTime(); - else + else ex_assert(0, "Cpu limit evaluated without runtime stats."); - + *diagsArea << DgInt2((Lng32) localCpuTime / 1000); } } diff --git a/core/sql/executor/ex_send_bottom.cpp b/core/sql/executor/ex_send_bottom.cpp index 1f115f7f78..f393b336f7 100644 --- a/core/sql/executor/ex_send_bottom.cpp +++ b/core/sql/executor/ex_send_bottom.cpp @@ -538,12 +538,12 @@ short ex_send_bottom_tcb::checkRequest() "no diags areas in message"); // construct a copy of diags area from message object // and put it in the queue - ComDiagsArea* diagsArea = + ComDiagsArea* diagsArea = ComDiagsArea::allocate (getGlobals()->getDefaultHeap()); *workMsgStream_ >> *diagsArea; - - sentry->setDiagsArea(diagsArea); + + sentry->setDiagsAreax(diagsArea); } // See if the queue entry is on the cancelOnSight_ list, and if so, @@ -555,11 +555,11 @@ short ex_send_bottom_tcb::checkRequest() sentry->downState.request = ex_queue::GET_NOMORE; } - // if extract work is already done, do not honor any more + // if extract work is already done, do not honor any more // data requests from consumer. - if (isExtractWorkDone_) + if (isExtractWorkDone_) { - // construct reply message + // construct reply message if (currentReplyBuffer_ == NULL) { getReplyBuffer(); diff --git a/core/sql/executor/ex_send_top.cpp b/core/sql/executor/ex_send_top.cpp index c4a1ec951f..1c204df199 100644 --- a/core/sql/executor/ex_send_top.cpp +++ b/core/sql/executor/ex_send_top.cpp @@ -634,10 +634,10 @@ short ex_send_top_tcb::checkReceive() // append the tupp that we got from the message pentry->copyAtp(rentry); pentry->getTupp(rentry->criDesc()->noTuples()) = nextTupp; - pentry->setDiagsArea(diagsArea); + pentry->setDiagsAreax(diagsArea); nextTupp.release(); - // if stats were returned, unpack and merge them to the + // if stats were returned, unpack and merge them to the // stat area. if (ci->getIsExtStatsAreaPresent()) { @@ -645,13 +645,13 @@ short ex_send_top_tcb::checkReceive() ex_assert_both_sides(msgStream_->getNextObjType(msgType) AND msgType == IPC_SQL_STATS_AREA, "no stats area in message"); - + CollHeap * defaultHeap = getGlobals()->getDefaultHeap(); ExStatisticsArea* statArea = new(defaultHeap) ExStatisticsArea(defaultHeap, 0, ((ComTdb*)getTdb())->getCollectStatsType()); - + *msgStream_ >> *statArea; if ( getGlobals()->statsEnabled() ) mergeStats(statArea); @@ -661,7 +661,7 @@ short ex_send_top_tcb::checkReceive() // we can get rid of the received area now NADELETE(statArea, ExStatisticsArea, defaultHeap); } - + // If statistics are being collected, update the number of // rows returned now. if(pentry->upState.status != ex_queue::Q_NO_DATA) diff --git a/core/sql/executor/ex_sort.cpp b/core/sql/executor/ex_sort.cpp index cbc8935b3d..874eacfd02 100644 --- a/core/sql/executor/ex_sort.cpp +++ b/core/sql/executor/ex_sort.cpp @@ -624,7 +624,7 @@ void ExSortTcb::createSortDiags() } //////////////////////////////////////////////////////////////////////// // processSortError() -// +// NABoolean ExSortTcb::processSortError(ex_queue_entry *pentry_down, queue_index parentIndex, queue_index downIndex) @@ -634,19 +634,19 @@ NABoolean ExSortTcb::processSortError(ex_queue_entry *pentry_down, up_entry->upState.parentIndex = downIndex; //qparent_.down->getHeadIndex() up_entry->upState.setMatchNo(0); up_entry->upState.status = ex_queue::Q_SQLERROR; - + ComDiagsArea *diagsArea = up_entry->getDiagsArea(); if (diagsArea == NULL) diagsArea = ComDiagsArea::allocate(this->getGlobals()->getDefaultHeap()); else diagsArea->incrRefCount(); - + if (sortDiag_) diagsArea->mergeAfter(*sortDiag_); - - up_entry->setDiagsArea (diagsArea); - + + up_entry->setDiagsAreax(diagsArea); + // insert into parent qparent_.up->insert(); @@ -1581,7 +1581,7 @@ short ExSortTcb::sortReceive(ex_queue_entry * pentry_down, createSortDiags(); if(sortPartiallyComplete_) step = ExSortTcb::SORT_ERROR; - else + else step = ExSortTcb::SORT_ERROR_ON_RECEIVE; if(receiveTd) { @@ -1597,7 +1597,7 @@ short ExSortTcb::sortReceive(ex_queue_entry * pentry_down, if (sortTdb().collectNFErrors()) { // If there are any nf error entries in the array - if (nfDiags_) + if (nfDiags_) { ComDiagsArea *nfda = NULL; // Get the first NF error in the list @@ -1605,18 +1605,18 @@ short ExSortTcb::sortReceive(ex_queue_entry * pentry_down, // assign it to the tgtEntry diags if (ret && nfda) { - tgtEntry->setDiagsArea(nfda); + tgtEntry->setDiagsAreax(nfda); // remove this entry from the nf list nfDiags_->remove(nfda); } } } - + Int16 *rowLenPtr = NULL; if (resizeCifRecord() > 0 && (topNSortPool_ == NULL)) { if (buf) - { + { char *dataPointer = tgtEntry->getAtp()->getTupp(sortTdb().tuppIndex_).getDataPointer(); buf->resize_tupp_desc(*((Int32 *)dataPointer), dataPointer);// } @@ -1748,7 +1748,7 @@ short ExSortTcb::done( Int64 &matchCount) { ex_queue_entry * pentry = qparent_.up->getTailEntry(); - + // all sorted rows have been returned. if (sendQND) { @@ -1756,7 +1756,7 @@ short ExSortTcb::done( pentry->upState.parentIndex = parentIndex; pentry->upState.downIndex = qparent_.down->getHeadIndex(); pentry->upState.setMatchNo(matchCount); - + // mainly used to propagate rows affected count to parent if (sortDiag_) { @@ -1765,9 +1765,9 @@ short ExSortTcb::done( pUPda = ComDiagsArea::allocate(this->getGlobals()->getDefaultHeap()); else pUPda->incrRefCount(); - + pUPda->mergeAfter(*sortDiag_); - pentry->setDiagsArea (pUPda); + pentry->setDiagsAreax(pUPda); } // insert into parent up queue @@ -1785,11 +1785,11 @@ short ExSortTcb::done( setCompareTd_ = NULL; } sortPartiallyComplete_ = FALSE; - + if (nfDiags_) nfDiags_->deallocate(); nfDiags_ = NULL; - + return 0; } diff --git a/core/sql/executor/ex_split_bottom.cpp b/core/sql/executor/ex_split_bottom.cpp index 4e1084aea4..c867b1646f 100644 --- a/core/sql/executor/ex_split_bottom.cpp +++ b/core/sql/executor/ex_split_bottom.cpp @@ -824,7 +824,7 @@ ExWorkProcRetcode ex_split_bottom_tcb::work() ComDiagsArea *da = ComDiagsArea::allocate( getGlobals()->getDefaultHeap()); *da << DgSqlCode(-CLI_TCB_EXECUTE_ERROR); - upEntry->setDiagsArea(da); + upEntry->setDiagsAreax(da); squeueUp->insert(); qChild_.down->cancelRequest(); @@ -903,14 +903,14 @@ ExWorkProcRetcode ex_split_bottom_tcb::work() localCpuTime = fragRootStats->getLocalCpuTime(); else if ((measRootStats = rootStats->castToExMeasStats()) != NULL) localCpuTime = measRootStats->getLocalCpuTime(); - else + else ex_assert(0, "Cpu limit evaluated without runtime stats."); *da << DgInt2((Lng32) localCpuTime / 1000); } - upEntry->setDiagsArea(da); + upEntry->setDiagsAreax(da); squeueUp->insert(); qChild_.down->cancelRequest(); @@ -1278,19 +1278,19 @@ ExWorkProcRetcode ex_split_bottom_tcb::workUp() continue; } } - + // the down request may not have come from this queue, make // sure the up request looks like a reply to the down request // of the queue sentry->upState.downIndex = squeueDown->getHeadIndex(); sentry->upState.parentIndex = squeueDown->getHeadEntry()->downState.parentIndex; - + // we take the liberty not to set the match # here // since we know that the send top doesn't mind that - + sentry->copyAtp(centry); - + if (isEofEntry) { if (centry->getAtp()->getDiagsArea()) @@ -1303,31 +1303,31 @@ ExWorkProcRetcode ex_split_bottom_tcb::workUp() // parallel extract query and broadcast the // diags area to all send bottoms. if (!splitBottomTdb().getExtractProducerFlag()) - centry->getAtp()->setDiagsArea(NULL); + centry->getAtp()->setDiagsAreax(NULL); } } else if (statsEntry) { statsEntry->incActualRowsReturned(); } - + squeueUp->insert(); - + } // if !GET_NOMORE - + // if this was EOF, remove the corresponding entry from // the down queue if (isEofEntry) { squeueDown->removeHead(); - } + } } // for each send queue that we have to send the entry to - + // we're done with all send bottoms, remove request from the // child queue and invalidate the calculated partition number qChild_.up->removeHead(); calcPartNumIsValid_ = FALSE; - + // We return to the idle state if this was the EOF entry. if (isEofEntry) { diff --git a/core/sql/executor/ex_split_top.cpp b/core/sql/executor/ex_split_top.cpp index 248b3364ed..76f411d58c 100644 --- a/core/sql/executor/ex_split_top.cpp +++ b/core/sql/executor/ex_split_top.cpp @@ -1835,15 +1835,15 @@ ExWorkProcRetcode ex_split_top_tcb::workUp() // calculating input part # or handling non-current down // requests) then return those errors now ex_queue_entry *upentry = qParentUp->getTailEntry(); - + upentry->upState.status = ex_queue::Q_SQLERROR; upentry->upState.downIndex = pindex; upentry->upState.setMatchNo(pstate->matchCountForGetN_); upentry->upState.parentIndex = pentry->downState.parentIndex; // attach diagnostics area (refcount gets transferred to ATP) - upentry->setDiagsArea(pstate->detachDiagsArea()); + upentry->setDiagsAreax(pstate->detachDiagsArea()); qParentUp->insert(); - + if (qParentUp->isFull()) return WORK_OK; } @@ -1852,7 +1852,7 @@ ExWorkProcRetcode ex_split_top_tcb::workUp() // send one end-of-data entry back to the parent // --------------------------------------------------------- ex_queue_entry *upentry = qParentUp->getTailEntry(); - + if (pstate->recSkipped() == TRUE) upentry->upState.status = ex_queue::Q_REC_SKIPPED; else @@ -1863,7 +1863,7 @@ ExWorkProcRetcode ex_split_top_tcb::workUp() upentry->upState.parentIndex = pentry->downState.parentIndex; // error diagnostics have been sent in a separate entry, send // diags area with warnings and # of rows affected here - upentry->setDiagsArea(pstate->detachDiagsArea()); + upentry->setDiagsAreax(pstate->detachDiagsArea()); // insert into parent up queue and delete request qParentUp->insert(); diff --git a/core/sql/executor/ex_stored_proc.cpp b/core/sql/executor/ex_stored_proc.cpp index 982d5c1a25..a15b0205bd 100644 --- a/core/sql/executor/ex_stored_proc.cpp +++ b/core/sql/executor/ex_stored_proc.cpp @@ -641,57 +641,56 @@ short ExStoredProcTcb::work() } break; - case ex_queue::Q_NO_DATA: + case ex_queue::Q_NO_DATA: { if (diags) { - ComDiagsArea * da = - ComDiagsArea::allocate( + ComDiagsArea * da = + ComDiagsArea::allocate( getGlobals()->getDefaultHeap()); da->unpackObj(diags->getType(), diags->getVersion(), TRUE, // sameEndianness, 0, // dummy for now... (IpcConstMessageBufferPtr) diags); - up_entry->setDiagsArea(da); + up_entry->setDiagsAreax(da); } - - + // done with this input request. up_entry->upState.status = ex_queue::Q_NO_DATA; up_entry->upState.parentIndex = pentry_down->downState.parentIndex; up_entry->upState.setMatchNo(pstate.matchCount_); - + // insert into parent qparent_.up->insert(); - + pstate.matchCount_ = 0; pstate.errorHappened_ = FALSE; - + qparent_.down->removeHead(); numInputRequests_--; } break; - + case ex_queue::Q_SQLERROR: { - if (pstate.errorHappened_) + if (pstate.errorHappened_) { // just ignore this row -- we've already returned an error. } else { - ComDiagsArea * da = - ComDiagsArea::allocate( + ComDiagsArea * da = + ComDiagsArea::allocate( getGlobals()->getDefaultHeap()); da->unpackObj(diags->getType(), diags->getVersion(), TRUE, // sameEndianness, 0, // dummy for now... (IpcConstMessageBufferPtr) diags); - up_entry->setDiagsArea(da); + up_entry->setDiagsAreax(da); // insert into parent qparent_.up->insert(); @@ -709,7 +708,7 @@ short ExStoredProcTcb::work() } // switch step_ } // while - + return WORK_OK; } diff --git a/core/sql/executor/ex_transaction.cpp b/core/sql/executor/ex_transaction.cpp index f2b2fb0b37..e10b752ed5 100644 --- a/core/sql/executor/ex_transaction.cpp +++ b/core/sql/executor/ex_transaction.cpp @@ -1140,25 +1140,25 @@ short ExTransTcb::work() (NOT transTdb().setAllowedInXn()))) { cliGlobals->setUdrXactViolation(TRUE); - + ex_queue_entry *up_entry = qparent_.up->getTailEntry(); up_entry->upState.parentIndex = pentry_down->downState.parentIndex; up_entry->upState.setMatchNo(0); up_entry->upState.status = ex_queue::Q_SQLERROR; - + ComDiagsArea *diags_my = up_entry->getDiagsArea(); - + if (!diags_my){ diags_my = ComDiagsArea::allocate(stmtGlob->getDefaultHeap()); - up_entry->setDiagsArea(diags_my); + up_entry->setDiagsAreax(diags_my); } *diags_my << DgSqlCode(- CLI_NO_TRANS_STMT_VIOLATION); - + // insert into parent qparent_.up->insert(); - - } + + } else{ short rc; @@ -1166,11 +1166,11 @@ short ExTransTcb::work() case BEGIN_: { if (ta->userEndedExeXn()) { - handleErrors(pentry_down, NULL, + handleErrors(pentry_down, NULL, (ExeErrorCode)(-CLI_USER_ENDED_EXE_XN)); break; } - + rc = ta->beginTransaction(); if (rc != 0) { // beginTransaction returned an error. diff --git a/core/sql/executor/ex_tuple.cpp b/core/sql/executor/ex_tuple.cpp index e63ef1c1d5..e24f5d7c33 100644 --- a/core/sql/executor/ex_tuple.cpp +++ b/core/sql/executor/ex_tuple.cpp @@ -613,8 +613,8 @@ ExWorkProcRetcode ExTupleNonLeafTcb::work() } else { - up_entry6->setDiagsArea(tempDA);//child did not have diags area - //use the Diags Area generated + up_entry6->setDiagsAreax(tempDA);//child did not have diags area + //use the Diags Area generated //by the error in the expression } } diff --git a/core/sql/executor/ex_tuple_flow.cpp b/core/sql/executor/ex_tuple_flow.cpp index 676a185eaf..7d628b9215 100644 --- a/core/sql/executor/ex_tuple_flow.cpp +++ b/core/sql/executor/ex_tuple_flow.cpp @@ -291,16 +291,16 @@ short ExTupleFlowTcb::work() } else { - tgt_entry->downState.request = + tgt_entry->downState.request = ex_queue::GET_EOD; } - tgt_entry->downState.requestValue = + tgt_entry->downState.requestValue = pentry_down->downState.requestValue; - tgt_entry->downState.parentIndex = + tgt_entry->downState.parentIndex = (Lng32) pstate.srcRequestCount_; tgt_entry->copyAtp(src_entry); - + qTgt_.down->insert(); pstate.tgtRequests_++; } @@ -314,40 +314,40 @@ short ExTupleFlowTcb::work() if (qParent_.up->isFull()) return WORK_OK; - ex_queue_entry * up_entry = + ex_queue_entry * up_entry = qParent_.up->getTailEntry(); if (src_entry->getDiagsArea()) src_entry->getDiagsArea()->incrRefCount(); - up_entry->setDiagsArea(src_entry->getDiagsArea()); + up_entry->setDiagsAreax(src_entry->getDiagsArea()); } qSrc_.up->removeHead(); - + pstate.srcEOD_ = TRUE; - + if (tflowTdb().sendEODtoTgt()) pstate.step_ = MOVE_EOD_TO_TGT_; } break; - + case ex_queue::Q_SQLERROR: { if (qParent_.up->isFull()) return WORK_OK; - + ex_queue_entry * pentry = qParent_.up->getTailEntry(); ComDiagsArea * da = src_entry->getDiagsArea(); ex_assert(da, "We have a Q_SQLERROR in Tupleflow but no diags area"); - + if (tflowTdb().isNonFatalErrorTolerated() && - (da->getNextRowNumber(ComCondition::NONFATAL_ERROR) == - ComCondition::NONFATAL_ERROR)) + (da->getNextRowNumber(ComCondition::NONFATAL_ERROR) == + ComCondition::NONFATAL_ERROR)) { - pstate.nonFatalErrorSeen_ = TRUE; + pstate.nonFatalErrorSeen_ = TRUE; } - else + else { pstate.step_ = HANDLE_ERROR_; pstate.nonFatalErrorSeen_ = FALSE; @@ -355,37 +355,36 @@ short ExTupleFlowTcb::work() pstate.srcRequestCount_++; if(tflowTdb().isRowsetIterator()) - da->setAllRowNumber((Lng32) pstate.srcRequestCount_); + da->setAllRowNumber((Lng32) pstate.srcRequestCount_); ComDiagsArea *accumulatedDiagsArea = pentry->getDiagsArea(); if (accumulatedDiagsArea) { accumulatedDiagsArea->mergeAfter(*da); - if (!(accumulatedDiagsArea->canAcceptMoreErrors()) && - tflowTdb().isNonFatalErrorTolerated()) + if (!(accumulatedDiagsArea->canAcceptMoreErrors()) && + tflowTdb().isNonFatalErrorTolerated()) { pstate.nonFatalErrorSeen_ = FALSE; - pstate.step_ = HANDLE_ERROR_; + pstate.step_ = HANDLE_ERROR_; } } else { - pentry->setDiagsArea(da); - da->incrRefCount(); + pentry->shareDiagsAreax(da); accumulatedDiagsArea = da ; - if (tflowTdb().isNonFatalErrorTolerated()) + if (tflowTdb().isNonFatalErrorTolerated()) { ComDiagsArea *cliDiagsArea = pentry_down->getDiagsArea(); da->setLengthLimit(cliDiagsArea->getLengthLimit()); } } - // For Non-Fatal errors we will remove this Q_SQLERROR reply from the + // For Non-Fatal errors we will remove this Q_SQLERROR reply from the // left child right below as we will continue to stay in this state (MOVE_SRC_TO_TGT_). // For fatal errors this Q_SQLERROR reply is removed in HANDLE_ERROR step to which // we will transition immediately. if (pstate.nonFatalErrorSeen_ == TRUE) - qSrc_.up->removeHead(); + qSrc_.up->removeHead(); } break; @@ -394,7 +393,7 @@ short ExTupleFlowTcb::work() pstate.srcRequestCount_++; ComDiagsArea * da = src_entry->getDiagsArea(); if (da) - pstate.nonFatalErrorSeen_ = TRUE; + pstate.nonFatalErrorSeen_ = TRUE; qSrc_.up->removeHead(); } break; @@ -484,29 +483,27 @@ short ExTupleFlowTcb::work() // Non-atomic Rowsets sends OK_MMORE with non-empty diags from child // empty diags (mainsqlcode == 0) implies OK_MMORE sent by ignoreDupKey code // when NAR is on, for -8102 error. Just consume the OK_MMORE. - - if(tflowTdb().isRowsetIterator()) + if(tflowTdb().isRowsetIterator()) { da->setAllRowNumber(Lng32 (tgt_entry->upState.parentIndex)); } - + pstate.nonFatalErrorSeen_ = TRUE; ex_queue_entry * pentry = qParent_.up->getTailEntry(); ComDiagsArea *accumulatedDiagsArea = pentry->getDiagsArea(); if (accumulatedDiagsArea) { accumulatedDiagsArea->mergeAfter(*da); - if (!(accumulatedDiagsArea->canAcceptMoreErrors()) && - tflowTdb().isNonFatalErrorTolerated()) + if (!(accumulatedDiagsArea->canAcceptMoreErrors()) && + tflowTdb().isNonFatalErrorTolerated()) { pstate.nonFatalErrorSeen_ = FALSE; - pstate.step_ = HANDLE_ERROR_; + pstate.step_ = HANDLE_ERROR_; } } else { - pentry->setDiagsArea(da); - da->incrRefCount(); + pentry->shareDiagsAreax(da); if (tflowTdb().isNonFatalErrorTolerated()) { ComDiagsArea *cliDiagsArea = pentry_down->getDiagsArea(); da->setLengthLimit(cliDiagsArea->getLengthLimit()); @@ -518,7 +515,7 @@ short ExTupleFlowTcb::work() qTgt_.up->removeHead(); } break; - + case ex_queue::Q_NO_DATA: { ComDiagsArea * da = tgt_entry->getDiagsArea(); @@ -526,12 +523,11 @@ short ExTupleFlowTcb::work() { ex_queue_entry * pentry = qParent_.up->getTailEntry(); ComDiagsArea *accumulatedDiagsArea = pentry->getDiagsArea(); - if (accumulatedDiagsArea) + if (accumulatedDiagsArea) accumulatedDiagsArea->mergeAfter(*da); else { - pentry->setDiagsArea(da); - da->incrRefCount(); + pentry->shareDiagsArea(da); if (tflowTdb().isNonFatalErrorTolerated()) { ComDiagsArea *cliDiagsArea = pentry_down->getDiagsArea(); da->setLengthLimit(cliDiagsArea->getLengthLimit()); @@ -544,37 +540,34 @@ short ExTupleFlowTcb::work() pstate.startRightIndex_++; } break; - + case ex_queue::Q_SQLERROR: { if (qParent_.up->isFull()) return WORK_OK; - + ex_queue_entry * pentry = qParent_.up->getTailEntry(); - pentry->copyAtp(tgt_entry); + pentry->copyAtp(tgt_entry); pstate.nonFatalErrorSeen_ = FALSE; - pstate.step_ = HANDLE_ERROR_; + pstate.step_ = HANDLE_ERROR_; - if(tflowTdb().isRowsetIterator()) + if(tflowTdb().isRowsetIterator()) { ex_queue_entry * pentry = qParent_.up->getTailEntry(); ComDiagsArea *da = pentry->getDiagsArea(); ex_assert(da, "To set RowNumber, an error condition must be present in the diags area"); - da->setAllRowNumber(Lng32 (tgt_entry->upState.parentIndex)); + da->setAllRowNumber(Lng32 (tgt_entry->upState.parentIndex)); } - } break; - + default: { ex_assert(0, "ExTupleFlowTcb::work() Error returned from tgt"); } break; - } // switch - - } // while + } // while if (pstate.step_ == HANDLE_ERROR_) break; @@ -695,18 +688,18 @@ short ExTupleFlowTcb::work() // insert Q_SQLERROR into the parent up queue if ((pstate.srcEOD_ == TRUE) && !pstate.tgtRequests_) { - pstate.step_ = DONE_; + pstate.step_ = DONE_; } else return WORK_OK; } break; - + case DONE_: { if (qParent_.up->isFull()) return WORK_OK; - + ex_queue_entry * pentry = qParent_.up->getTailEntry(); if (pstate.nonFatalErrorSeen_) { @@ -718,10 +711,9 @@ short ExTupleFlowTcb::work() da->mergeAfter(*cliDiagsArea); else { - pentry->setDiagsArea(cliDiagsArea); - cliDiagsArea->incrRefCount(); + pentry->shareDiagsArea(cliDiagsArea); } - } + } if (cliDiagsArea->canAcceptMoreErrors()) { ComDiagsArea *mergedDiagsArea = pentry->getDiagsArea(); @@ -737,10 +729,10 @@ short ExTupleFlowTcb::work() ex_assert(g, "Rowset insert has a flow node that is not in the master executor"); if (g->getRowsAffected() > 0) anyRowsAffected = TRUE; - + if (anyRowsAffected) *mergedDiagsArea << DgSqlCode(EXE_NONFATAL_ERROR_SEEN); - else + else *mergedDiagsArea << DgSqlCode(EXE_NONFATAL_ERROR_ON_ALL_ROWS); } // we exceeded the Nonfatal error limit when merging with the CLI diags area @@ -751,7 +743,7 @@ short ExTupleFlowTcb::work() break ; } } - + pentry->upState.status = ex_queue::Q_NO_DATA; pentry->upState.downIndex = qParent_.down->getHeadIndex(); pentry->upState.parentIndex = pentry_down->downState.parentIndex; @@ -765,7 +757,7 @@ short ExTupleFlowTcb::work() if (da == NULL) { da = ComDiagsArea::allocate(getGlobals()->getDefaultHeap()); - pentry->setDiagsArea(da); + pentry->setDiagsAreax(da); } da->addRowCount(pstate.noOfUnPackedRows_); pstate.noOfUnPackedRows_ = 0; @@ -780,12 +772,12 @@ short ExTupleFlowTcb::work() // to parent. getStatsEntry()->setActualRowsReturned(0); } - + // insert into parent up queue qParent_.up->insert(); - + pstate.step_ = EMPTY_; - qParent_.down->removeHead(); + qParent_.down->removeHead(); return WORK_CALL_AGAIN; // check for more down requests diff --git a/core/sql/executor/ex_union.cpp b/core/sql/executor/ex_union.cpp index 1cfe82df11..a5991c5907 100644 --- a/core/sql/executor/ex_union.cpp +++ b/core/sql/executor/ex_union.cpp @@ -267,14 +267,14 @@ void ex_union_tcb::stop() // Remove the head entries of the parent down queue and the two // child up queues. All checks are done by the caller. - ex_queue_entry * pentry_down = qparent.down->getHeadEntry(); + ex_queue_entry * pentry_down = qparent.down->getHeadEntry(); ex_union_private_state & pstate = - *((ex_union_private_state*) pentry_down->pstate); + *((ex_union_private_state*) pentry_down->pstate); ex_queue_entry * pentry = qparent.up->getTailEntry(); ex_queue_entry * centry0 = childQueues_[0].up->getHeadEntry(); ex_queue_entry * centry1 = childQueues_[1].up->getHeadEntry(); - + pentry->upState.status = ex_queue::Q_NO_DATA; pentry->upState.parentIndex = pentry_down->downState.parentIndex; pentry->upState.downIndex = qparent.down->getHeadIndex(); @@ -282,32 +282,32 @@ void ex_union_tcb::stop() centry1->upState.getMatchNo()); ComDiagsArea *da = pentry->getDiagsArea(); - - + + ComDiagsArea *c0da = centry0->getDiagsArea(); ComDiagsArea *c1da = centry1->getDiagsArea(); - if (c0da || c1da) - if (da == NULL) + if (c0da || c1da) + if (da == NULL) { da = ComDiagsArea::allocate(getGlobals()->getDefaultHeap()); - pentry->setDiagsArea(da); + pentry->setDiagsAreax(da); } - + if (c0da) da->mergeAfter(*c0da); if (c1da) da->mergeAfter(*c1da); - + // insert into parent qparent.up->insert(); - + // consume the left and right child row - childQueues_[0].up->removeHead(); - childQueues_[1].up->removeHead(); + childQueues_[0].up->removeHead(); + childQueues_[1].up->removeHead(); pstate.init(); - // this parent request has been processed. + // this parent request has been processed. // Hasta La Vista! qparent.down->removeHead(); } @@ -495,9 +495,9 @@ ExWorkProcRetcode ex_union_tcb::workUp() // couldn't alloc., try again later. return WORK_POOL_BLOCKED; } - + // copy down entry ATP into up entry - + // copy child data to parent ATP if (moveExpr(side)->eval(centry->getAtp(), pentry->getAtp()) == ex_expr::EXPR_ERROR) @@ -509,7 +509,7 @@ ExWorkProcRetcode ex_union_tcb::workUp() // Setting the diagnostics area for the up entry. This is // to flow the diagnostics information to the parent. ComDiagsArea * da = centry->getAtp()->getDiagsArea(); - pentry->getAtp()->setDiagsArea(da); + pentry->getAtp()->setDiagsAreax(da); if (da) da->incrRefCount(); } @@ -519,12 +519,12 @@ ExWorkProcRetcode ex_union_tcb::workUp() // the output atp (to parent's up queue) pentry->copyAtp(centry); } - + pentry->upState.setMatchNo(++pstate.matchCount_); // insert into parent up queue - qparent.up->insert(); - + qparent.up->insert(); + } // child state is not cancelled else if ((pstate.childStates_[side] != CANCELLED_) && (centry->upState.status == ex_queue::Q_SQLERROR)) @@ -1042,7 +1042,7 @@ void ex_o_union_tcb::startRightchild() // For NAR, we do not want to send down the diags area. if (union_tdb().inNotAtomicStmt()) - rentry->setDiagsArea(0); + rentry->setDiagsAreax(0); childQueues_[1].down->insert(); @@ -1238,21 +1238,21 @@ ExWorkProcRetcode ex_c_union_tcb::condWorkDown() // // Get handles. // - ex_queue_entry *pentry_down = + ex_queue_entry *pentry_down = qparent.down->getQueueEntry(processedInputs_); - ex_union_private_state &pstate = - *((ex_union_private_state*) pentry_down->pstate); + ex_union_private_state &pstate = + *((ex_union_private_state*) pentry_down->pstate); // // Evaluate the conditional expression. If it evaluates to TRUE, // the left child is started. If it evaluates to FALSE, and there is // a right child, it is started. Othewise, stop servicing the request. // - ex_expr::exp_return_type retCode = + ex_expr::exp_return_type retCode = condExpr()->eval(pentry_down->getAtp(), 0); - if (retCode == ex_expr::EXPR_TRUE) + if (retCode == ex_expr::EXPR_TRUE) { if (!(union_tdb().inNotAtomicStmt())) pstate.whichChild_ = 0; @@ -1261,10 +1261,10 @@ ExWorkProcRetcode ex_c_union_tcb::condWorkDown() pstate.whichChild_ = -1; pstate.setErrorCode(1); processedInputs_++; - ComDiagsArea * da = ExRaiseSqlError(getGlobals()->getDefaultHeap(), + ComDiagsArea * da = ExRaiseSqlError(getGlobals()->getDefaultHeap(), pentry_down, (ExeErrorCode)-EXE_NOTATOMIC_ENABLED_AFTER_TRIGGER); - pentry_down->setDiagsArea(da); + pentry_down->setDiagsAreax(da); workUpEvent_->schedule(); continue; } @@ -1554,12 +1554,12 @@ void ex_c_union_tcb::processEODErrorOrWarning(NABoolean isWarning) da = ExRaiseSqlError(getGlobals()->getDefaultHeap(), puentry, (ExeErrorCode)-EXE_CS_EOD_ROLLBACK_ERROR); - puentry->setDiagsArea(da); + puentry->setDiagsAreax(da); puentry->upState.status = ex_queue::Q_SQLERROR; puentry->upState.parentIndex = pdentry->downState.parentIndex; puentry->upState.downIndex = qparent.down->getHeadIndex(); puentry->upState.setMatchNo(0); - + qparent.up->insert(); } //ex_c_union_tcb::processEODErrorOrWarning diff --git a/core/sql/exp/ExpAtp.h b/core/sql/exp/ExpAtp.h index 2e35ee49ae..a5b36b53af 100644 --- a/core/sql/exp/ExpAtp.h +++ b/core/sql/exp/ExpAtp.h @@ -96,7 +96,8 @@ class atp_struct // Methods for manipulating diagnostics area. // inline ComDiagsArea *getDiagsArea() const; - inline void setDiagsArea(ComDiagsArea* diagsArea); + inline void setDiagsAreax(ComDiagsArea* diagsArea); + inline void shareDiagsAreax(ComDiagsArea* diagsArea); inline void initDiagsArea(ComDiagsArea* diagsArea); Long pack(void * space); Lng32 unpack(Lng32 base); @@ -198,8 +199,27 @@ inline ComDiagsArea *atp_struct::getDiagsArea() const return diagsArea_; } -inline void atp_struct::setDiagsArea(ComDiagsArea* diagsArea) +// this takes effect like std::move() in C++11 +inline void atp_struct::setDiagsAreax(ComDiagsArea* diagsArea) { + if (diagsArea == diagsArea_) + return; + + if (diagsArea_) + diagsArea_->decrRefCount(); + + diagsArea_ = diagsArea; +} + +// this increases the refCount +inline void atp_struct::shareDiagsArea(ComDiagsArea* diagsArea) +{ + if (diagsArea == diagsArea_) + return; + + if (diagsArea) + diagsArea->incrRefCount(); + if (diagsArea_) diagsArea_->decrRefCount(); @@ -250,10 +270,7 @@ inline void atp_struct::copyAtp(atp_struct *from) set_tag(from->get_tag()); - if (from->getDiagsArea()) - from->getDiagsArea()->incrRefCount(); - - setDiagsArea(from->getDiagsArea()); + shareDiagsArea(from->getDiagsArea()); } // copies tupps first_tupp thru last_tupp from 'from'(source) @@ -278,7 +295,7 @@ inline void atp_struct::copyPartialAtp(atp_struct * from, short last_tupp) { short j = my_first_tupp; - + for (short i = from_first_tupp; i <= last_tupp; i++, j++) { this->getTupp(j) = from->getTupp(i); //copy tupp @@ -305,7 +322,7 @@ inline void atp_struct::release() // null-out diags area pointer; setDiagsArea releases existing // reference to diags area if it is non-null - setDiagsArea(0); + setDiagsAreax(0); } inline void atp_struct::releasePartialAtp(short from_first_tupp, @@ -317,10 +334,10 @@ inline void atp_struct::releasePartialAtp(short from_first_tupp, { tuppArray_[i].release(); } - + // null-out diags area pointer; setDiagsArea releases existing // reference to diags area if it is non-null - setDiagsArea(0); + setDiagsAreax(0); } #endif diff --git a/core/sql/exp/exp_eval.cpp b/core/sql/exp/exp_eval.cpp index 00fbcc4da6..5eccb7c0c4 100644 --- a/core/sql/exp/exp_eval.cpp +++ b/core/sql/exp/exp_eval.cpp @@ -461,12 +461,12 @@ ex_expr::exp_return_type ex_expr::evalClauses(ex_clause *clause, } else defValNeeded = TRUE; - + if ((defValNeeded) && (mode == exp_READ)) { ComDiagsArea *diagsArea = atp1->getDiagsArea(); - retcode = + retcode = getDefaultValueForAddedColumn((*op)->getDefaultFieldNum(), tuppDesc, *op, @@ -478,9 +478,8 @@ ex_expr::exp_return_type ex_expr::evalClauses(ex_clause *clause, if (retcode == ex_expr::EXPR_ERROR) { - if (diagsArea != atp1->getDiagsArea()) - atp1->setDiagsArea(diagsArea); - + atp1->setDiagsAreax(diagsArea); + return retcode; } } @@ -675,7 +674,7 @@ ex_expr::exp_return_type ex_expr::evalClauses(ex_clause *clause, { ComDiagsArea *diagsArea = atp1->getDiagsArea(); - // this sets the *nulldata, *opdata, *vardata as needed + // this sets the *nulldata, *opdata, *vardata as needed retcode = getDefaultValueForAddedColumn ((*op)->getDefaultFieldNum(), @@ -689,19 +688,18 @@ ex_expr::exp_return_type ex_expr::evalClauses(ex_clause *clause, if (retcode == ex_expr::EXPR_ERROR) { - if (diagsArea != atp1->getDiagsArea()) - atp1->setDiagsArea(diagsArea); - + atp1->setDiagsAreax(diagsArea); + return retcode; } // all pointers are set now break; - } - else + } + else { // not an added column needing special attn. // but there may be other added columns present - + // if variable field, then read the offset from // the data record if ( varIndLen > 0 ) @@ -709,7 +707,7 @@ ex_expr::exp_return_type ex_expr::evalClauses(ex_clause *clause, offset = ExpTupleDesc::getVoaOffset(dataPtr, voaOffset, tdf); - + } else { @@ -765,13 +763,13 @@ ex_expr::exp_return_type ex_expr::evalClauses(ex_clause *clause, *vardata = dataPtr + offset; offset += varIndLen; } - + *opdata = dataPtr + offset; } // else read mode } else // missing value (indicates a null value) *nulldata = 0; - + } // SQLMX_FORMAT, SQLMX_ALIGNED_FORMAT break; @@ -779,8 +777,7 @@ ex_expr::exp_return_type ex_expr::evalClauses(ex_clause *clause, { ComDiagsArea *diagsArea = atp1->getDiagsArea(); ExRaiseSqlError(getHeap(), &diagsArea, EXE_INTERNAL_ERROR); - if(diagsArea != atp1->getDiagsArea()) - atp1->setDiagsArea(diagsArea); + atp1->setDiagsAreax(diagsArea); return ex_expr::EXPR_ERROR; } @@ -806,7 +803,7 @@ ex_expr::exp_return_type ex_expr::evalClauses(ex_clause *clause, } } // for - + // ----------------------------------------------------------------- // Call the NULL processing method for this clause and, if still // necessary, evaluate the expression. Note that if the @@ -849,9 +846,8 @@ ex_expr::exp_return_type ex_expr::evalClauses(ex_clause *clause, if (currAttr->isSQLMXAlignedFormat()) prevAttr = currAttr; } - - if (diagsArea != atp1->getDiagsArea()) - atp1->setDiagsArea(diagsArea); + + atp1->setDiagsAreax(diagsArea); if (retcode == ex_expr::EXPR_ERROR) return retcode; @@ -1598,8 +1594,7 @@ ex_expr::exp_return_type reportErr(atp_struct* atp1, ex_expr* expr) diagsArea = atp1->getDiagsArea(); ExRaiseSqlError(expr->getHeap(), &diagsArea, EXE_INTERNAL_ERROR); - if(diagsArea != atp1->getDiagsArea()) - atp1->setDiagsArea(diagsArea); + atp1->setDiagsArea(diagsArea); return ex_expr::EXPR_ERROR; } @@ -2500,7 +2495,7 @@ ex_expr::exp_return_type ex_expr::evalPCode(PCodeBinary* pCode32, retCode = alignAndEval(clause, opDataData, getHeap(), &diagsArea); if (diagsArea != atp1->getDiagsArea()) - atp1->setDiagsArea(diagsArea); + atp1->setDiagsAreax(diagsArea); if(retCode == ex_expr::EXPR_ERROR) return retCode; @@ -2983,36 +2978,36 @@ ex_expr::exp_return_type ex_expr::evalPCode(PCodeBinary* pCode32, ex_expr::exp_return_type er = convDoIt(ptrSrc, srcLen, REC_BYTE_F_ASCII, 0, 0, - (char*)&srcNumericVal, sizeof(Int64), - (pCodeOpc == PCIT::CONVVCPTR_MBIN64S_MATTR5_IBIN32S - ? REC_BIN64_SIGNED : REC_BIN32_SIGNED), - 0, 0, + (char*)&srcNumericVal, sizeof(Int64), + (pCodeOpc == PCIT::CONVVCPTR_MBIN64S_MATTR5_IBIN32S + ? REC_BIN64_SIGNED : REC_BIN32_SIGNED), + 0, 0, NULL, 0, heap_, &diagsArea, CONV_ASCII_BIN64S, NULL, 0); - if (diagsArea != atp1->getDiagsArea()) - atp1->setDiagsArea(diagsArea); - if (er == ex_expr::EXPR_ERROR) + atp1->setDiagsAreax(diagsArea); + + if (er == ex_expr::EXPR_ERROR) return ex_expr::EXPR_ERROR; } if (pCodeOpc == PCIT::CONVVCPTR_MBIN64S_MATTR5_IBIN32S) { if (neg) - *(Int64*)dst = -srcNumericVal; + *(Int64*)dst = -srcNumericVal; else - *(Int64*)dst = srcNumericVal; + *(Int64*)dst = srcNumericVal; } else { if (neg) - *(Lng32*)dst = -(Int32)srcNumericVal; + *(Lng32*)dst = -(Int32)srcNumericVal; else - *(Lng32*)dst = (Int32)srcNumericVal; + *(Lng32*)dst = (Int32)srcNumericVal; } - + pCode += 8; } break; @@ -3045,7 +3040,7 @@ ex_expr::exp_return_type ex_expr::evalPCode(PCodeBinary* pCode32, Int64 ptrVal = *(Int64*)(src + srcVCIndLen); char * ptrSrc = (char*)ptrVal; - // convert source to target (Flt32). + // convert source to target (Flt32). // First try simple conversion. If that returns an error, try complex conversion. NABoolean neg = FALSE; if (ptrSrc[0] == '-') @@ -3061,21 +3056,22 @@ ex_expr::exp_return_type ex_expr::evalPCode(PCodeBinary* pCode32, diagsArea = atp1->getDiagsArea(); ex_expr::exp_return_type er = convDoIt(ptrSrc, srcLen, REC_BYTE_F_ASCII, 0, 0, - (char*)&srcNumericVal, sizeof(double), REC_FLOAT32, 0, 0, + (char*)&srcNumericVal, sizeof(double), REC_FLOAT32, 0, 0, NULL, 0, heap_, &diagsArea, CONV_ASCII_FLOAT64, NULL, 0); - if (diagsArea != atp1->getDiagsArea()) - atp1->setDiagsArea(diagsArea); - if (er == ex_expr::EXPR_ERROR) + + atp1->setDiagsArea(diagsArea); + + if (er == ex_expr::EXPR_ERROR) return ex_expr::EXPR_ERROR; } if (neg) - *(float*)dst = - (float)srcNumericVal; + *(float*)dst = - (float)srcNumericVal; else - *(float*)dst = (float)srcNumericVal; + *(float*)dst = (float)srcNumericVal; pCode += 8; } @@ -3090,7 +3086,7 @@ ex_expr::exp_return_type ex_expr::evalPCode(PCodeBinary* pCode32, BASE_PTR_DEF_ASSIGN(char,tgt, 0); DEF_ASSIGN(Int32,comboLen1, 4); - char* comboPtr1 = (char*)&comboLen1; + char* comboPtr1 = (char*)&comboLen1; Int16 tgtNullIndLen = (Int16)comboPtr1[0]; Int16 tgtVCIndLen = (Int16)comboPtr1[1]; @@ -3118,7 +3114,7 @@ ex_expr::exp_return_type ex_expr::evalPCode(PCodeBinary* pCode32, DEF_ASSIGN(Int32,tgtOffset, 1); DEF_ASSIGN(Int32,tgtVoaOffset, 2); - + // VOA offsets should always be used in order. if(tgtVoaOffset > 0) { assert(tgtVoaOffset > lastVoaOffset); @@ -3132,20 +3128,21 @@ ex_expr::exp_return_type ex_expr::evalPCode(PCodeBinary* pCode32, varOffset, copyLen ); - + if (copyLen < srcLen) { diagsArea = atp1->getDiagsArea(); ex_expr::exp_return_type er = convDoIt(ptrSrc, srcLen, REC_BYTE_F_ASCII, 0, 0, - (tgt+tgtVCIndLen), maxTgtLen, REC_BYTE_V_ASCII, 0, 0, + (tgt+tgtVCIndLen), maxTgtLen, REC_BYTE_V_ASCII, 0, 0, tgt, tgtVCIndLen, heap_, &diagsArea, CONV_ASCII_F_V, NULL, 0); - if (diagsArea != atp1->getDiagsArea()) - atp1->setDiagsArea(diagsArea); - if (er == ex_expr::EXPR_ERROR) + + atp1->setDiagsArea(diagsArea); + + if (er == ex_expr::EXPR_ERROR) return ex_expr::EXPR_ERROR; } else @@ -3525,27 +3522,27 @@ ex_expr::exp_return_type ex_expr::evalPCode(PCodeBinary* pCode32, BASE_PTR_DEF_ASSIGN(char, src, 5); BASE_PTR_DEF_ASSIGN(char, tgt, 0); - + if (srcVCIndLen > 0) // is varchar { src += ExpTupleDesc::getVarOffset(src, - srcOffset, + srcOffset, srcVoaOffset, - srcVCIndLen, + srcVCIndLen, srcNullIndLen); srcMaxLen = ExpTupleDesc::getVarLength(src, srcVCIndLen); src += srcVCIndLen; - } + } else { - src += srcOffset; + src += srcOffset; } PTR_DEF_ASSIGN(Int32, startPtr, 10); PTR_DEF_ASSIGN(Int32, lengthPtr,12); - Int64 start = *startPtr; - Int64 length = *lengthPtr; + Int64 start = *startPtr; + Int64 length = *lengthPtr; Int64 temp = ((numOperands > 0) ? (start + length) @@ -3556,8 +3553,8 @@ ex_expr::exp_return_type ex_expr::evalPCode(PCodeBinary* pCode32, diagsArea = atp1->getDiagsArea(); ExRaiseSqlError(heap_, &diagsArea, EXE_SUBSTRING_ERROR); - if(diagsArea != atp1->getDiagsArea()) - atp1->setDiagsArea(diagsArea); + atp1->setDiagsAreax(diagsArea); + return ex_expr::EXPR_ERROR; } @@ -4159,8 +4156,9 @@ ex_expr::exp_return_type ex_expr::evalPCode(PCodeBinary* pCode32, // Raise an "assigning a null value to a NOT NULL". diagsArea = atp1->getDiagsArea(); ExRaiseSqlError(getHeap(), &diagsArea, EXE_ASSIGNING_NULL_TO_NOT_NULL); - if(diagsArea != atp1->getDiagsArea()) - atp1->setDiagsArea(diagsArea); + + atp1->setDiagsArea(diagsArea); + return ex_expr::EXPR_ERROR; } @@ -7634,7 +7632,7 @@ ex_expr::exp_return_type ex_expr::evalPCode(PCodeBinary* pCode32, { PTR_DEF_ASSIGN(Int32, indexPtr, 2 * PCODEBINARIES_PER_PTR); Int32 index = * indexPtr; - + // Lookup the indexed row in the history buffer. Compute pointers // to the attribute data, null indicator, and varchar indicator. // @@ -7653,12 +7651,13 @@ ex_expr::exp_return_type ex_expr::evalPCode(PCodeBinary* pCode32, { diagsArea = atp1->getDiagsArea(); ExRaiseSqlError(heap_, &diagsArea, EXE_HISTORY_BUFFER_TOO_SMALL); - if(diagsArea != atp1->getDiagsArea()) - atp1->setDiagsArea(diagsArea); + + atp1->setDiagsArea(diagsArea); + return ex_expr::EXPR_ERROR; } - if(row) + if(row) { srcData = (Int64 *)(row + pCode[5 + 2 * PCODEBINARIES_PER_PTR]); } @@ -7675,7 +7674,7 @@ ex_expr::exp_return_type ex_expr::evalPCode(PCodeBinary* pCode32, case PCIT::OFFSET_IPTR_IPTR_IBIN32S_MBIN64S_MBIN64S: { DEF_ASSIGN(Int32, index, 2 * PCODEBINARIES_PER_PTR); - + // Lookup the indexed row in the history buffer. Compute pointers // to the attribute data, null indicator, and varchar indicator. // @@ -7698,7 +7697,7 @@ ex_expr::exp_return_type ex_expr::evalPCode(PCodeBinary* pCode32, return ex_expr::EXPR_ERROR; } - if(row) + if(row) { srcData = (Int64 *)(row + pCode[4 + 2 * PCODEBINARIES_PER_PTR]); } @@ -8275,16 +8274,16 @@ ex_expr::exp_return_type ex_expr::evalPCode(PCodeBinary* pCode32, { // Raise an "assigning a null value to a NOT NULL". diagsArea = atp1->getDiagsArea(); - ExRaiseSqlError(getHeap(), &diagsArea, + ExRaiseSqlError(getHeap(), &diagsArea, EXE_ASSIGNING_NULL_TO_NOT_NULL); - if(diagsArea != atp1->getDiagsArea()) - atp1->setDiagsArea(diagsArea); + + atp1->setDiagsArea(diagsArea); return ex_expr::EXPR_ERROR; } pCode += 2; // Do NOT break here... - // The first null has been processed above, so fall through to + // The first null has been processed above, so fall through to // process the second null. // These two cases belong together... } @@ -8295,10 +8294,11 @@ ex_expr::exp_return_type ex_expr::evalPCode(PCodeBinary* pCode32, { // Raise an "assigning a null value to a NOT NULL". diagsArea = atp1->getDiagsArea(); - ExRaiseSqlError(getHeap(), &diagsArea, + ExRaiseSqlError(getHeap(), &diagsArea, EXE_ASSIGNING_NULL_TO_NOT_NULL); - if(diagsArea != atp1->getDiagsArea()) - atp1->setDiagsArea(diagsArea); + + atp1->setDiagsArea(diagsArea); + return ex_expr::EXPR_ERROR; } pCode += 2; @@ -8318,9 +8318,9 @@ ex_expr::exp_return_type ex_expr::evalPCode(PCodeBinary* pCode32, : val; NABoolean srcNull = - ExpTupleDesc::isNullValue((char*)(stack[pCode[2]]+pCode3), idx, + ExpTupleDesc::isNullValue((char*)(stack[pCode[2]]+pCode3), idx, (ExpTupleDesc::TupleDataFormat)pCode[5]); - + if ( srcNull && flag2 != 0 ) *ptr = 1; else if ( !srcNull && flag2 == 0 ) *ptr = 1; else *ptr = 0 ; @@ -8339,15 +8339,16 @@ ex_expr::exp_return_type ex_expr::evalPCode(PCodeBinary* pCode32, goto Error2_; }; }; - + Error1_: return reportOverflowError(atp1, pCodeOpcPtr, pCode, stack); - - Error2_: + + Error2_: diagsArea = atp1->getDiagsArea(); ExRaiseSqlError(heap_, &diagsArea, EXE_INTERNAL_ERROR); - if(diagsArea != atp1->getDiagsArea()) - atp1->setDiagsArea(diagsArea); + + atp1->setDiagsAreax(diagsArea); + return ex_expr::EXPR_ERROR; } @@ -8522,8 +8523,9 @@ ex_expr::exp_return_type ex_expr_base::reportOverflowError( ExRaiseDetailSqlError(getHeap(), &diagsArea, EXE_NUMERIC_OVERFLOW, op2, pCode[4], REC_NUM_BIG_SIGNED, 0, REC_BIN64_SIGNED, 0); - if(diagsArea != atp1->getDiagsArea()) - atp1->setDiagsArea(diagsArea); + + atp1->setDiagsArea(diagsArea); + return ex_expr::EXPR_ERROR; break; @@ -8532,15 +8534,17 @@ ex_expr::exp_return_type ex_expr_base::reportOverflowError( ExRaiseDetailSqlError(getHeap(), &diagsArea, EXE_NUMERIC_OVERFLOW, op2, pCode[5], REC_NUM_BIG_SIGNED, 0, REC_NUM_BIG_SIGNED,0); - if(diagsArea != atp1->getDiagsArea()) - atp1->setDiagsArea(diagsArea); + + atp1->setDiagsArea(diagsArea); + return ex_expr::EXPR_ERROR; break; case PCIT::GENFUNC_MATTR5_MATTR5_MBIN32S_IBIN32S: ExRaiseFunctionSqlError(getHeap(), &diagsArea, EXE_STRING_OVERFLOW,FALSE); - if(diagsArea != atp1->getDiagsArea()) - atp1->setDiagsArea(diagsArea); + + atp1->setDiagsArea(diagsArea); + return ex_expr::EXPR_ERROR; break; @@ -8553,8 +8557,9 @@ ex_expr::exp_return_type ex_expr_base::reportOverflowError( &diagsArea, EXE_INTERNAL_ERROR); - if(diagsArea != atp1->getDiagsArea()) - atp1->setDiagsArea(diagsArea); + + atp1->setDiagsArea(diagsArea); + return ex_expr::EXPR_ERROR; } @@ -8565,8 +8570,8 @@ ex_expr::exp_return_type ex_expr_base::reportOverflowError( op1, op2); - if(diagsArea != atp1->getDiagsArea()) - atp1->setDiagsArea(diagsArea); + atp1->setDiagsArea(diagsArea); + return ex_expr::EXPR_ERROR; } diff --git a/core/sql/optimizer/EncodedKeyValue.cpp b/core/sql/optimizer/EncodedKeyValue.cpp index ce63728358..25f81a4cbd 100644 --- a/core/sql/optimizer/EncodedKeyValue.cpp +++ b/core/sql/optimizer/EncodedKeyValue.cpp @@ -402,14 +402,14 @@ short encodeKeyValues(TrafDesc * column_descs, ExpDP2Expr * keyEncodeExpr = new(space) ExpDP2Expr(keExpr, workCriDesc, space); - - keyEncodeExpr->getExpr()->fixup(0,expGen.getPCodeMode(), + + keyEncodeExpr->getExpr()->fixup(0,expGen.getPCodeMode(), (ex_tcb *)space,space, h, FALSE, NULL); atp_struct * workAtp = keyEncodeExpr->getWorkAtp(); workAtp->getTupp(keyAtpIndex).setDataPointer(encodedKeyBuffer); - workAtp->setDiagsArea(diagsArea); - + workAtp->setDiagsAreax(diagsArea); + if (keyEncodeExpr->getExpr()->eval(workAtp, 0, space) == ex_expr::EXPR_ERROR) error = -1; diff --git a/core/sql/optimizer/ValueDesc.cpp b/core/sql/optimizer/ValueDesc.cpp index 0e12ffbadc..ea9fab41f4 100644 --- a/core/sql/optimizer/ValueDesc.cpp +++ b/core/sql/optimizer/ValueDesc.cpp @@ -4682,8 +4682,7 @@ ex_expr::exp_return_type ValueIdList::evalAtCompileTime workAtp->getTupp(keyAtpIndex).setDataPointer(resultBuffer); // set the diagsArea for the caller to get warnings - if (workAtp->getDiagsArea() != diagsArea) - workAtp->setDiagsArea(diagsArea); + workAtp->setDiagsAreax(diagsArea); // evaluate the expr(s) into resultBuffer ex_expr::exp_return_type rc = keyEncodeExpr->getExpr()->eval(workAtp, 0, STMTHEAP); From c038d73ead9a4452d6d0c8b5d8b8b1a1e4fa238c Mon Sep 17 00:00:00 2001 From: "wenjun.zhu" Date: Sun, 30 Sep 2018 16:34:03 +0800 Subject: [PATCH 2/2] add some invocation that has been missed --- core/sql/executor/ExCancel.cpp | 2 +- core/sql/executor/ExFastTransport.cpp | 2 +- core/sql/executor/ExHbaseIUD.cpp | 2 +- core/sql/executor/ExHdfsScan.cpp | 2 +- core/sql/executor/ex_ddl.cpp | 2 +- core/sql/executor/ex_queue.h | 6 ++++++ core/sql/executor/ex_tuple_flow.cpp | 4 ++-- core/sql/exp/ExpAtp.h | 2 +- core/sql/exp/exp_eval.cpp | 26 +++++++++++++------------- 9 files changed, 27 insertions(+), 21 deletions(-) diff --git a/core/sql/executor/ExCancel.cpp b/core/sql/executor/ExCancel.cpp index 2fe689d1f4..c4c1754679 100755 --- a/core/sql/executor/ExCancel.cpp +++ b/core/sql/executor/ExCancel.cpp @@ -522,7 +522,7 @@ void ExCancelTcb::reportError(ComDiagsArea *da, bool addCondition, da->decrRefCount(); } else - up_entry->setDiagsArea(da); + up_entry->setDiagsAreax(da); up_entry->upState.status = ex_queue::Q_SQLERROR; up_entry->upState.downIndex = qparent_.down->getHeadIndex(); diff --git a/core/sql/executor/ExFastTransport.cpp b/core/sql/executor/ExFastTransport.cpp index cb3d9fdeb7..9e4acf92a1 100644 --- a/core/sql/executor/ExFastTransport.cpp +++ b/core/sql/executor/ExFastTransport.cpp @@ -343,7 +343,7 @@ void ExFastExtractTcb::updateWorkATPDiagsArea(ComDiagsArea *da) else { ComDiagsArea * da1 = da; - workAtp_->shareDiagsAreax(da1); + workAtp_->shareDiagsArea(da1); } } } diff --git a/core/sql/executor/ExHbaseIUD.cpp b/core/sql/executor/ExHbaseIUD.cpp index b61ebbc55b..d7f1175613 100644 --- a/core/sql/executor/ExHbaseIUD.cpp +++ b/core/sql/executor/ExHbaseIUD.cpp @@ -604,7 +604,7 @@ ExWorkProcRetcode ExHbaseAccessInsertSQTcb::work() ComDiagsArea * diagsArea = NULL; ExRaiseSqlError(getHeap(), &diagsArea, (ExeErrorCode)(8102)); - pentry_down->setDiagsArea(diagsArea); + pentry_down->setDiagsAreax(diagsArea); step_ = HANDLE_ERROR; break; } diff --git a/core/sql/executor/ExHdfsScan.cpp b/core/sql/executor/ExHdfsScan.cpp index 4ce92574f1..56e54fa639 100644 --- a/core/sql/executor/ExHdfsScan.cpp +++ b/core/sql/executor/ExHdfsScan.cpp @@ -1542,7 +1542,7 @@ ExWorkProcRetcode ExHdfsScanTcb::work() "HDFS", (char*)"ExpLOBInterfaceSelectCursor/close", getLobErrStr(intParam1)); - pentry_down->setDiagsArea(diagsArea); + pentry_down->setDiagsAreax(diagsArea); step_ = HANDLE_ERROR; break; } diff --git a/core/sql/executor/ex_ddl.cpp b/core/sql/executor/ex_ddl.cpp index 7d161ee5d6..ef6761d4fe 100644 --- a/core/sql/executor/ex_ddl.cpp +++ b/core/sql/executor/ex_ddl.cpp @@ -1198,7 +1198,7 @@ short ExDescribeTcb::work() if (diagsArea == NULL) diagsArea = ComDiagsArea::allocate(this->getGlobals()->getDefaultHeap()); - diagsArea->mergeAfter (*da); + diagsArea->mergeAfter(*da); up_entry->shareDiagsArea(da); // insert into parent diff --git a/core/sql/executor/ex_queue.h b/core/sql/executor/ex_queue.h index 94e722b91b..73fea51bd2 100644 --- a/core/sql/executor/ex_queue.h +++ b/core/sql/executor/ex_queue.h @@ -566,6 +566,7 @@ class ex_queue_entry inline ComDiagsArea *getDiagsArea() const; inline void setDiagsAreax(ComDiagsArea* diagsArea); + inline void shareDiagsArea(ComDiagsArea* diagsArea); private: @@ -643,6 +644,11 @@ inline void ex_queue_entry::setDiagsAreax(ComDiagsArea* diagsArea) atp_->setDiagsAreax(diagsArea); } +inline void ex_queue_entry::shareDiagsArea(ComDiagsArea* diagsArea) +{ + atp_->shareDiagsArea(diagsArea); +} + ///////////////////////////////////////////////////////////////////////////// // Inline procedures -- class ex_queue diff --git a/core/sql/executor/ex_tuple_flow.cpp b/core/sql/executor/ex_tuple_flow.cpp index 7d628b9215..8a96ce6edd 100644 --- a/core/sql/executor/ex_tuple_flow.cpp +++ b/core/sql/executor/ex_tuple_flow.cpp @@ -370,7 +370,7 @@ short ExTupleFlowTcb::work() } else { - pentry->shareDiagsAreax(da); + pentry->shareDiagsArea(da); accumulatedDiagsArea = da ; if (tflowTdb().isNonFatalErrorTolerated()) { @@ -503,7 +503,7 @@ short ExTupleFlowTcb::work() } else { - pentry->shareDiagsAreax(da); + pentry->shareDiagsArea(da); if (tflowTdb().isNonFatalErrorTolerated()) { ComDiagsArea *cliDiagsArea = pentry_down->getDiagsArea(); da->setLengthLimit(cliDiagsArea->getLengthLimit()); diff --git a/core/sql/exp/ExpAtp.h b/core/sql/exp/ExpAtp.h index a5b36b53af..3b8443b085 100644 --- a/core/sql/exp/ExpAtp.h +++ b/core/sql/exp/ExpAtp.h @@ -97,7 +97,7 @@ class atp_struct // inline ComDiagsArea *getDiagsArea() const; inline void setDiagsAreax(ComDiagsArea* diagsArea); - inline void shareDiagsAreax(ComDiagsArea* diagsArea); + inline void shareDiagsArea(ComDiagsArea* diagsArea); inline void initDiagsArea(ComDiagsArea* diagsArea); Long pack(void * space); Lng32 unpack(Lng32 base); diff --git a/core/sql/exp/exp_eval.cpp b/core/sql/exp/exp_eval.cpp index 5eccb7c0c4..9e1cb3a798 100644 --- a/core/sql/exp/exp_eval.cpp +++ b/core/sql/exp/exp_eval.cpp @@ -1594,7 +1594,7 @@ ex_expr::exp_return_type reportErr(atp_struct* atp1, ex_expr* expr) diagsArea = atp1->getDiagsArea(); ExRaiseSqlError(expr->getHeap(), &diagsArea, EXE_INTERNAL_ERROR); - atp1->setDiagsArea(diagsArea); + atp1->setDiagsAreax(diagsArea); return ex_expr::EXPR_ERROR; } @@ -3062,7 +3062,7 @@ ex_expr::exp_return_type ex_expr::evalPCode(PCodeBinary* pCode32, CONV_ASCII_FLOAT64, NULL, 0); - atp1->setDiagsArea(diagsArea); + atp1->setDiagsAreax(diagsArea); if (er == ex_expr::EXPR_ERROR) return ex_expr::EXPR_ERROR; @@ -3140,7 +3140,7 @@ ex_expr::exp_return_type ex_expr::evalPCode(PCodeBinary* pCode32, CONV_ASCII_F_V, NULL, 0); - atp1->setDiagsArea(diagsArea); + atp1->setDiagsAreax(diagsArea); if (er == ex_expr::EXPR_ERROR) return ex_expr::EXPR_ERROR; @@ -4157,7 +4157,7 @@ ex_expr::exp_return_type ex_expr::evalPCode(PCodeBinary* pCode32, diagsArea = atp1->getDiagsArea(); ExRaiseSqlError(getHeap(), &diagsArea, EXE_ASSIGNING_NULL_TO_NOT_NULL); - atp1->setDiagsArea(diagsArea); + atp1->setDiagsAreax(diagsArea); return ex_expr::EXPR_ERROR; } @@ -7652,7 +7652,7 @@ ex_expr::exp_return_type ex_expr::evalPCode(PCodeBinary* pCode32, diagsArea = atp1->getDiagsArea(); ExRaiseSqlError(heap_, &diagsArea, EXE_HISTORY_BUFFER_TOO_SMALL); - atp1->setDiagsArea(diagsArea); + atp1->setDiagsAreax(diagsArea); return ex_expr::EXPR_ERROR; } @@ -7693,7 +7693,7 @@ ex_expr::exp_return_type ex_expr::evalPCode(PCodeBinary* pCode32, diagsArea = atp1->getDiagsArea(); ExRaiseSqlError(heap_, &diagsArea, EXE_HISTORY_BUFFER_TOO_SMALL); if(diagsArea != atp1->getDiagsArea()) - atp1->setDiagsArea(diagsArea); + atp1->setDiagsAreax(diagsArea); return ex_expr::EXPR_ERROR; } @@ -8277,7 +8277,7 @@ ex_expr::exp_return_type ex_expr::evalPCode(PCodeBinary* pCode32, ExRaiseSqlError(getHeap(), &diagsArea, EXE_ASSIGNING_NULL_TO_NOT_NULL); - atp1->setDiagsArea(diagsArea); + atp1->setDiagsAreax(diagsArea); return ex_expr::EXPR_ERROR; } @@ -8297,7 +8297,7 @@ ex_expr::exp_return_type ex_expr::evalPCode(PCodeBinary* pCode32, ExRaiseSqlError(getHeap(), &diagsArea, EXE_ASSIGNING_NULL_TO_NOT_NULL); - atp1->setDiagsArea(diagsArea); + atp1->setDiagsAreax(diagsArea); return ex_expr::EXPR_ERROR; } @@ -8524,7 +8524,7 @@ ex_expr::exp_return_type ex_expr_base::reportOverflowError( pCode[4], REC_NUM_BIG_SIGNED, 0, REC_BIN64_SIGNED, 0); - atp1->setDiagsArea(diagsArea); + atp1->setDiagsAreax(diagsArea); return ex_expr::EXPR_ERROR; break; @@ -8535,7 +8535,7 @@ ex_expr::exp_return_type ex_expr_base::reportOverflowError( pCode[5], REC_NUM_BIG_SIGNED, 0, REC_NUM_BIG_SIGNED,0); - atp1->setDiagsArea(diagsArea); + atp1->setDiagsAreax(diagsArea); return ex_expr::EXPR_ERROR; break; @@ -8543,7 +8543,7 @@ ex_expr::exp_return_type ex_expr_base::reportOverflowError( case PCIT::GENFUNC_MATTR5_MATTR5_MBIN32S_IBIN32S: ExRaiseFunctionSqlError(getHeap(), &diagsArea, EXE_STRING_OVERFLOW,FALSE); - atp1->setDiagsArea(diagsArea); + atp1->setDiagsAreax(diagsArea); return ex_expr::EXPR_ERROR; break; @@ -8558,7 +8558,7 @@ ex_expr::exp_return_type ex_expr_base::reportOverflowError( EXE_INTERNAL_ERROR); - atp1->setDiagsArea(diagsArea); + atp1->setDiagsAreax(diagsArea); return ex_expr::EXPR_ERROR; } @@ -8570,7 +8570,7 @@ ex_expr::exp_return_type ex_expr_base::reportOverflowError( op1, op2); - atp1->setDiagsArea(diagsArea); + atp1->setDiagsAreax(diagsArea); return ex_expr::EXPR_ERROR; }