mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-04-18 21:44:02 +03:00
clang format apply
This commit is contained in:
parent
6b6411229f
commit
04752ec546
@ -18,5 +18,5 @@ DerivePointerAlignment: false
|
||||
IndentCaseLabels: true
|
||||
NamespaceIndentation: None
|
||||
PointerAlignment: Left
|
||||
SortIncludes: true
|
||||
SortIncludes: false
|
||||
Standard: Auto
|
||||
|
@ -15,12 +15,10 @@
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace datatypes
|
||||
{
|
||||
|
||||
/*
|
||||
A subset of SQL Conditions related to data processing.
|
||||
SQLSTATE terminology is used for categories:
|
||||
@ -40,12 +38,12 @@ public:
|
||||
X_NUMERIC_VALUE_OUT_OF_RANGE = 1 << 17, // 22003
|
||||
X_INVALID_CHARACTER_VALUE_FOR_CAST = 1 << 18, // 22018
|
||||
};
|
||||
DataCondition()
|
||||
:mError(S_SUCCESS)
|
||||
{ }
|
||||
DataCondition(Code code)
|
||||
:mError(code)
|
||||
{ }
|
||||
DataCondition() : mError(S_SUCCESS)
|
||||
{
|
||||
}
|
||||
DataCondition(Code code) : mError(code)
|
||||
{
|
||||
}
|
||||
DataCondition& operator|=(Code code)
|
||||
{
|
||||
mError = (Code)(mError | code);
|
||||
@ -55,7 +53,10 @@ public:
|
||||
{
|
||||
return DataCondition((Code)(mError & rhs));
|
||||
}
|
||||
operator Code () const { return mError; }
|
||||
operator Code() const
|
||||
{
|
||||
return mError;
|
||||
}
|
||||
|
||||
// Adjust a sigened integer of any size to the range [-absMaxVal , +absMaxVal]
|
||||
template <typename T>
|
||||
@ -78,4 +79,3 @@ private:
|
||||
};
|
||||
|
||||
} // namespace datatypes
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -25,8 +25,6 @@
|
||||
|
||||
namespace datatypes
|
||||
{
|
||||
|
||||
|
||||
// Convert a positive floating point value to
|
||||
// a signed or unsigned integer with rounding
|
||||
// SRC - a floating point data type (float, double, float128_t)
|
||||
@ -40,7 +38,6 @@ DST positiveXFloatToXIntRound(SRC value, DST limit)
|
||||
return static_cast<DST>(tmp);
|
||||
}
|
||||
|
||||
|
||||
// Convert a negative floating point value to
|
||||
// a signed integer with rounding
|
||||
// SRC - a floating point data type (float, double, float128_t)
|
||||
@ -54,40 +51,31 @@ DST negativeXFloatToXIntRound(SRC value, DST limit)
|
||||
return static_cast<DST>(tmp);
|
||||
}
|
||||
|
||||
|
||||
// Convert a floating point value to ColumnStore int64_t
|
||||
// Magic values cannot be returned.
|
||||
template <typename SRC>
|
||||
int64_t xFloatToMCSSInt64Round(SRC value)
|
||||
{
|
||||
if (value > 0)
|
||||
return positiveXFloatToXIntRound<SRC, int64_t>(
|
||||
value,
|
||||
numeric_limits<int64_t>::max());
|
||||
return positiveXFloatToXIntRound<SRC, int64_t>(value, numeric_limits<int64_t>::max());
|
||||
if (value < 0)
|
||||
return negativeXFloatToXIntRound<SRC, int64_t>(
|
||||
value,
|
||||
numeric_limits<int64_t>::min() + 2);
|
||||
return negativeXFloatToXIntRound<SRC, int64_t>(value, numeric_limits<int64_t>::min() + 2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// Convert a floating point value to ColumnStore uint64_t
|
||||
// Magic values cannot be returned.
|
||||
template <typename SRC>
|
||||
uint64_t xFloatToMCSUInt64Round(SRC value)
|
||||
{
|
||||
if (value > 0)
|
||||
return positiveXFloatToXIntRound<SRC, uint64_t>(
|
||||
value,
|
||||
numeric_limits<uint64_t>::max() - 2);
|
||||
return positiveXFloatToXIntRound<SRC, uint64_t>(value, numeric_limits<uint64_t>::max() - 2);
|
||||
if (value < 0)
|
||||
return negativeXFloatToXIntRound<SRC, uint64_t>(value, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
} // end of namespace datatypes
|
||||
|
||||
// vim:ts=2 sw=2:
|
||||
|
@ -24,20 +24,12 @@
|
||||
|
||||
namespace datatypes
|
||||
{
|
||||
template<typename BinaryOperation,
|
||||
typename OpOverflowCheck,
|
||||
typename MultiplicationOverflowCheck>
|
||||
void addSubtractExecute(const Decimal& l,
|
||||
const Decimal& r,
|
||||
Decimal& result,
|
||||
BinaryOperation op,
|
||||
OpOverflowCheck opOverflowCheck,
|
||||
MultiplicationOverflowCheck mulOverflowCheck)
|
||||
template <typename BinaryOperation, typename OpOverflowCheck, typename MultiplicationOverflowCheck>
|
||||
void addSubtractExecute(const Decimal& l, const Decimal& r, Decimal& result, BinaryOperation op,
|
||||
OpOverflowCheck opOverflowCheck, MultiplicationOverflowCheck mulOverflowCheck)
|
||||
{
|
||||
int128_t lValue = Decimal::isWideDecimalTypeByPrecision(l.precision)
|
||||
? l.s128Value : l.value;
|
||||
int128_t rValue = Decimal::isWideDecimalTypeByPrecision(r.precision)
|
||||
? r.s128Value : r.value;
|
||||
int128_t lValue = Decimal::isWideDecimalTypeByPrecision(l.precision) ? l.s128Value : l.value;
|
||||
int128_t rValue = Decimal::isWideDecimalTypeByPrecision(r.precision) ? r.s128Value : r.value;
|
||||
|
||||
if (result.scale == l.scale && result.scale == r.scale)
|
||||
{
|
||||
@ -57,9 +49,8 @@ namespace datatypes
|
||||
{
|
||||
int128_t scaleMultiplier;
|
||||
getScaleDivisor(scaleMultiplier, l.scale - result.scale);
|
||||
lValue = (int128_t) (lValue > 0 ?
|
||||
(float128_t)lValue / scaleMultiplier + 0.5 :
|
||||
(float128_t)lValue / scaleMultiplier - 0.5);
|
||||
lValue = (int128_t)(lValue > 0 ? (float128_t)lValue / scaleMultiplier + 0.5
|
||||
: (float128_t)lValue / scaleMultiplier - 0.5);
|
||||
}
|
||||
|
||||
if (result.scale > r.scale)
|
||||
@ -73,9 +64,8 @@ namespace datatypes
|
||||
{
|
||||
int128_t scaleMultiplier;
|
||||
getScaleDivisor(scaleMultiplier, r.scale - result.scale);
|
||||
rValue = (int128_t) (rValue > 0 ?
|
||||
(float128_t)rValue / scaleMultiplier + 0.5 :
|
||||
(float128_t)rValue / scaleMultiplier - 0.5);
|
||||
rValue = (int128_t)(rValue > 0 ? (float128_t)rValue / scaleMultiplier + 0.5
|
||||
: (float128_t)rValue / scaleMultiplier - 0.5);
|
||||
}
|
||||
|
||||
// We assume there is no way that lValue or rValue calculations
|
||||
@ -85,18 +75,12 @@ namespace datatypes
|
||||
result.s128Value = op(lValue, rValue);
|
||||
}
|
||||
|
||||
template<typename OpOverflowCheck,
|
||||
typename MultiplicationOverflowCheck>
|
||||
void divisionExecute(const Decimal& l,
|
||||
const Decimal& r,
|
||||
Decimal& result,
|
||||
OpOverflowCheck opOverflowCheck,
|
||||
template <typename OpOverflowCheck, typename MultiplicationOverflowCheck>
|
||||
void divisionExecute(const Decimal& l, const Decimal& r, Decimal& result, OpOverflowCheck opOverflowCheck,
|
||||
MultiplicationOverflowCheck mulOverflowCheck)
|
||||
{
|
||||
int128_t lValue = Decimal::isWideDecimalTypeByPrecision(l.precision)
|
||||
? l.s128Value : l.value;
|
||||
int128_t rValue = Decimal::isWideDecimalTypeByPrecision(r.precision)
|
||||
? r.s128Value : r.value;
|
||||
int128_t lValue = Decimal::isWideDecimalTypeByPrecision(l.precision) ? l.s128Value : l.value;
|
||||
int128_t rValue = Decimal::isWideDecimalTypeByPrecision(r.precision) ? r.s128Value : r.value;
|
||||
|
||||
opOverflowCheck(lValue, rValue);
|
||||
if (result.scale >= l.scale - r.scale)
|
||||
@ -107,9 +91,9 @@ namespace datatypes
|
||||
|
||||
// TODO How do we check overflow of (int128_t)((float128_t)lValue / rValue * scaleMultiplier) ?
|
||||
|
||||
result.s128Value = (int128_t)(( (lValue > 0 && rValue > 0) || (lValue < 0 && rValue < 0) ?
|
||||
(float128_t)lValue / rValue * scaleMultiplier + 0.5 :
|
||||
(float128_t)lValue / rValue * scaleMultiplier - 0.5));
|
||||
result.s128Value = (int128_t)(((lValue > 0 && rValue > 0) || (lValue < 0 && rValue < 0)
|
||||
? (float128_t)lValue / rValue * scaleMultiplier + 0.5
|
||||
: (float128_t)lValue / rValue * scaleMultiplier - 0.5));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -117,24 +101,18 @@ namespace datatypes
|
||||
|
||||
getScaleDivisor(scaleMultiplier, (l.scale - r.scale) - result.scale);
|
||||
|
||||
result.s128Value = (int128_t)(( (lValue > 0 && rValue > 0) || (lValue < 0 && rValue < 0) ?
|
||||
(float128_t)lValue / rValue / scaleMultiplier + 0.5 :
|
||||
(float128_t)lValue / rValue / scaleMultiplier - 0.5));
|
||||
result.s128Value = (int128_t)(((lValue > 0 && rValue > 0) || (lValue < 0 && rValue < 0)
|
||||
? (float128_t)lValue / rValue / scaleMultiplier + 0.5
|
||||
: (float128_t)lValue / rValue / scaleMultiplier - 0.5));
|
||||
}
|
||||
}
|
||||
|
||||
template<typename OpOverflowCheck,
|
||||
typename MultiplicationOverflowCheck>
|
||||
void multiplicationExecute(const Decimal& l,
|
||||
const Decimal& r,
|
||||
Decimal& result,
|
||||
OpOverflowCheck opOverflowCheck,
|
||||
MultiplicationOverflowCheck mulOverflowCheck)
|
||||
template <typename OpOverflowCheck, typename MultiplicationOverflowCheck>
|
||||
void multiplicationExecute(const Decimal& l, const Decimal& r, Decimal& result,
|
||||
OpOverflowCheck opOverflowCheck, MultiplicationOverflowCheck mulOverflowCheck)
|
||||
{
|
||||
int128_t lValue = Decimal::isWideDecimalTypeByPrecision(l.precision)
|
||||
? l.s128Value : l.value;
|
||||
int128_t rValue = Decimal::isWideDecimalTypeByPrecision(r.precision)
|
||||
? r.s128Value : r.value;
|
||||
int128_t lValue = Decimal::isWideDecimalTypeByPrecision(l.precision) ? l.s128Value : l.value;
|
||||
int128_t rValue = Decimal::isWideDecimalTypeByPrecision(r.precision) ? r.s128Value : r.value;
|
||||
|
||||
if (lValue == 0 || rValue == 0)
|
||||
{
|
||||
@ -160,22 +138,19 @@ namespace datatypes
|
||||
getScaleDivisor(scaleMultiplierL, diff / 2);
|
||||
getScaleDivisor(scaleMultiplierR, diff - (diff / 2));
|
||||
|
||||
lValue = (int128_t)(( (lValue > 0) ?
|
||||
(float128_t)lValue / scaleMultiplierL + 0.5 :
|
||||
(float128_t)lValue / scaleMultiplierL - 0.5));
|
||||
lValue = (int128_t)(((lValue > 0) ? (float128_t)lValue / scaleMultiplierL + 0.5
|
||||
: (float128_t)lValue / scaleMultiplierL - 0.5));
|
||||
|
||||
rValue = (int128_t)(( (rValue > 0) ?
|
||||
(float128_t)rValue / scaleMultiplierR + 0.5 :
|
||||
(float128_t)rValue / scaleMultiplierR - 0.5));
|
||||
rValue = (int128_t)(((rValue > 0) ? (float128_t)rValue / scaleMultiplierR + 0.5
|
||||
: (float128_t)rValue / scaleMultiplierR - 0.5));
|
||||
|
||||
opOverflowCheck(lValue, rValue, result.s128Value);;
|
||||
opOverflowCheck(lValue, rValue, result.s128Value);
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
Decimal::Decimal(const char *str, size_t length, DataCondition & convError,
|
||||
int8_t s, uint8_t p)
|
||||
:scale(s),
|
||||
precision(p)
|
||||
Decimal::Decimal(const char* str, size_t length, DataCondition& convError, int8_t s, uint8_t p)
|
||||
: scale(s), precision(p)
|
||||
{
|
||||
literal::Converter<literal::SignedNumericLiteral> conv(str, length, convError);
|
||||
// We don't check "convErr" here. Let the caller do it.
|
||||
@ -244,8 +219,7 @@ namespace datatypes
|
||||
|
||||
// no overflow check
|
||||
template <>
|
||||
void Decimal::addition<int128_t, false>(const Decimal& l,
|
||||
const Decimal& r, Decimal& result)
|
||||
void Decimal::addition<int128_t, false>(const Decimal& l, const Decimal& r, Decimal& result)
|
||||
{
|
||||
std::plus<int128_t> add;
|
||||
NoOverflowCheck noOverflowCheck;
|
||||
@ -254,8 +228,7 @@ namespace datatypes
|
||||
|
||||
// with overflow check
|
||||
template <>
|
||||
void Decimal::addition<int128_t, true>(const Decimal& l,
|
||||
const Decimal& r, Decimal& result)
|
||||
void Decimal::addition<int128_t, true>(const Decimal& l, const Decimal& r, Decimal& result)
|
||||
{
|
||||
std::plus<int128_t> add;
|
||||
AdditionOverflowCheck overflowCheck;
|
||||
@ -265,8 +238,7 @@ namespace datatypes
|
||||
|
||||
// no overflow check
|
||||
template <>
|
||||
void Decimal::addition<int64_t, false>(const Decimal& l,
|
||||
const Decimal& r, Decimal& result)
|
||||
void Decimal::addition<int64_t, false>(const Decimal& l, const Decimal& r, Decimal& result)
|
||||
{
|
||||
if (result.scale == l.scale && result.scale == r.scale)
|
||||
{
|
||||
@ -279,24 +251,21 @@ namespace datatypes
|
||||
if (result.scale > l.scale)
|
||||
lValue *= mcs_pow_10[result.scale - l.scale];
|
||||
else if (result.scale < l.scale)
|
||||
lValue = (int64_t)(lValue > 0 ?
|
||||
(double)lValue / mcs_pow_10[l.scale - result.scale] + 0.5 :
|
||||
(double)lValue / mcs_pow_10[l.scale - result.scale] - 0.5);
|
||||
lValue = (int64_t)(lValue > 0 ? (double)lValue / mcs_pow_10[l.scale - result.scale] + 0.5
|
||||
: (double)lValue / mcs_pow_10[l.scale - result.scale] - 0.5);
|
||||
|
||||
if (result.scale > r.scale)
|
||||
rValue *= mcs_pow_10[result.scale - r.scale];
|
||||
else if (result.scale < r.scale)
|
||||
rValue = (int64_t)(rValue > 0 ?
|
||||
(double)rValue / mcs_pow_10[r.scale - result.scale] + 0.5 :
|
||||
(double)rValue / mcs_pow_10[r.scale - result.scale] - 0.5);
|
||||
rValue = (int64_t)(rValue > 0 ? (double)rValue / mcs_pow_10[r.scale - result.scale] + 0.5
|
||||
: (double)rValue / mcs_pow_10[r.scale - result.scale] - 0.5);
|
||||
|
||||
result.value = lValue + rValue;
|
||||
}
|
||||
|
||||
// with overflow check
|
||||
template <>
|
||||
void Decimal::addition<int64_t, true>(const Decimal& l,
|
||||
const Decimal& r, Decimal& result)
|
||||
void Decimal::addition<int64_t, true>(const Decimal& l, const Decimal& r, Decimal& result)
|
||||
{
|
||||
AdditionOverflowCheck additionOverflowCheck;
|
||||
MultiplicationOverflowCheck mulOverflowCheck;
|
||||
@ -313,16 +282,14 @@ namespace datatypes
|
||||
if (result.scale > l.scale)
|
||||
mulOverflowCheck(lValue, mcs_pow_10[result.scale - l.scale], lValue);
|
||||
else if (result.scale < l.scale)
|
||||
lValue = (int64_t)(lValue > 0 ?
|
||||
(double)lValue / mcs_pow_10[l.scale - result.scale] + 0.5 :
|
||||
(double)lValue / mcs_pow_10[l.scale - result.scale] - 0.5);
|
||||
lValue = (int64_t)(lValue > 0 ? (double)lValue / mcs_pow_10[l.scale - result.scale] + 0.5
|
||||
: (double)lValue / mcs_pow_10[l.scale - result.scale] - 0.5);
|
||||
|
||||
if (result.scale > r.scale)
|
||||
mulOverflowCheck(rValue, mcs_pow_10[result.scale - r.scale], rValue);
|
||||
else if (result.scale < r.scale)
|
||||
rValue = (int64_t)(rValue > 0 ?
|
||||
(double)rValue / mcs_pow_10[r.scale - result.scale] + 0.5 :
|
||||
(double)rValue / mcs_pow_10[r.scale - result.scale] - 0.5);
|
||||
rValue = (int64_t)(rValue > 0 ? (double)rValue / mcs_pow_10[r.scale - result.scale] + 0.5
|
||||
: (double)rValue / mcs_pow_10[r.scale - result.scale] - 0.5);
|
||||
|
||||
additionOverflowCheck(lValue, rValue);
|
||||
result.value = lValue + rValue;
|
||||
@ -330,8 +297,7 @@ namespace datatypes
|
||||
|
||||
// no overflow check
|
||||
template <>
|
||||
void Decimal::subtraction<int128_t, false>(const Decimal& l,
|
||||
const Decimal& r, Decimal& result)
|
||||
void Decimal::subtraction<int128_t, false>(const Decimal& l, const Decimal& r, Decimal& result)
|
||||
{
|
||||
std::minus<int128_t> subtract;
|
||||
NoOverflowCheck noOverflowCheck;
|
||||
@ -340,8 +306,7 @@ namespace datatypes
|
||||
|
||||
// with overflow check
|
||||
template <>
|
||||
void Decimal::subtraction<int128_t, true>(const Decimal& l,
|
||||
const Decimal& r, Decimal& result)
|
||||
void Decimal::subtraction<int128_t, true>(const Decimal& l, const Decimal& r, Decimal& result)
|
||||
{
|
||||
std::minus<int128_t> subtract;
|
||||
SubtractionOverflowCheck overflowCheck;
|
||||
@ -351,8 +316,7 @@ namespace datatypes
|
||||
|
||||
// no overflow check
|
||||
template <>
|
||||
void Decimal::subtraction<int64_t, false>(const Decimal& l,
|
||||
const Decimal& r, Decimal& result)
|
||||
void Decimal::subtraction<int64_t, false>(const Decimal& l, const Decimal& r, Decimal& result)
|
||||
{
|
||||
if (result.scale == l.scale && result.scale == r.scale)
|
||||
{
|
||||
@ -365,24 +329,21 @@ namespace datatypes
|
||||
if (result.scale > l.scale)
|
||||
lValue *= mcs_pow_10[result.scale - l.scale];
|
||||
else if (result.scale < l.scale)
|
||||
lValue = (int64_t)(lValue > 0 ?
|
||||
(double)lValue / mcs_pow_10[l.scale - result.scale] + 0.5 :
|
||||
(double)lValue / mcs_pow_10[l.scale - result.scale] - 0.5);
|
||||
lValue = (int64_t)(lValue > 0 ? (double)lValue / mcs_pow_10[l.scale - result.scale] + 0.5
|
||||
: (double)lValue / mcs_pow_10[l.scale - result.scale] - 0.5);
|
||||
|
||||
if (result.scale > r.scale)
|
||||
rValue *= mcs_pow_10[result.scale - r.scale];
|
||||
else if (result.scale < r.scale)
|
||||
rValue = (int64_t)(rValue > 0 ?
|
||||
(double)rValue / mcs_pow_10[r.scale - result.scale] + 0.5 :
|
||||
(double)rValue / mcs_pow_10[r.scale - result.scale] - 0.5);
|
||||
rValue = (int64_t)(rValue > 0 ? (double)rValue / mcs_pow_10[r.scale - result.scale] + 0.5
|
||||
: (double)rValue / mcs_pow_10[r.scale - result.scale] - 0.5);
|
||||
|
||||
result.value = lValue - rValue;
|
||||
}
|
||||
|
||||
// with overflow check
|
||||
template <>
|
||||
void Decimal::subtraction<int64_t, true>(const Decimal& l,
|
||||
const Decimal& r, Decimal& result)
|
||||
void Decimal::subtraction<int64_t, true>(const Decimal& l, const Decimal& r, Decimal& result)
|
||||
{
|
||||
SubtractionOverflowCheck subtractionOverflowCheck;
|
||||
MultiplicationOverflowCheck mulOverflowCheck;
|
||||
@ -399,16 +360,14 @@ namespace datatypes
|
||||
if (result.scale > l.scale)
|
||||
mulOverflowCheck(lValue, mcs_pow_10[result.scale - l.scale], lValue);
|
||||
else if (result.scale < l.scale)
|
||||
lValue = (int64_t)(lValue > 0 ?
|
||||
(double)lValue / mcs_pow_10[l.scale - result.scale] + 0.5 :
|
||||
(double)lValue / mcs_pow_10[l.scale - result.scale] - 0.5);
|
||||
lValue = (int64_t)(lValue > 0 ? (double)lValue / mcs_pow_10[l.scale - result.scale] + 0.5
|
||||
: (double)lValue / mcs_pow_10[l.scale - result.scale] - 0.5);
|
||||
|
||||
if (result.scale > r.scale)
|
||||
mulOverflowCheck(rValue, mcs_pow_10[result.scale - r.scale], rValue);
|
||||
else if (result.scale < r.scale)
|
||||
rValue = (int64_t)(rValue > 0 ?
|
||||
(double)rValue / mcs_pow_10[r.scale - result.scale] + 0.5 :
|
||||
(double)rValue / mcs_pow_10[r.scale - result.scale] - 0.5);
|
||||
rValue = (int64_t)(rValue > 0 ? (double)rValue / mcs_pow_10[r.scale - result.scale] + 0.5
|
||||
: (double)rValue / mcs_pow_10[r.scale - result.scale] - 0.5);
|
||||
|
||||
subtractionOverflowCheck(lValue, rValue);
|
||||
result.value = lValue - rValue;
|
||||
@ -416,8 +375,7 @@ namespace datatypes
|
||||
|
||||
// no overflow check
|
||||
template <>
|
||||
void Decimal::division<int128_t, false>(const Decimal& l,
|
||||
const Decimal& r, Decimal& result)
|
||||
void Decimal::division<int128_t, false>(const Decimal& l, const Decimal& r, Decimal& result)
|
||||
{
|
||||
NoOverflowCheck noOverflowCheck;
|
||||
divisionExecute(l, r, result, noOverflowCheck, noOverflowCheck);
|
||||
@ -425,8 +383,7 @@ namespace datatypes
|
||||
|
||||
// With overflow check
|
||||
template <>
|
||||
void Decimal::division<int128_t, true>(const Decimal& l,
|
||||
const Decimal& r, Decimal& result)
|
||||
void Decimal::division<int128_t, true>(const Decimal& l, const Decimal& r, Decimal& result)
|
||||
{
|
||||
DivisionOverflowCheck overflowCheck;
|
||||
MultiplicationOverflowCheck mulOverflowCheck;
|
||||
@ -436,43 +393,45 @@ namespace datatypes
|
||||
// no overflow check
|
||||
// We rely on the zero check from ArithmeticOperator::execute
|
||||
template <>
|
||||
void Decimal::division<int64_t, false>(const Decimal& l,
|
||||
const Decimal& r, Decimal& result)
|
||||
void Decimal::division<int64_t, false>(const Decimal& l, const Decimal& r, Decimal& result)
|
||||
{
|
||||
if (result.scale >= l.scale - r.scale)
|
||||
result.value = (int64_t)(( (l.value > 0 && r.value > 0) || (l.value < 0 && r.value < 0) ?
|
||||
(long double)l.value / r.value * mcs_pow_10[result.scale - (l.scale - r.scale)] + 0.5 :
|
||||
(long double)l.value / r.value * mcs_pow_10[result.scale - (l.scale - r.scale)] - 0.5));
|
||||
result.value = (int64_t)((
|
||||
(l.value > 0 && r.value > 0) || (l.value < 0 && r.value < 0)
|
||||
? (long double)l.value / r.value * mcs_pow_10[result.scale - (l.scale - r.scale)] + 0.5
|
||||
: (long double)l.value / r.value * mcs_pow_10[result.scale - (l.scale - r.scale)] - 0.5));
|
||||
else
|
||||
result.value = (int64_t)(( (l.value > 0 && r.value > 0) || (l.value < 0 && r.value < 0) ?
|
||||
(long double)l.value / r.value / mcs_pow_10[l.scale - r.scale - result.scale] + 0.5 :
|
||||
(long double)l.value / r.value / mcs_pow_10[l.scale - r.scale - result.scale] - 0.5));
|
||||
result.value = (int64_t)((
|
||||
(l.value > 0 && r.value > 0) || (l.value < 0 && r.value < 0)
|
||||
? (long double)l.value / r.value / mcs_pow_10[l.scale - r.scale - result.scale] + 0.5
|
||||
: (long double)l.value / r.value / mcs_pow_10[l.scale - r.scale - result.scale] - 0.5));
|
||||
}
|
||||
|
||||
// With overflow check
|
||||
template <>
|
||||
void Decimal::division<int64_t, true>(const Decimal& l,
|
||||
const Decimal& r, Decimal& result)
|
||||
void Decimal::division<int64_t, true>(const Decimal& l, const Decimal& r, Decimal& result)
|
||||
{
|
||||
DivisionOverflowCheck divisionOverflowCheck;
|
||||
|
||||
divisionOverflowCheck(l.value, r.value);
|
||||
|
||||
if (result.scale >= l.scale - r.scale)
|
||||
// TODO How do we check overflow of (int64_t)((long double)l.value / r.value * mcs_pow_10[result.scale - (l.scale - r.scale)]) ?
|
||||
result.value = (int64_t)(( (l.value > 0 && r.value > 0) || (l.value < 0 && r.value < 0) ?
|
||||
(long double)l.value / r.value * mcs_pow_10[result.scale - (l.scale - r.scale)] + 0.5 :
|
||||
(long double)l.value / r.value * mcs_pow_10[result.scale - (l.scale - r.scale)] - 0.5));
|
||||
// TODO How do we check overflow of (int64_t)((long double)l.value / r.value * mcs_pow_10[result.scale -
|
||||
// (l.scale - r.scale)]) ?
|
||||
result.value = (int64_t)((
|
||||
(l.value > 0 && r.value > 0) || (l.value < 0 && r.value < 0)
|
||||
? (long double)l.value / r.value * mcs_pow_10[result.scale - (l.scale - r.scale)] + 0.5
|
||||
: (long double)l.value / r.value * mcs_pow_10[result.scale - (l.scale - r.scale)] - 0.5));
|
||||
else
|
||||
result.value = (int64_t)(( (l.value > 0 && r.value > 0) || (l.value < 0 && r.value < 0) ?
|
||||
(long double)l.value / r.value / mcs_pow_10[l.scale - r.scale - result.scale] + 0.5 :
|
||||
(long double)l.value / r.value / mcs_pow_10[l.scale - r.scale - result.scale] - 0.5));
|
||||
result.value = (int64_t)((
|
||||
(l.value > 0 && r.value > 0) || (l.value < 0 && r.value < 0)
|
||||
? (long double)l.value / r.value / mcs_pow_10[l.scale - r.scale - result.scale] + 0.5
|
||||
: (long double)l.value / r.value / mcs_pow_10[l.scale - r.scale - result.scale] - 0.5));
|
||||
}
|
||||
|
||||
// no overflow check
|
||||
template <>
|
||||
void Decimal::multiplication<int128_t, false>(const Decimal& l,
|
||||
const Decimal& r, Decimal& result)
|
||||
void Decimal::multiplication<int128_t, false>(const Decimal& l, const Decimal& r, Decimal& result)
|
||||
{
|
||||
MultiplicationNoOverflowCheck noOverflowCheck;
|
||||
multiplicationExecute(l, r, result, noOverflowCheck, noOverflowCheck);
|
||||
@ -480,8 +439,7 @@ namespace datatypes
|
||||
|
||||
// With overflow check
|
||||
template <>
|
||||
void Decimal::multiplication<int128_t, true>(const Decimal& l,
|
||||
const Decimal& r, Decimal& result)
|
||||
void Decimal::multiplication<int128_t, true>(const Decimal& l, const Decimal& r, Decimal& result)
|
||||
{
|
||||
MultiplicationOverflowCheck mulOverflowCheck;
|
||||
multiplicationExecute(l, r, result, mulOverflowCheck, mulOverflowCheck);
|
||||
@ -489,21 +447,20 @@ namespace datatypes
|
||||
|
||||
// no overflow check
|
||||
template <>
|
||||
void Decimal::multiplication<int64_t, false>(const Decimal& l,
|
||||
const Decimal& r, Decimal& result)
|
||||
void Decimal::multiplication<int64_t, false>(const Decimal& l, const Decimal& r, Decimal& result)
|
||||
{
|
||||
if (result.scale >= l.scale + r.scale)
|
||||
result.value = l.value * r.value * mcs_pow_10[result.scale - (l.scale + r.scale)];
|
||||
else
|
||||
result.value = (int64_t)(( (l.value > 0 && r.value > 0) || (l.value < 0 && r.value < 0) ?
|
||||
(double)l.value * r.value / mcs_pow_10[l.scale + r.scale - result.scale] + 0.5 :
|
||||
(double)l.value * r.value / mcs_pow_10[l.scale + r.scale - result.scale] - 0.5));
|
||||
result.value =
|
||||
(int64_t)(((l.value > 0 && r.value > 0) || (l.value < 0 && r.value < 0)
|
||||
? (double)l.value * r.value / mcs_pow_10[l.scale + r.scale - result.scale] + 0.5
|
||||
: (double)l.value * r.value / mcs_pow_10[l.scale + r.scale - result.scale] - 0.5));
|
||||
}
|
||||
|
||||
// With overflow check
|
||||
template <>
|
||||
void Decimal::multiplication<int64_t, true>(const Decimal& l,
|
||||
const Decimal& r, Decimal& result)
|
||||
void Decimal::multiplication<int64_t, true>(const Decimal& l, const Decimal& r, Decimal& result)
|
||||
{
|
||||
MultiplicationOverflowCheck mulOverflowCheck;
|
||||
|
||||
@ -516,16 +473,14 @@ namespace datatypes
|
||||
{
|
||||
mulOverflowCheck(l.value, r.value, result.value);
|
||||
|
||||
result.value = (int64_t)(( (result.value > 0) ?
|
||||
(double)result.value / mcs_pow_10[l.scale + r.scale - result.scale] + 0.5 :
|
||||
(double)result.value / mcs_pow_10[l.scale + r.scale - result.scale] - 0.5));
|
||||
result.value = (int64_t)((
|
||||
(result.value > 0) ? (double)result.value / mcs_pow_10[l.scale + r.scale - result.scale] + 0.5
|
||||
: (double)result.value / mcs_pow_10[l.scale + r.scale - result.scale] - 0.5));
|
||||
}
|
||||
}
|
||||
|
||||
// Writes integer part of a Decimal using int128 argument provided
|
||||
uint8_t Decimal::writeIntPart(const int128_t& x,
|
||||
char* buf,
|
||||
const uint8_t buflen) const
|
||||
uint8_t Decimal::writeIntPart(const int128_t& x, char* buf, const uint8_t buflen) const
|
||||
{
|
||||
char* p = buf;
|
||||
int128_t intPart = x;
|
||||
@ -553,25 +508,20 @@ namespace datatypes
|
||||
mid = intPart % maxUint64divisor;
|
||||
high = intPart / maxUint64divisor;
|
||||
break;
|
||||
default:
|
||||
throw logging::QueryDataExcept("Decimal::writeIntPart() bad scale",
|
||||
logging::formatErr);
|
||||
default: throw logging::QueryDataExcept("Decimal::writeIntPart() bad scale", logging::formatErr);
|
||||
}
|
||||
|
||||
p += printPodParts(p, high, mid, low);
|
||||
uint8_t written = p - buf;
|
||||
if (buflen <= written)
|
||||
{
|
||||
throw logging::QueryDataExcept("Decimal::writeIntPart() char buffer overflow.",
|
||||
logging::formatErr);
|
||||
throw logging::QueryDataExcept("Decimal::writeIntPart() char buffer overflow.", logging::formatErr);
|
||||
}
|
||||
|
||||
return written;
|
||||
}
|
||||
|
||||
uint8_t Decimal::writeFractionalPart(const int128_t& x,
|
||||
char* buf,
|
||||
const uint8_t buflen) const
|
||||
uint8_t Decimal::writeFractionalPart(const int128_t& x, char* buf, const uint8_t buflen) const
|
||||
{
|
||||
int128_t scaleDivisor = 1;
|
||||
char* p = buf;
|
||||
@ -585,8 +535,7 @@ namespace datatypes
|
||||
case 1:
|
||||
scaleDivisor *= datatypes::mcs_pow_10[datatypes::maxPowOf10];
|
||||
// fallthrough
|
||||
case 0:
|
||||
scaleDivisor *= datatypes::mcs_pow_10[scale % datatypes::maxPowOf10];
|
||||
case 0: scaleDivisor *= datatypes::mcs_pow_10[scale % datatypes::maxPowOf10];
|
||||
}
|
||||
|
||||
int128_t fractionalPart = x % scaleDivisor;
|
||||
@ -599,7 +548,8 @@ namespace datatypes
|
||||
*p++ = '0';
|
||||
scaleDivisor /= 10;
|
||||
}
|
||||
size_t written = p - buf;;
|
||||
size_t written = p - buf;
|
||||
;
|
||||
p += TSInt128::writeIntPart(fractionalPart, p, buflen - written);
|
||||
return p - buf;
|
||||
}
|
||||
@ -633,8 +583,7 @@ namespace datatypes
|
||||
|
||||
if (sizeof(buf) <= written)
|
||||
{
|
||||
throw logging::QueryDataExcept("Decimal::toString() char buffer overflow.",
|
||||
logging::formatErr);
|
||||
throw logging::QueryDataExcept("Decimal::toString() char buffer overflow.", logging::formatErr);
|
||||
}
|
||||
|
||||
*p = '\0';
|
||||
@ -649,11 +598,9 @@ namespace datatypes
|
||||
uint64_t uvalue = value < 0 ? (uint64_t)-value : (uint64_t)value;
|
||||
uint64_t intg = uvalue / divisor;
|
||||
uint64_t frac = uvalue % divisor;
|
||||
int nbytes = snprintf(buf, sizeof(buf), "%s%" PRIu64,
|
||||
value < 0 ? "-" : "", intg);
|
||||
int nbytes = snprintf(buf, sizeof(buf), "%s%" PRIu64, value < 0 ? "-" : "", intg);
|
||||
if (scale > 0)
|
||||
snprintf(buf + nbytes, sizeof(buf) - nbytes, ".%.*" PRIu64,
|
||||
(int) scale, frac);
|
||||
snprintf(buf + nbytes, sizeof(buf) - nbytes, ".%.*" PRIu64, (int)scale, frac);
|
||||
return std::string(buf);
|
||||
}
|
||||
|
||||
@ -687,4 +634,4 @@ namespace datatypes
|
||||
os << dec.toString();
|
||||
return os;
|
||||
}
|
||||
} // end of namespace
|
||||
} // namespace datatypes
|
||||
|
@ -31,7 +31,6 @@
|
||||
#include "branchpred.h"
|
||||
#include "mcs_data_condition.h"
|
||||
|
||||
|
||||
namespace datatypes
|
||||
{
|
||||
class Decimal;
|
||||
@ -43,13 +42,19 @@ namespace datatypes
|
||||
namespace detail_xxl
|
||||
{
|
||||
constexpr uint8_t hexval(char c)
|
||||
{ return c>='a' ? (10+c-'a') : c>='A' ? (10+c-'A') : c-'0'; }
|
||||
{
|
||||
return c >= 'a' ? (10 + c - 'a') : c >= 'A' ? (10 + c - 'A') : c - '0';
|
||||
}
|
||||
|
||||
template <int BASE, uint128_t V>
|
||||
constexpr uint128_t lit_eval() { return V; }
|
||||
constexpr uint128_t lit_eval()
|
||||
{
|
||||
return V;
|
||||
}
|
||||
|
||||
template <int BASE, uint128_t V, char C, char... Cs>
|
||||
constexpr uint128_t lit_eval() {
|
||||
constexpr uint128_t lit_eval()
|
||||
{
|
||||
static_assert(BASE != 16 || sizeof...(Cs) <= 32 - 1, "Literal too large for BASE=16");
|
||||
static_assert(BASE != 10 || sizeof...(Cs) <= 39 - 1, "Literal too large for BASE=10");
|
||||
static_assert(BASE != 8 || sizeof...(Cs) <= 44 - 1, "Literal too large for BASE=8");
|
||||
@ -57,37 +62,64 @@ namespace detail_xxl
|
||||
return lit_eval<BASE, BASE * V + hexval(C), Cs...>();
|
||||
}
|
||||
|
||||
template<char... Cs > struct LitEval
|
||||
{static constexpr uint128_t eval() {return lit_eval<10,0,Cs...>();} };
|
||||
|
||||
template<char... Cs> struct LitEval<'0','x',Cs...>
|
||||
{static constexpr uint128_t eval() {return lit_eval<16,0,Cs...>();} };
|
||||
|
||||
template<char... Cs> struct LitEval<'0','b',Cs...>
|
||||
{static constexpr uint128_t eval() {return lit_eval<2,0,Cs...>();} };
|
||||
|
||||
template<char... Cs> struct LitEval<'0',Cs...>
|
||||
{static constexpr uint128_t eval() {return lit_eval<8,0,Cs...>();} };
|
||||
|
||||
template <char... Cs>
|
||||
constexpr uint128_t operator "" _xxl() {return LitEval<Cs...>::eval();}
|
||||
struct LitEval
|
||||
{
|
||||
static constexpr uint128_t eval()
|
||||
{
|
||||
return lit_eval<10, 0, Cs...>();
|
||||
}
|
||||
};
|
||||
|
||||
template <char... Cs>
|
||||
constexpr uint128_t operator "" _xxl() {return ::detail_xxl::operator "" _xxl<Cs...>();}
|
||||
struct LitEval<'0', 'x', Cs...>
|
||||
{
|
||||
static constexpr uint128_t eval()
|
||||
{
|
||||
return lit_eval<16, 0, Cs...>();
|
||||
}
|
||||
};
|
||||
|
||||
template <char... Cs>
|
||||
struct LitEval<'0', 'b', Cs...>
|
||||
{
|
||||
static constexpr uint128_t eval()
|
||||
{
|
||||
return lit_eval<2, 0, Cs...>();
|
||||
}
|
||||
};
|
||||
|
||||
template <char... Cs>
|
||||
struct LitEval<'0', Cs...>
|
||||
{
|
||||
static constexpr uint128_t eval()
|
||||
{
|
||||
return lit_eval<8, 0, Cs...>();
|
||||
}
|
||||
};
|
||||
|
||||
template <char... Cs>
|
||||
constexpr uint128_t operator"" _xxl()
|
||||
{
|
||||
return LitEval<Cs...>::eval();
|
||||
}
|
||||
} // namespace detail_xxl
|
||||
|
||||
template <char... Cs>
|
||||
constexpr uint128_t operator"" _xxl()
|
||||
{
|
||||
return ::detail_xxl::operator"" _xxl<Cs...>();
|
||||
}
|
||||
|
||||
namespace datatypes
|
||||
{
|
||||
|
||||
constexpr uint32_t MAXDECIMALWIDTH = 16U;
|
||||
constexpr uint8_t INT64MAXPRECISION = 18U;
|
||||
constexpr uint8_t INT128MAXPRECISION = 38U;
|
||||
constexpr uint32_t MAXLEGACYWIDTH = 8U;
|
||||
constexpr uint8_t MAXSCALEINC4AVG = 4U;
|
||||
|
||||
|
||||
const uint64_t mcs_pow_10[20] =
|
||||
{
|
||||
const uint64_t mcs_pow_10[20] = {
|
||||
1ULL,
|
||||
10ULL,
|
||||
100ULL,
|
||||
@ -109,8 +141,7 @@ const uint64_t mcs_pow_10[20] =
|
||||
1000000000000000000ULL,
|
||||
10000000000000000000ULL,
|
||||
};
|
||||
const int128_t mcs_pow_10_128[20] =
|
||||
{
|
||||
const int128_t mcs_pow_10_128[20] = {
|
||||
10000000000000000000_xxl,
|
||||
100000000000000000000_xxl,
|
||||
1000000000000000000000_xxl,
|
||||
@ -137,7 +168,6 @@ constexpr uint32_t maxPowOf10 = sizeof(mcs_pow_10)/sizeof(mcs_pow_10[0])-1;
|
||||
constexpr int128_t Decimal128Null = TSInt128::NullValue;
|
||||
constexpr int128_t Decimal128Empty = TSInt128::EmptyValue;
|
||||
|
||||
|
||||
template <typename T>
|
||||
T scaleDivisor(const uint32_t scale)
|
||||
{
|
||||
@ -151,20 +181,20 @@ T scaleDivisor(const uint32_t scale)
|
||||
return (T)mcs_pow_10_128[scale - 19];
|
||||
}
|
||||
|
||||
|
||||
// Decomposed Decimal representation
|
||||
// T - storage data type (int64_t, int128_t)
|
||||
template<typename T>class DecomposedDecimal
|
||||
template <typename T>
|
||||
class DecomposedDecimal
|
||||
{
|
||||
T mDivisor;
|
||||
T mIntegral;
|
||||
T mFractional;
|
||||
|
||||
public:
|
||||
DecomposedDecimal(T value, uint32_t scale)
|
||||
:mDivisor(scaleDivisor<T>(scale)),
|
||||
mIntegral(value / mDivisor),
|
||||
mFractional(value % mDivisor)
|
||||
{ }
|
||||
: mDivisor(scaleDivisor<T>(scale)), mIntegral(value / mDivisor), mFractional(value % mDivisor)
|
||||
{
|
||||
}
|
||||
T toSIntRound() const
|
||||
{
|
||||
T frac2 = 2 * mFractional;
|
||||
@ -191,13 +221,11 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename T>
|
||||
T applySignedScale(const T& val, int32_t scale)
|
||||
{
|
||||
return scale < 0 ?
|
||||
val / datatypes::scaleDivisor<T>((uint32_t) -scale) :
|
||||
val * datatypes::scaleDivisor<T>((uint32_t) scale);
|
||||
return scale < 0 ? val / datatypes::scaleDivisor<T>((uint32_t)-scale)
|
||||
: val * datatypes::scaleDivisor<T>((uint32_t)scale);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -219,9 +247,12 @@ struct lldiv_t_128
|
||||
{
|
||||
int128_t quot;
|
||||
int128_t rem;
|
||||
lldiv_t_128() : quot(0), rem(0) {}
|
||||
lldiv_t_128(const int128_t& a_quot, const int128_t& a_rem)
|
||||
: quot(a_quot), rem(a_rem) {}
|
||||
lldiv_t_128() : quot(0), rem(0)
|
||||
{
|
||||
}
|
||||
lldiv_t_128(const int128_t& a_quot, const int128_t& a_rem) : quot(a_quot), rem(a_rem)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
inline lldiv_t_128 lldiv128(const int128_t& dividend, const int128_t& divisor)
|
||||
@ -232,25 +263,25 @@ inline lldiv_t_128 lldiv128(const int128_t& dividend, const int128_t& divisor)
|
||||
return lldiv_t_128(dividend / divisor, dividend % divisor);
|
||||
}
|
||||
|
||||
|
||||
// TODO: derive it from TSInt64 eventually
|
||||
class TDecimal64
|
||||
{
|
||||
public:
|
||||
int64_t value;
|
||||
|
||||
public:
|
||||
static constexpr uint8_t MAXLENGTH8BYTES = 23;
|
||||
|
||||
public:
|
||||
TDecimal64()
|
||||
:value(0)
|
||||
{ }
|
||||
explicit TDecimal64(int64_t val)
|
||||
:value(val)
|
||||
{ }
|
||||
explicit TDecimal64(const TSInt64 &val)
|
||||
:value(static_cast<int64_t>(val))
|
||||
{ }
|
||||
TDecimal64() : value(0)
|
||||
{
|
||||
}
|
||||
explicit TDecimal64(int64_t val) : value(val)
|
||||
{
|
||||
}
|
||||
explicit TDecimal64(const TSInt64& val) : value(static_cast<int64_t>(val))
|
||||
{
|
||||
}
|
||||
// Divide to the scale divisor with rounding
|
||||
int64_t toSInt64Round(uint32_t scale) const
|
||||
{
|
||||
@ -258,9 +289,7 @@ public:
|
||||
}
|
||||
uint64_t toUInt64Round(uint32_t scale) const
|
||||
{
|
||||
return value < 0 ?
|
||||
0 :
|
||||
static_cast<uint64_t>(toSInt64Round(scale));
|
||||
return value < 0 ? 0 : static_cast<uint64_t>(toSInt64Round(scale));
|
||||
}
|
||||
|
||||
int64_t toSInt64Floor(uint32_t scale) const
|
||||
@ -282,7 +311,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class TDecimal128 : public TSInt128
|
||||
{
|
||||
public:
|
||||
@ -312,24 +340,24 @@ public:
|
||||
|
||||
public:
|
||||
TDecimal128()
|
||||
{ }
|
||||
explicit TDecimal128(const int128_t &val)
|
||||
:TSInt128(val)
|
||||
{ }
|
||||
explicit TDecimal128(const TSInt128& val)
|
||||
:TSInt128(val)
|
||||
{ }
|
||||
explicit TDecimal128(const int128_t* valPtr)
|
||||
:TSInt128(valPtr)
|
||||
{ }
|
||||
{
|
||||
}
|
||||
explicit TDecimal128(const int128_t& val) : TSInt128(val)
|
||||
{
|
||||
}
|
||||
explicit TDecimal128(const TSInt128& val) : TSInt128(val)
|
||||
{
|
||||
}
|
||||
explicit TDecimal128(const int128_t* valPtr) : TSInt128(valPtr)
|
||||
{
|
||||
}
|
||||
uint64_t toUInt64Round(uint32_t scale) const
|
||||
{
|
||||
if (s128Value <= 0)
|
||||
return 0;
|
||||
int128_t intg = DecomposedDecimal<int128_t>(s128Value, scale).
|
||||
toSIntRoundPositive();
|
||||
return intg > numeric_limits<uint64_t>::max() ? numeric_limits<uint64_t>::max() :
|
||||
static_cast<uint64_t>(intg);
|
||||
int128_t intg = DecomposedDecimal<int128_t>(s128Value, scale).toSIntRoundPositive();
|
||||
return intg > numeric_limits<uint64_t>::max() ? numeric_limits<uint64_t>::max()
|
||||
: static_cast<uint64_t>(intg);
|
||||
}
|
||||
|
||||
int128_t toSInt128Floor(uint32_t scale) const
|
||||
@ -343,7 +371,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// @brief The class for Decimal related operations
|
||||
// The methods and operators implemented in this class are
|
||||
// scale and precision aware.
|
||||
@ -361,36 +388,28 @@ class Decimal: public TDecimal128, public TDecimal64
|
||||
two internal representations of decimal.
|
||||
*/
|
||||
template <typename T, bool overflow>
|
||||
static void addition(const Decimal& l,
|
||||
const Decimal& r,
|
||||
Decimal& result);
|
||||
static void addition(const Decimal& l, const Decimal& r, Decimal& result);
|
||||
|
||||
/**
|
||||
@brief Subtraction template that supports overflow check and
|
||||
two internal representations of decimal.
|
||||
*/
|
||||
template <typename T, bool overflow>
|
||||
static void subtraction(const Decimal& l,
|
||||
const Decimal& r,
|
||||
Decimal& result);
|
||||
static void subtraction(const Decimal& l, const Decimal& r, Decimal& result);
|
||||
|
||||
/**
|
||||
@brief Division template that supports overflow check and
|
||||
two internal representations of decimal.
|
||||
*/
|
||||
template <typename T, bool overflow>
|
||||
static void division(const Decimal& l,
|
||||
const Decimal& r,
|
||||
Decimal& result);
|
||||
static void division(const Decimal& l, const Decimal& r, Decimal& result);
|
||||
|
||||
/**
|
||||
@brief Multiplication template that supports overflow check and
|
||||
two internal representations of decimal.
|
||||
*/
|
||||
template <typename T, bool overflow>
|
||||
static void multiplication(const Decimal& l,
|
||||
const Decimal& r,
|
||||
Decimal& result);
|
||||
static void multiplication(const Decimal& l, const Decimal& r, Decimal& result);
|
||||
|
||||
/**
|
||||
@brief The method detects whether decimal type is wide
|
||||
@ -398,16 +417,13 @@ class Decimal: public TDecimal128, public TDecimal64
|
||||
*/
|
||||
static inline bool isWideDecimalTypeByPrecision(const int32_t precision)
|
||||
{
|
||||
return precision > INT64MAXPRECISION
|
||||
&& precision <= INT128MAXPRECISION;
|
||||
return precision > INT64MAXPRECISION && precision <= INT128MAXPRECISION;
|
||||
}
|
||||
|
||||
/**
|
||||
@brief MDB increases scale by up to 4 digits calculating avg()
|
||||
*/
|
||||
static inline void setScalePrecision4Avg(
|
||||
unsigned int& precision,
|
||||
unsigned int& scale)
|
||||
static inline void setScalePrecision4Avg(unsigned int& precision, unsigned int& scale)
|
||||
{
|
||||
uint32_t scaleAvailable = INT128MAXPRECISION - scale;
|
||||
uint32_t precisionAvailable = INT128MAXPRECISION - precision;
|
||||
@ -419,35 +435,25 @@ class Decimal: public TDecimal128, public TDecimal64
|
||||
{
|
||||
}
|
||||
|
||||
Decimal(int64_t val, int8_t s, uint8_t p, const int128_t &val128 = 0) :
|
||||
TDecimal128(val128),
|
||||
TDecimal64(val),
|
||||
scale(s),
|
||||
precision(p)
|
||||
{ }
|
||||
Decimal(int64_t val, int8_t s, uint8_t p, const int128_t& val128 = 0)
|
||||
: TDecimal128(val128), TDecimal64(val), scale(s), precision(p)
|
||||
{
|
||||
}
|
||||
|
||||
Decimal(const TSInt64 &val, int8_t s, uint8_t p) :
|
||||
TDecimal64(val),
|
||||
scale(s),
|
||||
precision(p)
|
||||
{ }
|
||||
Decimal(const TSInt64& val, int8_t s, uint8_t p) : TDecimal64(val), scale(s), precision(p)
|
||||
{
|
||||
}
|
||||
|
||||
Decimal(int64_t unused, int8_t s, uint8_t p, const int128_t* val128Ptr) :
|
||||
TDecimal128(val128Ptr),
|
||||
TDecimal64(unused),
|
||||
scale(s),
|
||||
precision(p)
|
||||
{ }
|
||||
Decimal(int64_t unused, int8_t s, uint8_t p, const int128_t* val128Ptr)
|
||||
: TDecimal128(val128Ptr), TDecimal64(unused), scale(s), precision(p)
|
||||
{
|
||||
}
|
||||
|
||||
Decimal(const TSInt128& val128, int8_t s, uint8_t p) :
|
||||
TDecimal128(val128),
|
||||
scale(s),
|
||||
precision(p)
|
||||
{ }
|
||||
Decimal(const TSInt128& val128, int8_t s, uint8_t p) : TDecimal128(val128), scale(s), precision(p)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Decimal(const char *str, size_t length, DataCondition & error,
|
||||
int8_t s, uint8_t p);
|
||||
Decimal(const char* str, size_t length, DataCondition& error, int8_t s, uint8_t p);
|
||||
|
||||
int decimalComp(const Decimal& d) const
|
||||
{
|
||||
@ -553,16 +559,14 @@ class Decimal: public TDecimal128, public TDecimal64
|
||||
{
|
||||
int128_t scaleDivisor;
|
||||
getScaleDivisor(scaleDivisor, scale);
|
||||
return std::make_pair(TSInt128(s128Value / scaleDivisor),
|
||||
TSInt128(s128Value % scaleDivisor));
|
||||
return std::make_pair(TSInt128(s128Value / scaleDivisor), TSInt128(s128Value % scaleDivisor));
|
||||
}
|
||||
|
||||
inline std::tuple<TSInt128, TSInt128, TSInt128> getIntegralFractionalAndDivisor() const
|
||||
{
|
||||
int128_t scaleDivisor;
|
||||
getScaleDivisor(scaleDivisor, scale);
|
||||
return std::make_tuple(TSInt128(s128Value / scaleDivisor),
|
||||
TSInt128(s128Value % scaleDivisor),
|
||||
return std::make_tuple(TSInt128(s128Value / scaleDivisor), TSInt128(s128Value % scaleDivisor),
|
||||
TSInt128(scaleDivisor));
|
||||
}
|
||||
|
||||
@ -603,66 +607,65 @@ class Decimal: public TDecimal128, public TDecimal64
|
||||
return TDecimal64::toUInt64Round((uint32_t)scale);
|
||||
}
|
||||
|
||||
template<typename T> T decimal64ToXFloat() const
|
||||
template <typename T>
|
||||
T decimal64ToXFloat() const
|
||||
{
|
||||
return TDecimal64::toXFloat<T>((uint32_t)scale);
|
||||
}
|
||||
|
||||
int64_t toSInt64Round() const
|
||||
{
|
||||
return isWideDecimalTypeByPrecision(precision) ?
|
||||
static_cast<int64_t>(getPosNegRoundedIntegralPart(4)) :
|
||||
TDecimal64::toSInt64Round((uint32_t) scale);
|
||||
return isWideDecimalTypeByPrecision(precision) ? static_cast<int64_t>(getPosNegRoundedIntegralPart(4))
|
||||
: TDecimal64::toSInt64Round((uint32_t)scale);
|
||||
}
|
||||
uint64_t toUInt64Round() const
|
||||
{
|
||||
return isWideDecimalTypeByPrecision(precision) ?
|
||||
TDecimal128::toUInt64Round((uint32_t) scale) :
|
||||
TDecimal64::toUInt64Round((uint32_t) scale);
|
||||
return isWideDecimalTypeByPrecision(precision) ? TDecimal128::toUInt64Round((uint32_t)scale)
|
||||
: TDecimal64::toUInt64Round((uint32_t)scale);
|
||||
}
|
||||
|
||||
// FLOOR related routines
|
||||
int64_t toSInt64Floor() const
|
||||
{
|
||||
return isWideDecimalTypeByPrecision(precision) ?
|
||||
static_cast<int64_t>(TSInt128(TDecimal128::toSInt128Floor((uint32_t) scale))) :
|
||||
TDecimal64::toSInt64Floor((uint32_t) scale);
|
||||
return isWideDecimalTypeByPrecision(precision)
|
||||
? static_cast<int64_t>(TSInt128(TDecimal128::toSInt128Floor((uint32_t)scale)))
|
||||
: TDecimal64::toSInt64Floor((uint32_t)scale);
|
||||
}
|
||||
|
||||
uint64_t toUInt64Floor() const
|
||||
{
|
||||
return isWideDecimalTypeByPrecision(precision) ?
|
||||
static_cast<uint64_t>(TSInt128(TDecimal128::toSInt128Floor((uint32_t) scale))) :
|
||||
static_cast<uint64_t>(TSInt64(TDecimal64::toSInt64Floor((uint32_t) scale)));
|
||||
return isWideDecimalTypeByPrecision(precision)
|
||||
? static_cast<uint64_t>(TSInt128(TDecimal128::toSInt128Floor((uint32_t)scale)))
|
||||
: static_cast<uint64_t>(TSInt64(TDecimal64::toSInt64Floor((uint32_t)scale)));
|
||||
}
|
||||
|
||||
Decimal floor() const
|
||||
{
|
||||
return isWideDecimalTypeByPrecision(precision)?
|
||||
Decimal(TSInt128(TDecimal128::toSInt128Floor((uint32_t) scale)), 0, precision) :
|
||||
Decimal(TSInt64(TDecimal64::toSInt64Floor((uint32_t) scale)), 0, precision);
|
||||
return isWideDecimalTypeByPrecision(precision)
|
||||
? Decimal(TSInt128(TDecimal128::toSInt128Floor((uint32_t)scale)), 0, precision)
|
||||
: Decimal(TSInt64(TDecimal64::toSInt64Floor((uint32_t)scale)), 0, precision);
|
||||
}
|
||||
|
||||
// CEIL related routines
|
||||
int64_t toSInt64Ceil() const
|
||||
{
|
||||
return isWideDecimalTypeByPrecision(precision) ?
|
||||
static_cast<int64_t>(TSInt128(TDecimal128::toSInt128Ceil((uint32_t) scale))) :
|
||||
static_cast<int64_t>(TSInt64(TDecimal64::toSInt64Ceil((uint32_t) scale)));
|
||||
return isWideDecimalTypeByPrecision(precision)
|
||||
? static_cast<int64_t>(TSInt128(TDecimal128::toSInt128Ceil((uint32_t)scale)))
|
||||
: static_cast<int64_t>(TSInt64(TDecimal64::toSInt64Ceil((uint32_t)scale)));
|
||||
}
|
||||
|
||||
uint64_t toUInt64Ceil() const
|
||||
{
|
||||
return isWideDecimalTypeByPrecision(precision) ?
|
||||
static_cast<uint64_t>(TSInt128(TDecimal128::toSInt128Ceil((uint32_t) scale))) :
|
||||
static_cast<uint64_t>(TSInt64(TDecimal64::toSInt64Ceil((uint32_t) scale)));
|
||||
return isWideDecimalTypeByPrecision(precision)
|
||||
? static_cast<uint64_t>(TSInt128(TDecimal128::toSInt128Ceil((uint32_t)scale)))
|
||||
: static_cast<uint64_t>(TSInt64(TDecimal64::toSInt64Ceil((uint32_t)scale)));
|
||||
}
|
||||
|
||||
Decimal ceil() const
|
||||
{
|
||||
return isWideDecimalTypeByPrecision(precision) ?
|
||||
Decimal(TSInt128(TDecimal128::toSInt128Ceil((uint32_t) scale)), 0, precision) :
|
||||
Decimal(TSInt64(TDecimal64::toSInt64Ceil((uint32_t) scale)), 0, precision);
|
||||
return isWideDecimalTypeByPrecision(precision)
|
||||
? Decimal(TSInt128(TDecimal128::toSInt128Ceil((uint32_t)scale)), 0, precision)
|
||||
: Decimal(TSInt64(TDecimal64::toSInt64Ceil((uint32_t)scale)), 0, precision);
|
||||
}
|
||||
|
||||
// MOD operator for an integer divisor to be used
|
||||
@ -676,7 +679,9 @@ class Decimal: public TDecimal128, public TDecimal64
|
||||
// Scale the value and calculate
|
||||
// (LHS.value % RHS.value) * LHS.scaleMultiplier + LHS.scale_div_remainder
|
||||
auto integralFractionalDivisor = getIntegralFractionalAndDivisor();
|
||||
return (std::get<0>(integralFractionalDivisor) % div.getValue()) * std::get<2>(integralFractionalDivisor) + std::get<1>(integralFractionalDivisor);
|
||||
return (std::get<0>(integralFractionalDivisor) % div.getValue()) *
|
||||
std::get<2>(integralFractionalDivisor) +
|
||||
std::get<1>(integralFractionalDivisor);
|
||||
}
|
||||
|
||||
template <typename Op128, typename Op64>
|
||||
@ -684,18 +689,15 @@ class Decimal: public TDecimal128, public TDecimal64
|
||||
{
|
||||
Op128 op128;
|
||||
Op64 op64;
|
||||
if (precision > datatypes::INT64MAXPRECISION &&
|
||||
rhs.precision > datatypes::INT64MAXPRECISION)
|
||||
if (precision > datatypes::INT64MAXPRECISION && rhs.precision > datatypes::INT64MAXPRECISION)
|
||||
{
|
||||
if (scale == rhs.scale)
|
||||
return op128(s128Value, rhs.s128Value);
|
||||
else
|
||||
return op64(datatypes::Decimal::compare(*this, rhs), 0);
|
||||
}
|
||||
else if (precision > datatypes::INT64MAXPRECISION &&
|
||||
rhs.precision <= datatypes::INT64MAXPRECISION)
|
||||
else if (precision > datatypes::INT64MAXPRECISION && rhs.precision <= datatypes::INT64MAXPRECISION)
|
||||
{
|
||||
|
||||
if (scale == rhs.scale)
|
||||
{
|
||||
return op128(s128Value, (int128_t)rhs.value);
|
||||
@ -703,16 +705,11 @@ class Decimal: public TDecimal128, public TDecimal64
|
||||
else
|
||||
{
|
||||
// comp_op<int64>(compare(l,r),0)
|
||||
return op64(datatypes::Decimal::compare(
|
||||
*this,
|
||||
Decimal(TSInt128(rhs.value),
|
||||
rhs.scale,
|
||||
rhs.precision)),
|
||||
0);
|
||||
return op64(
|
||||
datatypes::Decimal::compare(*this, Decimal(TSInt128(rhs.value), rhs.scale, rhs.precision)), 0);
|
||||
}
|
||||
}
|
||||
else if (precision <= datatypes::INT64MAXPRECISION &&
|
||||
rhs.precision > datatypes::INT64MAXPRECISION)
|
||||
else if (precision <= datatypes::INT64MAXPRECISION && rhs.precision > datatypes::INT64MAXPRECISION)
|
||||
{
|
||||
if (scale == rhs.scale)
|
||||
{
|
||||
@ -721,13 +718,7 @@ class Decimal: public TDecimal128, public TDecimal64
|
||||
else
|
||||
{
|
||||
// comp_op<int64>(compare(l,r),0)
|
||||
return op64(datatypes::Decimal::compare(
|
||||
Decimal(
|
||||
TSInt128(value),
|
||||
scale,
|
||||
precision),
|
||||
rhs),
|
||||
0);
|
||||
return op64(datatypes::Decimal::compare(Decimal(TSInt128(value), scale, precision), rhs), 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -741,20 +732,17 @@ class Decimal: public TDecimal128, public TDecimal64
|
||||
|
||||
bool operator==(const Decimal& rhs) const
|
||||
{
|
||||
return cmpOperatorTemplate<std::equal_to<int128_t>,
|
||||
std::equal_to<int64_t>>(rhs);
|
||||
return cmpOperatorTemplate<std::equal_to<int128_t>, std::equal_to<int64_t>>(rhs);
|
||||
}
|
||||
|
||||
bool operator>(const Decimal& rhs) const
|
||||
{
|
||||
return cmpOperatorTemplate<std::greater<int128_t>,
|
||||
std::greater<int64_t>>(rhs);
|
||||
return cmpOperatorTemplate<std::greater<int128_t>, std::greater<int64_t>>(rhs);
|
||||
}
|
||||
|
||||
bool operator>=(const Decimal& rhs) const
|
||||
{
|
||||
return cmpOperatorTemplate<std::greater_equal<int128_t>,
|
||||
std::greater_equal<int64_t>>(rhs);
|
||||
return cmpOperatorTemplate<std::greater_equal<int128_t>, std::greater_equal<int64_t>>(rhs);
|
||||
}
|
||||
|
||||
bool operator<(const Decimal& rhs) const
|
||||
@ -783,21 +771,14 @@ class Decimal: public TDecimal128, public TDecimal64
|
||||
|
||||
if (datatypes::abs(div.rem) * 2 >= scaleDivisorInt)
|
||||
{
|
||||
return Decimal(value,
|
||||
scale,
|
||||
precision,
|
||||
(div.quot < 0) ? div.quot-- : div.quot++);
|
||||
return Decimal(value, scale, precision, (div.quot < 0) ? div.quot-- : div.quot++);
|
||||
}
|
||||
return Decimal(value,
|
||||
scale,
|
||||
precision,
|
||||
div.quot);
|
||||
return Decimal(value, scale, precision, div.quot);
|
||||
}
|
||||
|
||||
inline bool isTSInt128ByPrecision() const
|
||||
{
|
||||
return precision > INT64MAXPRECISION
|
||||
&& precision <= INT128MAXPRECISION;
|
||||
return precision > INT64MAXPRECISION && precision <= INT128MAXPRECISION;
|
||||
}
|
||||
|
||||
inline bool isScaled() const
|
||||
@ -815,17 +796,22 @@ class Decimal: public TDecimal128, public TDecimal64
|
||||
uint8_t precision; // 1~38
|
||||
|
||||
// STRICTLY for unit tests!!!
|
||||
void setTSInt64Value(const int64_t x) { value = x; }
|
||||
void setTSInt128Value(const int128_t& x) { s128Value = x; }
|
||||
void setScale(const uint8_t x) { scale = x; }
|
||||
void setTSInt64Value(const int64_t x)
|
||||
{
|
||||
value = x;
|
||||
}
|
||||
void setTSInt128Value(const int128_t& x)
|
||||
{
|
||||
s128Value = x;
|
||||
}
|
||||
void setScale(const uint8_t x)
|
||||
{
|
||||
scale = x;
|
||||
}
|
||||
|
||||
private:
|
||||
uint8_t writeIntPart(const int128_t& x,
|
||||
char* buf,
|
||||
const uint8_t buflen) const;
|
||||
uint8_t writeFractionalPart(const int128_t& x,
|
||||
char* buf,
|
||||
const uint8_t buflen) const;
|
||||
uint8_t writeIntPart(const int128_t& x, char* buf, const uint8_t buflen) const;
|
||||
uint8_t writeFractionalPart(const int128_t& x, char* buf, const uint8_t buflen) const;
|
||||
std::string toStringTSInt128WithScale() const;
|
||||
std::string toStringTSInt64() const;
|
||||
|
||||
@ -847,21 +833,20 @@ class Decimal: public TDecimal128, public TDecimal64
|
||||
@brief The structure contains an overflow check for int128
|
||||
division.
|
||||
*/
|
||||
struct DivisionOverflowCheck {
|
||||
struct DivisionOverflowCheck
|
||||
{
|
||||
void operator()(const int128_t& x, const int128_t& y)
|
||||
{
|
||||
if (x == Decimal::minInt128 && y == -1)
|
||||
{
|
||||
throw logging::OperationOverflowExcept(
|
||||
"Decimal::division<int128_t> produces an overflow.");
|
||||
throw logging::OperationOverflowExcept("Decimal::division<int128_t> produces an overflow.");
|
||||
}
|
||||
}
|
||||
void operator()(const int64_t x, const int64_t y)
|
||||
{
|
||||
if (x == std::numeric_limits<int64_t>::min() && y == -1)
|
||||
{
|
||||
throw logging::OperationOverflowExcept(
|
||||
"Decimal::division<int64_t> produces an overflow.");
|
||||
throw logging::OperationOverflowExcept("Decimal::division<int64_t> produces an overflow.");
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -870,7 +855,8 @@ struct DivisionOverflowCheck {
|
||||
// @brief The structure contains an overflow check for int128
|
||||
// and int64_t multiplication.
|
||||
//
|
||||
struct MultiplicationOverflowCheck {
|
||||
struct MultiplicationOverflowCheck
|
||||
{
|
||||
void operator()(const int128_t& x, const int128_t& y)
|
||||
{
|
||||
int128_t tempR = 0;
|
||||
@ -913,7 +899,8 @@ produces an overflow.");
|
||||
@brief The strucuture runs an empty overflow check for int128
|
||||
multiplication operation.
|
||||
*/
|
||||
struct MultiplicationNoOverflowCheck {
|
||||
struct MultiplicationNoOverflowCheck
|
||||
{
|
||||
void operator()(const int128_t& x, const int128_t& y, int128_t& r)
|
||||
{
|
||||
r = x * y;
|
||||
@ -924,23 +911,21 @@ struct MultiplicationNoOverflowCheck {
|
||||
@brief The structure contains an overflow check for int128
|
||||
and int64 addition.
|
||||
*/
|
||||
struct AdditionOverflowCheck {
|
||||
struct AdditionOverflowCheck
|
||||
{
|
||||
void operator()(const int128_t& x, const int128_t& y)
|
||||
{
|
||||
if ((y > 0 && x > Decimal::maxInt128 - y)
|
||||
|| (y < 0 && x < Decimal::minInt128 - y))
|
||||
if ((y > 0 && x > Decimal::maxInt128 - y) || (y < 0 && x < Decimal::minInt128 - y))
|
||||
{
|
||||
throw logging::OperationOverflowExcept(
|
||||
"Decimal::addition<int128_t> produces an overflow.");
|
||||
throw logging::OperationOverflowExcept("Decimal::addition<int128_t> produces an overflow.");
|
||||
}
|
||||
}
|
||||
void operator()(const int64_t x, const int64_t y)
|
||||
{
|
||||
if ((y > 0 && x > std::numeric_limits<int64_t>::max() - y)
|
||||
|| (y < 0 && x < std::numeric_limits<int64_t>::min() - y))
|
||||
if ((y > 0 && x > std::numeric_limits<int64_t>::max() - y) ||
|
||||
(y < 0 && x < std::numeric_limits<int64_t>::min() - y))
|
||||
{
|
||||
throw logging::OperationOverflowExcept(
|
||||
"Decimal::addition<int64_t> produces an overflow.");
|
||||
throw logging::OperationOverflowExcept("Decimal::addition<int64_t> produces an overflow.");
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -949,23 +934,21 @@ struct AdditionOverflowCheck {
|
||||
@brief The structure contains an overflow check for int128
|
||||
subtraction.
|
||||
*/
|
||||
struct SubtractionOverflowCheck {
|
||||
struct SubtractionOverflowCheck
|
||||
{
|
||||
void operator()(const int128_t& x, const int128_t& y)
|
||||
{
|
||||
if ((y > 0 && x < Decimal::minInt128 + y)
|
||||
|| (y < 0 && x > Decimal::maxInt128 + y))
|
||||
if ((y > 0 && x < Decimal::minInt128 + y) || (y < 0 && x > Decimal::maxInt128 + y))
|
||||
{
|
||||
throw logging::OperationOverflowExcept(
|
||||
"Decimal::subtraction<int128_t> produces an overflow.");
|
||||
throw logging::OperationOverflowExcept("Decimal::subtraction<int128_t> produces an overflow.");
|
||||
}
|
||||
}
|
||||
void operator()(const int64_t x, const int64_t y)
|
||||
{
|
||||
if ((y > 0 && x < std::numeric_limits<int64_t>::min() + y)
|
||||
|| (y < 0 && x > std::numeric_limits<int64_t>::max() + y))
|
||||
if ((y > 0 && x < std::numeric_limits<int64_t>::min() + y) ||
|
||||
(y < 0 && x > std::numeric_limits<int64_t>::max() + y))
|
||||
{
|
||||
throw logging::OperationOverflowExcept(
|
||||
"Decimal::subtraction<int64_t> produces an overflow.");
|
||||
throw logging::OperationOverflowExcept("Decimal::subtraction<int64_t> produces an overflow.");
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -974,11 +957,12 @@ struct SubtractionOverflowCheck {
|
||||
@brief The strucuture runs an empty overflow check for int128
|
||||
operation.
|
||||
*/
|
||||
struct NoOverflowCheck {
|
||||
struct NoOverflowCheck
|
||||
{
|
||||
void operator()(const int128_t& x, const int128_t& y)
|
||||
{
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
} //end of namespace
|
||||
} // namespace datatypes
|
||||
|
@ -22,15 +22,19 @@
|
||||
|
||||
namespace datatypes
|
||||
{
|
||||
|
||||
class TDouble
|
||||
{
|
||||
protected:
|
||||
double mValue;
|
||||
public:
|
||||
TDouble(): mValue(0) { }
|
||||
|
||||
explicit TDouble(double value): mValue(value) { }
|
||||
public:
|
||||
TDouble() : mValue(0)
|
||||
{
|
||||
}
|
||||
|
||||
explicit TDouble(double value) : mValue(value)
|
||||
{
|
||||
}
|
||||
|
||||
explicit operator double() const
|
||||
{
|
||||
@ -48,7 +52,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // end of namespace datatypes
|
||||
|
||||
// vim:ts=2 sw=2:
|
||||
|
@ -33,7 +33,6 @@ using float128_t = __float128;
|
||||
|
||||
namespace datatypes
|
||||
{
|
||||
|
||||
/* Main union type we use to manipulate the floating-point type. */
|
||||
typedef union
|
||||
{
|
||||
@ -78,7 +77,8 @@ typedef union
|
||||
|
||||
/* Get two 64 bit ints from a long double. */
|
||||
#define MCS_GET_FLT128_WORDS64(ix0, ix1, d) \
|
||||
do { \
|
||||
do \
|
||||
{ \
|
||||
mcs_ieee854_float128 u; \
|
||||
u.value = (d); \
|
||||
(ix0) = u.words64.high; \
|
||||
@ -87,7 +87,8 @@ do { \
|
||||
|
||||
/* Set a long double from two 64 bit ints. */
|
||||
#define MCS_SET_FLT128_WORDS64(d, ix0, ix1) \
|
||||
do { \
|
||||
do \
|
||||
{ \
|
||||
mcs_ieee854_float128 u; \
|
||||
u.words64.high = (ix0); \
|
||||
u.words64.low = (ix1); \
|
||||
@ -98,40 +99,33 @@ class TSInt128;
|
||||
class TFloat128;
|
||||
using int128_t = __int128;
|
||||
|
||||
static const float128_t mcs_fl_one = 1.0, mcs_fl_Zero[] = {0.0, -0.0,};
|
||||
static const float128_t mcs_fl_one = 1.0, mcs_fl_Zero[] = {
|
||||
0.0,
|
||||
-0.0,
|
||||
};
|
||||
|
||||
// Copy from boost::multiprecision::float128
|
||||
template<> class numeric_limits<float128_t> {
|
||||
template <>
|
||||
class numeric_limits<float128_t>
|
||||
{
|
||||
public:
|
||||
static constexpr bool is_specialized = true;
|
||||
static float128_t max()
|
||||
{
|
||||
return mcs_ieee854_float128{ .ieee = {0xffffffff,
|
||||
0xffffffff,
|
||||
0xffffffff,
|
||||
0xffff,
|
||||
0x7ffe,
|
||||
0x0}}.value;
|
||||
return mcs_ieee854_float128{.ieee = {0xffffffff, 0xffffffff, 0xffffffff, 0xffff, 0x7ffe, 0x0}}.value;
|
||||
}
|
||||
static float128_t min()
|
||||
{
|
||||
return mcs_ieee854_float128{ .ieee = {0x0,
|
||||
0x0,
|
||||
0x0,
|
||||
0x0,
|
||||
0x1,
|
||||
0x0}}.value;
|
||||
return mcs_ieee854_float128{.ieee = {0x0, 0x0, 0x0, 0x0, 0x1, 0x0}}.value;
|
||||
}
|
||||
static float128_t denorm_min()
|
||||
{
|
||||
return mcs_ieee854_float128{ .ieee = {0x1,
|
||||
0x0,
|
||||
0x0,
|
||||
0x0,
|
||||
0x0,
|
||||
0x0}}.value;
|
||||
return mcs_ieee854_float128{.ieee = {0x1, 0x0, 0x0, 0x0, 0x0, 0x0}}.value;
|
||||
}
|
||||
static float128_t lowest()
|
||||
{
|
||||
return -max();
|
||||
}
|
||||
static float128_t lowest() { return -max(); }
|
||||
static constexpr int digits = 113;
|
||||
static constexpr int digits10 = 33;
|
||||
static constexpr int max_digits10 = 36;
|
||||
@ -139,18 +133,30 @@ template<> class numeric_limits<float128_t> {
|
||||
static constexpr bool is_integer = false;
|
||||
static constexpr bool is_exact = false;
|
||||
static constexpr int radix = 2;
|
||||
static float128_t round_error() { return 0.5; }
|
||||
static float128_t round_error()
|
||||
{
|
||||
return 0.5;
|
||||
}
|
||||
static constexpr int min_exponent = -16381;
|
||||
static constexpr int min_exponent10 = min_exponent * 301L / 1000L;
|
||||
static constexpr int max_exponent = 16384;
|
||||
static constexpr int max_exponent10 = max_exponent * 301L / 1000L;
|
||||
static constexpr bool has_infinity = true;
|
||||
static constexpr bool has_quiet_NaN = true;
|
||||
static float128_t quiet_NaN() { return 1.0 / 0.0; }
|
||||
static float128_t quiet_NaN()
|
||||
{
|
||||
return 1.0 / 0.0;
|
||||
}
|
||||
static constexpr bool has_signaling_NaN = false;
|
||||
static constexpr bool has_denorm_loss = true;
|
||||
static float128_t infinity() { return 1.0 / 0.0; }
|
||||
static float128_t signaling_NaN() { return 0; }
|
||||
static float128_t infinity()
|
||||
{
|
||||
return 1.0 / 0.0;
|
||||
}
|
||||
static float128_t signaling_NaN()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
static constexpr bool is_iec559 = true;
|
||||
static constexpr bool is_bounded = false;
|
||||
static constexpr bool is_modulo = false;
|
||||
@ -161,17 +167,20 @@ template<> class numeric_limits<float128_t> {
|
||||
// Type defined integral types
|
||||
// for templates
|
||||
template <typename T>
|
||||
struct get_integral_type {
|
||||
struct get_integral_type
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct get_integral_type<TFloat128>{
|
||||
struct get_integral_type<TFloat128>
|
||||
{
|
||||
typedef float128_t type;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct get_integral_type<TSInt128>{
|
||||
struct get_integral_type<TSInt128>
|
||||
{
|
||||
typedef int128_t type;
|
||||
};
|
||||
|
||||
@ -183,11 +192,19 @@ class TFloat128
|
||||
|
||||
static constexpr uint16_t MAXLENGTH16BYTES = 42;
|
||||
// A variety of ctors for aligned and unaligned arguments
|
||||
TFloat128(): value(0) { }
|
||||
TFloat128() : value(0)
|
||||
{
|
||||
}
|
||||
|
||||
// aligned argument
|
||||
TFloat128(const float128_t& x) { value = x; }
|
||||
TFloat128(const int128_t& x) { value = static_cast<float128_t>(x); }
|
||||
TFloat128(const float128_t& x)
|
||||
{
|
||||
value = x;
|
||||
}
|
||||
TFloat128(const int128_t& x)
|
||||
{
|
||||
value = static_cast<float128_t>(x);
|
||||
}
|
||||
|
||||
// fmodq(x,y) taken from libquadmath
|
||||
// Return x mod y in exact arithmetic
|
||||
@ -207,51 +224,77 @@ class TFloat128
|
||||
if ((hy | ly) == 0 || (hx >= 0x7fff000000000000LL) || /* y=0,or x not finite */
|
||||
((hy | ((ly | -ly) >> 63)) > 0x7fff000000000000LL)) /* or y is NaN */
|
||||
return (x * y) / (x * y);
|
||||
if(hx<=hy) {
|
||||
if((hx<hy)||(lx<ly)) return x; /* |x|<|y| return x */
|
||||
if (hx <= hy)
|
||||
{
|
||||
if ((hx < hy) || (lx < ly))
|
||||
return x; /* |x|<|y| return x */
|
||||
if (lx == ly)
|
||||
return mcs_fl_Zero[(uint64_t)sx >> 63]; /* |x|=|y| return x*0*/
|
||||
}
|
||||
|
||||
/* determine ix = ilogb(x) */
|
||||
if(hx<0x0001000000000000LL) { /* subnormal x */
|
||||
if(hx==0) {
|
||||
for (ix = -16431, i=lx; i>0; i<<=1) ix -=1;
|
||||
} else {
|
||||
for (ix = -16382, i=hx<<15; i>0; i<<=1) ix -=1;
|
||||
if (hx < 0x0001000000000000LL)
|
||||
{ /* subnormal x */
|
||||
if (hx == 0)
|
||||
{
|
||||
for (ix = -16431, i = lx; i > 0; i <<= 1)
|
||||
ix -= 1;
|
||||
}
|
||||
} else ix = (hx>>48)-0x3fff;
|
||||
else
|
||||
{
|
||||
for (ix = -16382, i = hx << 15; i > 0; i <<= 1)
|
||||
ix -= 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
ix = (hx >> 48) - 0x3fff;
|
||||
|
||||
/* determine iy = ilogb(y) */
|
||||
if(hy<0x0001000000000000LL) { /* subnormal y */
|
||||
if(hy==0) {
|
||||
for (iy = -16431, i=ly; i>0; i<<=1) iy -=1;
|
||||
} else {
|
||||
for (iy = -16382, i=hy<<15; i>0; i<<=1) iy -=1;
|
||||
if (hy < 0x0001000000000000LL)
|
||||
{ /* subnormal y */
|
||||
if (hy == 0)
|
||||
{
|
||||
for (iy = -16431, i = ly; i > 0; i <<= 1)
|
||||
iy -= 1;
|
||||
}
|
||||
} else iy = (hy>>48)-0x3fff;
|
||||
else
|
||||
{
|
||||
for (iy = -16382, i = hy << 15; i > 0; i <<= 1)
|
||||
iy -= 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
iy = (hy >> 48) - 0x3fff;
|
||||
|
||||
/* set up {hx,lx}, {hy,ly} and align y to x */
|
||||
if (ix >= -16382)
|
||||
hx = 0x0001000000000000LL | (0x0000ffffffffffffLL & hx);
|
||||
else { /* subnormal x, shift x to normal */
|
||||
else
|
||||
{ /* subnormal x, shift x to normal */
|
||||
n = -16382 - ix;
|
||||
if(n<=63) {
|
||||
if (n <= 63)
|
||||
{
|
||||
hx = (hx << n) | (lx >> (64 - n));
|
||||
lx <<= n;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
hx = lx << (n - 64);
|
||||
lx = 0;
|
||||
}
|
||||
}
|
||||
if (iy >= -16382)
|
||||
hy = 0x0001000000000000LL | (0x0000ffffffffffffLL & hy);
|
||||
else { /* subnormal y, shift y to normal */
|
||||
else
|
||||
{ /* subnormal y, shift y to normal */
|
||||
n = -16382 - iy;
|
||||
if(n<=63) {
|
||||
if (n <= 63)
|
||||
{
|
||||
hy = (hy << n) | (ly >> (64 - n));
|
||||
ly <<= n;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
hy = ly << (n - 64);
|
||||
ly = 0;
|
||||
}
|
||||
@ -259,37 +302,66 @@ class TFloat128
|
||||
|
||||
/* fix point fmod */
|
||||
n = ix - iy;
|
||||
while(n--) {
|
||||
hz=hx-hy;lz=lx-ly; if(lx<ly) hz -= 1;
|
||||
if(hz<0){hx = hx+hx+(lx>>63); lx = lx+lx;}
|
||||
else {
|
||||
while (n--)
|
||||
{
|
||||
hz = hx - hy;
|
||||
lz = lx - ly;
|
||||
if (lx < ly)
|
||||
hz -= 1;
|
||||
if (hz < 0)
|
||||
{
|
||||
hx = hx + hx + (lx >> 63);
|
||||
lx = lx + lx;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((hz | lz) == 0) /* return sign(x)*0 */
|
||||
return mcs_fl_Zero[(uint64_t)sx >> 63];
|
||||
hx = hz+hz+(lz>>63); lx = lz+lz;
|
||||
hx = hz + hz + (lz >> 63);
|
||||
lx = lz + lz;
|
||||
}
|
||||
}
|
||||
hz=hx-hy;lz=lx-ly; if(lx<ly) hz -= 1;
|
||||
if(hz>=0) {hx=hz;lx=lz;}
|
||||
hz = hx - hy;
|
||||
lz = lx - ly;
|
||||
if (lx < ly)
|
||||
hz -= 1;
|
||||
if (hz >= 0)
|
||||
{
|
||||
hx = hz;
|
||||
lx = lz;
|
||||
}
|
||||
|
||||
/* convert back to floating value and restore the sign */
|
||||
if ((hx | lx) == 0) /* return sign(x)*0 */
|
||||
return mcs_fl_Zero[(uint64_t)sx >> 63];
|
||||
while(hx<0x0001000000000000LL) { /* normalize x */
|
||||
hx = hx+hx+(lx>>63); lx = lx+lx;
|
||||
while (hx < 0x0001000000000000LL)
|
||||
{ /* normalize x */
|
||||
hx = hx + hx + (lx >> 63);
|
||||
lx = lx + lx;
|
||||
iy -= 1;
|
||||
}
|
||||
if(iy>= -16382) { /* normalize output */
|
||||
if (iy >= -16382)
|
||||
{ /* normalize output */
|
||||
hx = ((hx - 0x0001000000000000LL) | ((iy + 16383) << 48));
|
||||
MCS_SET_FLT128_WORDS64(x, hx | sx, lx);
|
||||
} else { /* subnormal output */
|
||||
}
|
||||
else
|
||||
{ /* subnormal output */
|
||||
n = -16382 - iy;
|
||||
if(n<=48) {
|
||||
if (n <= 48)
|
||||
{
|
||||
lx = (lx >> n) | ((uint64_t)hx << (64 - n));
|
||||
hx >>= n;
|
||||
} else if (n<=63) {
|
||||
lx = (hx<<(64-n))|(lx>>n); hx = sx;
|
||||
} else {
|
||||
lx = hx>>(n-64); hx = sx;
|
||||
}
|
||||
else if (n <= 63)
|
||||
{
|
||||
lx = (hx << (64 - n)) | (lx >> n);
|
||||
hx = sx;
|
||||
}
|
||||
else
|
||||
{
|
||||
lx = hx >> (n - 64);
|
||||
hx = sx;
|
||||
}
|
||||
MCS_SET_FLT128_WORDS64(x, hx | sx, lx);
|
||||
x *= mcs_fl_one; /* create necessary signal */
|
||||
@ -306,9 +378,15 @@ class TFloat128
|
||||
const bool isinf = ((!isneg) ? bool(+x > (datatypes::numeric_limits<float128_t>::max)())
|
||||
: bool(-x > (datatypes::numeric_limits<float128_t>::max)()));
|
||||
|
||||
if(isnan) { return x; }
|
||||
if (isnan)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
if(isinf) { return datatypes::numeric_limits<float128_t>::quiet_NaN(); }
|
||||
if (isinf)
|
||||
{
|
||||
return datatypes::numeric_limits<float128_t>::quiet_NaN();
|
||||
}
|
||||
|
||||
const bool x_is_neg = (x < 0);
|
||||
const float128_t abs_x = (x_is_neg ? -x : x);
|
||||
@ -332,7 +410,10 @@ class TFloat128
|
||||
}
|
||||
else
|
||||
{
|
||||
if(p == static_cast<int>(1)) { return x; }
|
||||
if (p == static_cast<int>(1))
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
if (abs_x > (datatypes::numeric_limits<float128_t>::max)())
|
||||
{
|
||||
@ -340,9 +421,19 @@ class TFloat128
|
||||
: +datatypes::numeric_limits<float128_t>::infinity());
|
||||
}
|
||||
|
||||
if (p == static_cast<int>(2)) { return (x * x); }
|
||||
else if(p == static_cast<int>(3)) { return ((x * x) * x); }
|
||||
else if(p == static_cast<int>(4)) { const float128_t x2 = (x * x); return (x2 * x2); }
|
||||
if (p == static_cast<int>(2))
|
||||
{
|
||||
return (x * x);
|
||||
}
|
||||
else if (p == static_cast<int>(3))
|
||||
{
|
||||
return ((x * x) * x);
|
||||
}
|
||||
else if (p == static_cast<int>(4))
|
||||
{
|
||||
const float128_t x2 = (x * x);
|
||||
return (x2 * x2);
|
||||
}
|
||||
else
|
||||
{
|
||||
// The variable xn stores the binary powers of x.
|
||||
@ -403,7 +494,8 @@ class TFloat128
|
||||
++p;
|
||||
}
|
||||
|
||||
const bool isnan = ((std::strcmp(p, "nan") == 0) || (std::strcmp(p, "NaN") == 0) || (std::strcmp(p, "NAN") == 0));
|
||||
const bool isnan =
|
||||
((std::strcmp(p, "nan") == 0) || (std::strcmp(p, "NaN") == 0) || (std::strcmp(p, "NAN") == 0));
|
||||
|
||||
if (isnan)
|
||||
{
|
||||
@ -415,7 +507,8 @@ class TFloat128
|
||||
return value;
|
||||
}
|
||||
|
||||
const bool isinf = ((std::strcmp(p, "inf") == 0) || (std::strcmp(p, "Inf") == 0) || (std::strcmp(p, "INF") == 0));
|
||||
const bool isinf =
|
||||
((std::strcmp(p, "inf") == 0) || (std::strcmp(p, "Inf") == 0) || (std::strcmp(p, "INF") == 0));
|
||||
|
||||
if (isinf)
|
||||
{
|
||||
@ -624,11 +717,11 @@ class TFloat128
|
||||
|
||||
return static_cast<long double>(value);
|
||||
}
|
||||
|
||||
private:
|
||||
float128_t value;
|
||||
};
|
||||
|
||||
} //end of namespace
|
||||
} // namespace datatypes
|
||||
|
||||
// vim:ts=2 sw=2:
|
||||
|
||||
|
@ -24,9 +24,7 @@
|
||||
|
||||
namespace datatypes
|
||||
{
|
||||
uint8_t TSInt128::printPodParts(char* buf,
|
||||
const int128_t& high,
|
||||
const int128_t& mid,
|
||||
uint8_t TSInt128::printPodParts(char* buf, const int128_t& high, const int128_t& mid,
|
||||
const int128_t& low) const
|
||||
{
|
||||
char* p = buf;
|
||||
@ -54,9 +52,7 @@ namespace datatypes
|
||||
}
|
||||
|
||||
// This method writes unsigned integer representation of TSInt128
|
||||
uint8_t TSInt128::writeIntPart(const int128_t& x,
|
||||
char* buf,
|
||||
const uint8_t buflen) const
|
||||
uint8_t TSInt128::writeIntPart(const int128_t& x, char* buf, const uint8_t buflen) const
|
||||
{
|
||||
char* p = buf;
|
||||
int128_t high = 0, mid = 0, low = 0;
|
||||
@ -71,8 +67,7 @@ namespace datatypes
|
||||
uint8_t written = p - buf;
|
||||
if (buflen <= written)
|
||||
{
|
||||
throw logging::QueryDataExcept("TSInt128::writeIntPart() char buffer overflow.",
|
||||
logging::formatErr);
|
||||
throw logging::QueryDataExcept("TSInt128::writeIntPart() char buffer overflow.", logging::formatErr);
|
||||
}
|
||||
|
||||
return written;
|
||||
|
@ -27,100 +27,73 @@
|
||||
|
||||
// Inline asm has three argument lists: output, input and clobber list
|
||||
#ifdef __aarch64__
|
||||
#define MACRO_VALUE_PTR_128(dst, \
|
||||
dst_restrictions, \
|
||||
src, \
|
||||
src_restrictions, \
|
||||
clobb) \
|
||||
#define MACRO_VALUE_PTR_128(dst, dst_restrictions, src, src_restrictions, clobb) \
|
||||
::memcpy((dst), &(src), sizeof(int128_t));
|
||||
#define MACRO_PTR_PTR_128(dst, \
|
||||
dst_restrictions, \
|
||||
src, \
|
||||
src_restrictions, \
|
||||
clobb) \
|
||||
#define MACRO_PTR_PTR_128(dst, dst_restrictions, src, src_restrictions, clobb) \
|
||||
::memcpy((dst), (src), sizeof(int128_t));
|
||||
#elif defined(__GNUC__) && (__GNUC___ > 7) || defined(__clang__)
|
||||
#define MACRO_VALUE_PTR_128(dst, \
|
||||
dst_restrictions, \
|
||||
src, \
|
||||
src_restrictions, \
|
||||
clobb) \
|
||||
__asm__ volatile("movups %1,%0" \
|
||||
:dst_restrictions ( *(dst) ) \
|
||||
:src_restrictions ( (src) ) \
|
||||
:clobb \
|
||||
);
|
||||
#define MACRO_PTR_PTR_128(dst, \
|
||||
dst_restrictions, \
|
||||
src, \
|
||||
src_restrictions, \
|
||||
clobb) \
|
||||
#define MACRO_VALUE_PTR_128(dst, dst_restrictions, src, src_restrictions, clobb) \
|
||||
__asm__ volatile("movups %1,%0" : dst_restrictions(*(dst)) : src_restrictions((src)) : clobb);
|
||||
#define MACRO_PTR_PTR_128(dst, dst_restrictions, src, src_restrictions, clobb) \
|
||||
::memcpy((dst), (src), sizeof(int128_t));
|
||||
|
||||
#else
|
||||
#define MACRO_VALUE_PTR_128(dst, \
|
||||
dst_restrictions, \
|
||||
src, \
|
||||
src_restrictions, \
|
||||
clobb) \
|
||||
__asm__ volatile("movups %1,%0" \
|
||||
:dst_restrictions ( *(dst) ) \
|
||||
:src_restrictions ( (src) ) \
|
||||
:clobb \
|
||||
);
|
||||
#define MACRO_PTR_PTR_128(dst, \
|
||||
dst_restrictions, \
|
||||
src, \
|
||||
src_restrictions, \
|
||||
clobb) \
|
||||
__asm__ volatile("movdqu %1,%%xmm0;" \
|
||||
#define MACRO_VALUE_PTR_128(dst, dst_restrictions, src, src_restrictions, clobb) \
|
||||
__asm__ volatile("movups %1,%0" : dst_restrictions(*(dst)) : src_restrictions((src)) : clobb);
|
||||
#define MACRO_PTR_PTR_128(dst, dst_restrictions, src, src_restrictions, clobb) \
|
||||
__asm__ volatile( \
|
||||
"movdqu %1,%%xmm0;" \
|
||||
"movups %%xmm0,%0;" \
|
||||
: dst_restrictions(*(dst)) \
|
||||
: src_restrictions(*(src)) \
|
||||
:"memory", clobb \
|
||||
);
|
||||
: "memory", clobb);
|
||||
#endif
|
||||
|
||||
namespace datatypes
|
||||
{
|
||||
|
||||
using int128_t = __int128;
|
||||
using uint128_t = unsigned __int128;
|
||||
|
||||
|
||||
// Type traits
|
||||
template <typename T>
|
||||
struct is_allowed_numeric {
|
||||
struct is_allowed_numeric
|
||||
{
|
||||
static const bool value = false;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct is_allowed_numeric<int> {
|
||||
struct is_allowed_numeric<int>
|
||||
{
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct is_allowed_numeric<int128_t> {
|
||||
struct is_allowed_numeric<int128_t>
|
||||
{
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct is_int128_t {
|
||||
struct is_int128_t
|
||||
{
|
||||
static const bool value = false;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct is_int128_t<int128_t> {
|
||||
struct is_int128_t<int128_t>
|
||||
{
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct is_uint128_t {
|
||||
struct is_uint128_t
|
||||
{
|
||||
static const bool value = false;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct is_uint128_t<uint128_t> {
|
||||
struct is_uint128_t<uint128_t>
|
||||
{
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
@ -137,10 +110,14 @@ class TSInt128
|
||||
static constexpr int128_t EmptyValue = (int128_t(0x8000000000000000LL) << 64) + 1;
|
||||
|
||||
// A variety of ctors for aligned and unaligned arguments
|
||||
TSInt128(): s128Value(0) { }
|
||||
TSInt128() : s128Value(0)
|
||||
{
|
||||
}
|
||||
|
||||
// Copy ctor
|
||||
TSInt128(const TSInt128& other): s128Value(other.s128Value) { }
|
||||
TSInt128(const TSInt128& other) : s128Value(other.s128Value)
|
||||
{
|
||||
}
|
||||
|
||||
TSInt128& operator=(const TSInt128& other)
|
||||
{
|
||||
@ -149,13 +126,22 @@ class TSInt128
|
||||
}
|
||||
|
||||
// aligned argument
|
||||
explicit TSInt128(const int128_t& x) { s128Value = x; }
|
||||
explicit TSInt128(const int128_t& x)
|
||||
{
|
||||
s128Value = x;
|
||||
}
|
||||
|
||||
// unaligned argument
|
||||
explicit TSInt128(const int128_t* x) { assignPtrPtr(&s128Value, x); }
|
||||
explicit TSInt128(const int128_t* x)
|
||||
{
|
||||
assignPtrPtr(&s128Value, x);
|
||||
}
|
||||
|
||||
// unaligned argument
|
||||
explicit TSInt128(const unsigned char* x) { assignPtrPtr(&s128Value, x); }
|
||||
explicit TSInt128(const unsigned char* x)
|
||||
{
|
||||
assignPtrPtr(&s128Value, x);
|
||||
}
|
||||
|
||||
// Method returns max length of a string representation
|
||||
static constexpr uint8_t maxLength()
|
||||
@ -191,15 +177,13 @@ class TSInt128
|
||||
}
|
||||
|
||||
// operators
|
||||
template<typename T,
|
||||
typename = std::enable_if<is_allowed_numeric<T>::value> >
|
||||
template <typename T, typename = std::enable_if<is_allowed_numeric<T>::value> >
|
||||
inline bool operator<(const T& x) const
|
||||
{
|
||||
return s128Value < static_cast<int128_t>(x);
|
||||
}
|
||||
|
||||
template<typename T,
|
||||
typename = std::enable_if<is_allowed_numeric<T>::value> >
|
||||
template <typename T, typename = std::enable_if<is_allowed_numeric<T>::value> >
|
||||
inline bool operator==(const T& x) const
|
||||
{
|
||||
return s128Value == static_cast<int128_t>(x);
|
||||
@ -323,15 +307,10 @@ class TSInt128
|
||||
}
|
||||
|
||||
// print int128_t parts represented as PODs
|
||||
uint8_t printPodParts(char* buf,
|
||||
const int128_t& high,
|
||||
const int128_t& mid,
|
||||
const int128_t& low) const;
|
||||
uint8_t printPodParts(char* buf, const int128_t& high, const int128_t& mid, const int128_t& low) const;
|
||||
|
||||
// writes integer part of dec into a buffer
|
||||
uint8_t writeIntPart(const int128_t& x,
|
||||
char* buf,
|
||||
const uint8_t buflen) const;
|
||||
uint8_t writeIntPart(const int128_t& x, char* buf, const uint8_t buflen) const;
|
||||
|
||||
// string representation of TSInt128
|
||||
std::string toString() const;
|
||||
@ -341,7 +320,6 @@ class TSInt128
|
||||
int128_t s128Value;
|
||||
}; // end of class
|
||||
|
||||
|
||||
} // end of namespace datatypes
|
||||
|
||||
// vim:ts=2 sw=2:
|
||||
|
@ -22,29 +22,34 @@
|
||||
|
||||
namespace datatypes
|
||||
{
|
||||
|
||||
|
||||
class TNullFlag
|
||||
{
|
||||
protected:
|
||||
bool mIsNull;
|
||||
|
||||
public:
|
||||
explicit TNullFlag(bool val) :mIsNull(val) { }
|
||||
explicit TNullFlag(bool val) : mIsNull(val)
|
||||
{
|
||||
}
|
||||
bool isNull() const
|
||||
{
|
||||
return mIsNull;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class TUInt64
|
||||
{
|
||||
protected:
|
||||
uint64_t mValue;
|
||||
public:
|
||||
TUInt64(): mValue(0) { }
|
||||
|
||||
explicit TUInt64(uint64_t value): mValue(value) { }
|
||||
public:
|
||||
TUInt64() : mValue(0)
|
||||
{
|
||||
}
|
||||
|
||||
explicit TUInt64(uint64_t value) : mValue(value)
|
||||
{
|
||||
}
|
||||
|
||||
explicit operator uint64_t() const
|
||||
{
|
||||
@ -57,15 +62,19 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class TSInt64
|
||||
{
|
||||
protected:
|
||||
int64_t mValue;
|
||||
public:
|
||||
TSInt64(): mValue(0) { }
|
||||
|
||||
explicit TSInt64(int64_t value): mValue(value) { }
|
||||
public:
|
||||
TSInt64() : mValue(0)
|
||||
{
|
||||
}
|
||||
|
||||
explicit TSInt64(int64_t value) : mValue(value)
|
||||
{
|
||||
}
|
||||
|
||||
explicit operator int64_t() const
|
||||
{
|
||||
@ -77,17 +86,16 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
class TUInt64Null : public TUInt64, public TNullFlag
|
||||
{
|
||||
public:
|
||||
TUInt64Null() : TNullFlag(true)
|
||||
{
|
||||
}
|
||||
|
||||
TUInt64Null(): TNullFlag(true) { }
|
||||
|
||||
explicit TUInt64Null(uint64_t value, bool isNull = false):
|
||||
TUInt64(value), TNullFlag(isNull)
|
||||
{ }
|
||||
explicit TUInt64Null(uint64_t value, bool isNull = false) : TUInt64(value), TNullFlag(isNull)
|
||||
{
|
||||
}
|
||||
|
||||
explicit operator uint64_t() const
|
||||
{
|
||||
@ -121,16 +129,16 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class TSInt64Null : public TSInt64, public TNullFlag
|
||||
{
|
||||
public:
|
||||
TSInt64Null() : TNullFlag(true)
|
||||
{
|
||||
}
|
||||
|
||||
TSInt64Null(): TNullFlag(true) { }
|
||||
|
||||
explicit TSInt64Null(int64_t value, bool isNull = false):
|
||||
TSInt64(value), TNullFlag(isNull)
|
||||
{ }
|
||||
explicit TSInt64Null(int64_t value, bool isNull = false) : TSInt64(value), TNullFlag(isNull)
|
||||
{
|
||||
}
|
||||
|
||||
explicit operator int64_t() const
|
||||
{
|
||||
@ -169,7 +177,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // end of namespace datatypes
|
||||
|
||||
// vim:ts=2 sw=2:
|
||||
|
@ -22,15 +22,19 @@
|
||||
|
||||
namespace datatypes
|
||||
{
|
||||
|
||||
class TLongDouble
|
||||
{
|
||||
protected:
|
||||
long double mValue;
|
||||
public:
|
||||
TLongDouble(): mValue(0) { }
|
||||
|
||||
explicit TLongDouble(long double value): mValue(value) { }
|
||||
public:
|
||||
TLongDouble() : mValue(0)
|
||||
{
|
||||
}
|
||||
|
||||
explicit TLongDouble(long double value) : mValue(value)
|
||||
{
|
||||
}
|
||||
|
||||
explicit operator long double() const
|
||||
{
|
||||
@ -48,7 +52,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // end of namespace datatypes
|
||||
|
||||
// vim:ts=2 sw=2:
|
||||
|
@ -21,18 +21,24 @@
|
||||
|
||||
namespace datatypes
|
||||
{
|
||||
|
||||
template <typename T>
|
||||
struct numeric_limits
|
||||
{
|
||||
static constexpr T min() { return std::numeric_limits<T>::min(); }
|
||||
static constexpr T max() { return std::numeric_limits<T>::max(); }
|
||||
static constexpr T min()
|
||||
{
|
||||
return std::numeric_limits<T>::min();
|
||||
}
|
||||
static constexpr T max()
|
||||
{
|
||||
return std::numeric_limits<T>::max();
|
||||
}
|
||||
};
|
||||
|
||||
using int128_t = __int128;
|
||||
using uint128_t = unsigned __int128;
|
||||
|
||||
template<> struct numeric_limits<int128_t>
|
||||
template <>
|
||||
struct numeric_limits<int128_t>
|
||||
{
|
||||
static constexpr int128_t min()
|
||||
{
|
||||
@ -44,7 +50,8 @@ template<> struct numeric_limits<int128_t>
|
||||
}
|
||||
};
|
||||
|
||||
template<> struct numeric_limits<uint128_t>
|
||||
template <>
|
||||
struct numeric_limits<uint128_t>
|
||||
{
|
||||
static constexpr uint128_t min()
|
||||
{
|
||||
@ -57,4 +64,3 @@ template<> struct numeric_limits<uint128_t>
|
||||
};
|
||||
|
||||
} // namespace datatypes
|
||||
|
||||
|
@ -15,7 +15,6 @@
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "conststring.h"
|
||||
@ -23,14 +22,14 @@
|
||||
|
||||
namespace datatypes
|
||||
{
|
||||
|
||||
class TCharShort
|
||||
{
|
||||
int64_t mValue;
|
||||
|
||||
public:
|
||||
TCharShort(int64_t value)
|
||||
:mValue(value)
|
||||
{ }
|
||||
TCharShort(int64_t value) : mValue(value)
|
||||
{
|
||||
}
|
||||
utils::ConstString toConstString(uint32_t width) const
|
||||
{
|
||||
utils::ConstString res = utils::ConstString((const char*)&mValue, width);
|
||||
@ -40,12 +39,8 @@ public:
|
||||
{
|
||||
datatypes::TCharShort sa(a);
|
||||
datatypes::TCharShort sb(b);
|
||||
return cs.strnncollsp(sa.toConstString(width),
|
||||
sb.toConstString(width));
|
||||
return cs.strnncollsp(sa.toConstString(width), sb.toConstString(width));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // namespace datatypes
|
||||
|
||||
|
||||
|
@ -15,32 +15,25 @@
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "genericparser.h"
|
||||
#include "mcs_datatype.h"
|
||||
|
||||
|
||||
namespace literal
|
||||
{
|
||||
|
||||
using utils::ConstString;
|
||||
using genericparser::Parser;
|
||||
using datatypes::DataCondition;
|
||||
using genericparser::Parser;
|
||||
using utils::ConstString;
|
||||
|
||||
typedef uint32_t scale_t;
|
||||
|
||||
|
||||
|
||||
template <class A>
|
||||
class Converter: public Parser,
|
||||
public A
|
||||
class Converter : public Parser, public A
|
||||
{
|
||||
public:
|
||||
Converter(const char* str, size_t length, DataCondition& error)
|
||||
:Parser(str, length),
|
||||
A(&Parser::skipLeadingSpaces())
|
||||
: Parser(str, length), A(&Parser::skipLeadingSpaces())
|
||||
{
|
||||
if (Parser::syntaxError())
|
||||
{
|
||||
@ -59,12 +52,11 @@ public:
|
||||
error |= (DataCondition::X_INVALID_CHARACTER_VALUE_FOR_CAST);
|
||||
}
|
||||
}
|
||||
Converter(const std::string & str, DataCondition &error)
|
||||
:Converter(str.data(), str.length(), error)
|
||||
{ }
|
||||
Converter(const std::string& str, DataCondition& error) : Converter(str.data(), str.length(), error)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
|
||||
SQL Standard definition for <cast specification>
|
||||
@ -143,7 +135,6 @@ Grammar
|
||||
|
||||
*/
|
||||
|
||||
|
||||
//
|
||||
// Terminal symbols
|
||||
//
|
||||
@ -151,58 +142,72 @@ Grammar
|
||||
class Period : public ConstString
|
||||
{
|
||||
public:
|
||||
explicit Period(Parser *p)
|
||||
:ConstString(p->tokenChar('.'))
|
||||
{ }
|
||||
bool isNull() const { return mStr == nullptr; }
|
||||
explicit Period(Parser* p) : ConstString(p->tokenChar('.'))
|
||||
{
|
||||
}
|
||||
bool isNull() const
|
||||
{
|
||||
return mStr == nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class ExponentMarker : public ConstString
|
||||
{
|
||||
public:
|
||||
explicit ExponentMarker(Parser *p)
|
||||
:ConstString(p->tokenAnyCharOf('e', 'E'))
|
||||
{ }
|
||||
bool isNull() const { return mStr == nullptr; }
|
||||
explicit ExponentMarker(Parser* p) : ConstString(p->tokenAnyCharOf('e', 'E'))
|
||||
{
|
||||
}
|
||||
bool isNull() const
|
||||
{
|
||||
return mStr == nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class Sign : public ConstString
|
||||
{
|
||||
public:
|
||||
explicit Sign(): ConstString(NULL, 0) { }
|
||||
explicit Sign(const ConstString &str)
|
||||
:ConstString(str)
|
||||
{ }
|
||||
explicit Sign(Parser *p)
|
||||
:ConstString(p->tokenAnyCharOf('+', '-'))
|
||||
{ }
|
||||
explicit Sign() : ConstString(NULL, 0)
|
||||
{
|
||||
}
|
||||
explicit Sign(const ConstString& str) : ConstString(str)
|
||||
{
|
||||
}
|
||||
explicit Sign(Parser* p) : ConstString(p->tokenAnyCharOf('+', '-'))
|
||||
{
|
||||
}
|
||||
static Sign empty(Parser* p)
|
||||
{
|
||||
return Sign(p->tokStartConstString());
|
||||
}
|
||||
bool isNull() const { return mStr == nullptr; }
|
||||
bool negative() const { return eq('-'); }
|
||||
bool isNull() const
|
||||
{
|
||||
return mStr == nullptr;
|
||||
}
|
||||
bool negative() const
|
||||
{
|
||||
return eq('-');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class Digits : public ConstString
|
||||
{
|
||||
public:
|
||||
explicit Digits()
|
||||
:ConstString(NULL, 0)
|
||||
{ }
|
||||
explicit Digits(const char *str, size_t length)
|
||||
:ConstString(str, length)
|
||||
{ }
|
||||
explicit Digits(const ConstString &str)
|
||||
:ConstString(str)
|
||||
{ }
|
||||
explicit Digits(Parser *p)
|
||||
:ConstString(p->tokenDigits())
|
||||
{ }
|
||||
bool isNull() const { return mStr == nullptr; }
|
||||
explicit Digits() : ConstString(NULL, 0)
|
||||
{
|
||||
}
|
||||
explicit Digits(const char* str, size_t length) : ConstString(str, length)
|
||||
{
|
||||
}
|
||||
explicit Digits(const ConstString& str) : ConstString(str)
|
||||
{
|
||||
}
|
||||
explicit Digits(Parser* p) : ConstString(p->tokenDigits())
|
||||
{
|
||||
}
|
||||
bool isNull() const
|
||||
{
|
||||
return mStr == nullptr;
|
||||
}
|
||||
|
||||
void skipLeadingZeroDigits()
|
||||
{
|
||||
@ -219,7 +224,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Non-terminal symbols
|
||||
//
|
||||
@ -228,18 +232,18 @@ public:
|
||||
class UnsignedInteger : public Digits
|
||||
{
|
||||
public:
|
||||
explicit UnsignedInteger()
|
||||
:Digits()
|
||||
{ }
|
||||
explicit UnsignedInteger(const char *str, size_t length)
|
||||
:Digits(str, length)
|
||||
{ }
|
||||
explicit UnsignedInteger(const ConstString &str)
|
||||
:Digits(str)
|
||||
{ }
|
||||
explicit UnsignedInteger(Parser *p)
|
||||
:Digits(p)
|
||||
{ }
|
||||
explicit UnsignedInteger() : Digits()
|
||||
{
|
||||
}
|
||||
explicit UnsignedInteger(const char* str, size_t length) : Digits(str, length)
|
||||
{
|
||||
}
|
||||
explicit UnsignedInteger(const ConstString& str) : Digits(str)
|
||||
{
|
||||
}
|
||||
explicit UnsignedInteger(Parser* p) : Digits(p)
|
||||
{
|
||||
}
|
||||
static UnsignedInteger empty(const Parser* p)
|
||||
{
|
||||
return UnsignedInteger(p->tokStartConstString());
|
||||
@ -327,28 +331,29 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// <signed integer> := [<sign>] <unsigned integer>
|
||||
class SignedInteger : public Parser::DD2OM<Sign, UnsignedInteger>
|
||||
{
|
||||
public:
|
||||
using DD2OM::DD2OM;
|
||||
bool isNull() const { return UnsignedInteger::isNull(); }
|
||||
bool isNull() const
|
||||
{
|
||||
return UnsignedInteger::isNull();
|
||||
}
|
||||
|
||||
template<typename T> T abs(DataCondition & error) const
|
||||
template <typename T>
|
||||
T abs(DataCondition& error) const
|
||||
{
|
||||
return toXIntPositive<T>(error);
|
||||
}
|
||||
|
||||
template<typename T> T toSInt(DataCondition & error) const
|
||||
template <typename T>
|
||||
T toSInt(DataCondition& error) const
|
||||
{
|
||||
return negative() ?
|
||||
toSIntNegative<T>(error) :
|
||||
toXIntPositive<T>(error);
|
||||
return negative() ? toSIntNegative<T>(error) : toXIntPositive<T>(error);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// E <signed integer>
|
||||
class EExponent : public Parser::UD2MM<ExponentMarker, SignedInteger>
|
||||
{
|
||||
@ -356,7 +361,6 @@ public:
|
||||
using UD2MM::UD2MM;
|
||||
};
|
||||
|
||||
|
||||
// <period> <unsigned integer>
|
||||
class ExactUnsignedNumericLiteralFractionAlone : public Parser::UD2MM<Period, UnsignedInteger>
|
||||
{
|
||||
@ -364,7 +368,6 @@ public:
|
||||
using UD2MM::UD2MM;
|
||||
};
|
||||
|
||||
|
||||
// <period> [ <unsigned integer> ]
|
||||
class PeriodOptUnsignedInteger : public Parser::UD2MO<Period, UnsignedInteger>
|
||||
{
|
||||
@ -380,51 +383,47 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// <integral unsigned integer> := <unsigned integer>
|
||||
class IntegralUnsignedInteger : public UnsignedInteger
|
||||
{
|
||||
public:
|
||||
explicit IntegralUnsignedInteger(Parser *p)
|
||||
:UnsignedInteger(p)
|
||||
{ }
|
||||
explicit IntegralUnsignedInteger(Parser* p) : UnsignedInteger(p)
|
||||
{
|
||||
}
|
||||
const UnsignedInteger& integral() const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// <integral unsigned integer> [ <period> [ <unsigned integer> ] ]
|
||||
|
||||
class ExactUnsignedNumericLiteralIntegralOptFraction:
|
||||
public Parser::DD2MO<IntegralUnsignedInteger,
|
||||
PeriodOptUnsignedInteger>
|
||||
class ExactUnsignedNumericLiteralIntegralOptFraction
|
||||
: public Parser::DD2MO<IntegralUnsignedInteger, PeriodOptUnsignedInteger>
|
||||
{
|
||||
public:
|
||||
using DD2MO::DD2MO;
|
||||
};
|
||||
|
||||
|
||||
// A container for integral and fractional parts
|
||||
class UnsignedIntegerDecimal
|
||||
{
|
||||
protected:
|
||||
UnsignedInteger mIntegral;
|
||||
UnsignedInteger mFraction;
|
||||
|
||||
public:
|
||||
explicit UnsignedIntegerDecimal(const UnsignedInteger &intg,
|
||||
const UnsignedInteger &frac)
|
||||
:mIntegral(intg),
|
||||
mFraction(frac)
|
||||
{ }
|
||||
explicit UnsignedIntegerDecimal(const ExactUnsignedNumericLiteralFractionAlone &rhs)
|
||||
:mFraction(rhs)
|
||||
{ }
|
||||
explicit UnsignedIntegerDecimal(const UnsignedInteger& intg, const UnsignedInteger& frac)
|
||||
: mIntegral(intg), mFraction(frac)
|
||||
{
|
||||
}
|
||||
explicit UnsignedIntegerDecimal(const ExactUnsignedNumericLiteralFractionAlone& rhs) : mFraction(rhs)
|
||||
{
|
||||
}
|
||||
explicit UnsignedIntegerDecimal(const ExactUnsignedNumericLiteralIntegralOptFraction& rhs)
|
||||
:mIntegral(rhs.integral()),
|
||||
mFraction(rhs.fraction())
|
||||
{ }
|
||||
: mIntegral(rhs.integral()), mFraction(rhs.fraction())
|
||||
{
|
||||
}
|
||||
|
||||
size_t IntFracDigits() const
|
||||
{
|
||||
@ -442,19 +441,22 @@ public:
|
||||
mFraction.skipTrailingZeroDigits();
|
||||
}
|
||||
|
||||
template<typename T> T toXIntPositive(DataCondition & error) const
|
||||
template <typename T>
|
||||
T toXIntPositive(DataCondition& error) const
|
||||
{
|
||||
T val = mIntegral.toXIntPositive<T>(error);
|
||||
return mFraction.toXIntPositiveContinue<T>(val, error);
|
||||
}
|
||||
|
||||
template<typename T> T toXIntPositiveRoundAwayFromZero(bool roundUp, DataCondition & error) const
|
||||
template <typename T>
|
||||
T toXIntPositiveRoundAwayFromZero(bool roundUp, DataCondition& error) const
|
||||
{
|
||||
T val = mIntegral.toXIntPositive<T>(error);
|
||||
return mFraction.toXIntPositiveRoundAwayFromZeroContinue<T>(val, roundUp, error);
|
||||
}
|
||||
|
||||
template<typename T> T toXIntPositiveScaleUp(size_t scale, DataCondition & error) const
|
||||
template <typename T>
|
||||
T toXIntPositiveScaleUp(size_t scale, DataCondition& error) const
|
||||
{
|
||||
T val = toXIntPositive<T>(error);
|
||||
if (val == datatypes::numeric_limits<T>::max())
|
||||
@ -472,14 +474,15 @@ public:
|
||||
return val;
|
||||
}
|
||||
|
||||
template<typename T> T toXIntPositiveRound(DataCondition & error) const
|
||||
template <typename T>
|
||||
T toXIntPositiveRound(DataCondition& error) const
|
||||
{
|
||||
bool roundUp = mFraction.length() && mFraction.str()[0] >= '5';
|
||||
return mIntegral.toXIntPositiveRoundAwayFromZero<T>(roundUp, error);
|
||||
}
|
||||
|
||||
template<typename T> T toXIntPositiveRoundExp(uint64_t absExp, bool negExp,
|
||||
DataCondition & error) const
|
||||
template <typename T>
|
||||
T toXIntPositiveRoundExp(uint64_t absExp, bool negExp, DataCondition& error) const
|
||||
{
|
||||
if (absExp == 0)
|
||||
return toXIntPositiveRound<T>(error);
|
||||
@ -509,24 +512,20 @@ public:
|
||||
size_t diff = absExp - mFraction.length();
|
||||
return toXIntPositiveScaleUp<T>(diff, error);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
// <exact unsigned numeric literal> :=
|
||||
// <period> [ <unsigned integer> ]
|
||||
// | <unsigned integer> [ <period> [ <unsigned integer> ] ]
|
||||
|
||||
class ExactUnsignedNumericLiteral:
|
||||
public Parser::Choice2<UnsignedIntegerDecimal,
|
||||
ExactUnsignedNumericLiteralFractionAlone,
|
||||
class ExactUnsignedNumericLiteral
|
||||
: public Parser::Choice2<UnsignedIntegerDecimal, ExactUnsignedNumericLiteralFractionAlone,
|
||||
ExactUnsignedNumericLiteralIntegralOptFraction>
|
||||
{
|
||||
public:
|
||||
using Choice2::Choice2;
|
||||
};
|
||||
|
||||
|
||||
// <unsigned numeric literal> ::= <exact numeric literal> [ E <exponent> ]
|
||||
|
||||
class UnsignedNumericLiteral : public Parser::DM2MO<ExactUnsignedNumericLiteral, EExponent>
|
||||
@ -570,16 +569,17 @@ public:
|
||||
}
|
||||
return ExactUnsignedNumericLiteral::toXIntPositiveRoundExp<T>((uint64_t)exp, false, error);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
// <signed numeric literal> ::= [ <sign> ] <unsigned numeric literal>
|
||||
class SignedNumericLiteral : public Parser::DD2OM<Sign, UnsignedNumericLiteral>
|
||||
{
|
||||
public:
|
||||
using DD2OM::DD2OM;
|
||||
bool isNull() const { return UnsignedNumericLiteral::isNull(); }
|
||||
bool isNull() const
|
||||
{
|
||||
return UnsignedNumericLiteral::isNull();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T toUIntXRound() const
|
||||
@ -613,6 +613,4 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // namespace literal
|
||||
|
||||
|
@ -29,9 +29,8 @@ namespace ddlpackage
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
AlterTableStatement::AlterTableStatement(QualifiedName* qName, AlterTableActionList* ataList):
|
||||
fTableName(qName),
|
||||
fActions(*ataList)
|
||||
AlterTableStatement::AlterTableStatement(QualifiedName* qName, AlterTableActionList* ataList)
|
||||
: fTableName(qName), fActions(*ataList)
|
||||
{
|
||||
delete ataList;
|
||||
}
|
||||
@ -60,8 +59,6 @@ std::ostream& AlterTableStatement::put(std::ostream& os) const
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** @brief Format to ostream. Diagnostic. */
|
||||
std::ostream& AlterTableAction::put(std::ostream& os) const
|
||||
{
|
||||
@ -76,13 +73,11 @@ std::ostream& operator<<(std::ostream& os, const AlterTableAction& ata)
|
||||
return ata.put(os);
|
||||
}
|
||||
|
||||
|
||||
AtaAddColumn::~AtaAddColumn()
|
||||
{
|
||||
delete fColumnDef;
|
||||
}
|
||||
|
||||
|
||||
/** @brief ostream output */
|
||||
std::ostream& AtaAddColumn::put(std::ostream& os) const
|
||||
{
|
||||
@ -91,22 +86,17 @@ std::ostream& AtaAddColumn::put(std::ostream& os) const
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
|
||||
AtaDropColumn::AtaDropColumn(std::string columnName, DDL_REFERENTIAL_ACTION dropBehavior) :
|
||||
fColumnName(columnName),
|
||||
fDropBehavior(dropBehavior)
|
||||
AtaDropColumn::AtaDropColumn(std::string columnName, DDL_REFERENTIAL_ACTION dropBehavior)
|
||||
: fColumnName(columnName), fDropBehavior(dropBehavior)
|
||||
{
|
||||
}
|
||||
|
||||
std::ostream& AtaDropColumn::put(std::ostream& os) const
|
||||
{
|
||||
os << "Drop Column: " << fColumnName << " "
|
||||
<< ReferentialActionStrings[fDropBehavior];
|
||||
os << "Drop Column: " << fColumnName << " " << ReferentialActionStrings[fDropBehavior];
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
AtaModifyColumnType::~AtaModifyColumnType()
|
||||
{
|
||||
delete fColumnType;
|
||||
@ -119,8 +109,6 @@ std::ostream& AtaModifyColumnType::put(std::ostream& os) const
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
|
||||
AtaRenameColumn::~AtaRenameColumn()
|
||||
{
|
||||
delete fNewType;
|
||||
@ -132,33 +120,23 @@ std::ostream& AtaRenameColumn::put(std::ostream& os) const
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
|
||||
AtaSetColumnDefault::AtaSetColumnDefault(const char* colName, ColumnDefaultValue* defaultValue) :
|
||||
fColumnName(colName),
|
||||
fDefaultValue(defaultValue)
|
||||
AtaSetColumnDefault::AtaSetColumnDefault(const char* colName, ColumnDefaultValue* defaultValue)
|
||||
: fColumnName(colName), fDefaultValue(defaultValue)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
AtaSetColumnDefault::~AtaSetColumnDefault()
|
||||
{
|
||||
delete fDefaultValue;
|
||||
}
|
||||
|
||||
|
||||
std::ostream& AtaSetColumnDefault::put(std::ostream& os) const
|
||||
{
|
||||
os << "Set Column Default: " << fColumnName << " "
|
||||
<< *fDefaultValue << endl;
|
||||
os << "Set Column Default: " << fColumnName << " " << *fDefaultValue << endl;
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
AtaDropColumnDefault::AtaDropColumnDefault(const char* colName) :
|
||||
fColumnName(colName)
|
||||
AtaDropColumnDefault::AtaDropColumnDefault(const char* colName) : fColumnName(colName)
|
||||
{
|
||||
}
|
||||
|
||||
@ -168,11 +146,7 @@ std::ostream& AtaDropColumnDefault::put(std::ostream& os) const
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
AtaRenameTable::AtaRenameTable(QualifiedName* qualifiedName) :
|
||||
fQualifiedName(qualifiedName)
|
||||
AtaRenameTable::AtaRenameTable(QualifiedName* qualifiedName) : fQualifiedName(qualifiedName)
|
||||
{
|
||||
}
|
||||
|
||||
@ -181,17 +155,13 @@ AtaRenameTable::~AtaRenameTable()
|
||||
delete fQualifiedName;
|
||||
}
|
||||
|
||||
|
||||
std::ostream& AtaRenameTable::put(std::ostream& os) const
|
||||
{
|
||||
os << "Rename Table: " << *fQualifiedName << endl;
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
|
||||
AtaTableComment::AtaTableComment(const char* tableComment) :
|
||||
fTableComment(tableComment)
|
||||
AtaTableComment::AtaTableComment(const char* tableComment) : fTableComment(tableComment)
|
||||
{
|
||||
}
|
||||
|
||||
@ -199,14 +169,12 @@ AtaTableComment::~AtaTableComment()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
std::ostream& AtaTableComment::put(std::ostream& os) const
|
||||
{
|
||||
os << "TableComment: " << fTableComment << endl;
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
AtaAddColumns::~AtaAddColumns()
|
||||
{
|
||||
ColumnDefList::iterator itr;
|
||||
@ -215,7 +183,6 @@ AtaAddColumns::~AtaAddColumns()
|
||||
delete *itr;
|
||||
}
|
||||
|
||||
|
||||
AtaAddColumns::AtaAddColumns(TableElementList* tableElements)
|
||||
{
|
||||
/* It is convenient to reuse the grammar rules for
|
||||
@ -226,9 +193,7 @@ AtaAddColumns::AtaAddColumns(TableElementList* tableElements)
|
||||
ColumnDef* column;
|
||||
TableElementList::const_iterator itr;
|
||||
|
||||
for (itr = tableElements->begin();
|
||||
itr != tableElements->end();
|
||||
++itr)
|
||||
for (itr = tableElements->begin(); itr != tableElements->end(); ++itr)
|
||||
{
|
||||
column = dynamic_cast<ColumnDef*>(*itr);
|
||||
|
||||
@ -246,9 +211,7 @@ std::ostream& AtaAddColumns::put(std::ostream& os) const
|
||||
os << "Add Columns: " << endl;
|
||||
ColumnDefList::const_iterator itr;
|
||||
|
||||
for (itr = fColumns.begin();
|
||||
itr != fColumns.end();
|
||||
++itr)
|
||||
for (itr = fColumns.begin(); itr != fColumns.end(); ++itr)
|
||||
{
|
||||
os << **itr << endl;
|
||||
}
|
||||
@ -261,7 +224,6 @@ AtaDropColumns::~AtaDropColumns()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
AtaDropColumns::AtaDropColumns(ColumnNameList* columnNames)
|
||||
{
|
||||
fColumns = *columnNames;
|
||||
@ -273,9 +235,7 @@ std::ostream& AtaDropColumns::put(std::ostream& os) const
|
||||
os << "Drop Columns: " << endl;
|
||||
ColumnNameList::const_iterator itr;
|
||||
|
||||
for (itr = fColumns.begin();
|
||||
itr != fColumns.end();
|
||||
++itr)
|
||||
for (itr = fColumns.begin(); itr != fColumns.end(); ++itr)
|
||||
{
|
||||
os << *itr << endl;
|
||||
}
|
||||
@ -283,11 +243,8 @@ std::ostream& AtaDropColumns::put(std::ostream& os) const
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
AtaAddTableConstraint::AtaAddTableConstraint(TableConstraintDef* tableConstraint) :
|
||||
fTableConstraint(tableConstraint)
|
||||
AtaAddTableConstraint::AtaAddTableConstraint(TableConstraintDef* tableConstraint)
|
||||
: fTableConstraint(tableConstraint)
|
||||
{
|
||||
}
|
||||
|
||||
@ -296,7 +253,6 @@ AtaAddTableConstraint::~AtaAddTableConstraint()
|
||||
delete fTableConstraint;
|
||||
}
|
||||
|
||||
|
||||
std::ostream& AtaAddTableConstraint::put(std::ostream& os) const
|
||||
{
|
||||
os << "Add Table Constraint:" << endl;
|
||||
@ -304,13 +260,9 @@ std::ostream& AtaAddTableConstraint::put(std::ostream& os) const
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
AtaDropTableConstraint::AtaDropTableConstraint
|
||||
(const char* constraintName, DDL_REFERENTIAL_ACTION dropBehavior) :
|
||||
fConstraintName(constraintName),
|
||||
fDropBehavior(dropBehavior)
|
||||
AtaDropTableConstraint::AtaDropTableConstraint(const char* constraintName,
|
||||
DDL_REFERENTIAL_ACTION dropBehavior)
|
||||
: fConstraintName(constraintName), fDropBehavior(dropBehavior)
|
||||
{
|
||||
}
|
||||
|
||||
@ -320,4 +272,4 @@ std::ostream& AtaDropTableConstraint::put(std::ostream& os) const
|
||||
return os;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace ddlpackage
|
||||
|
@ -30,7 +30,6 @@
|
||||
|
||||
namespace ddlpackage
|
||||
{
|
||||
|
||||
using namespace std;
|
||||
|
||||
ColumnDef::~ColumnDef()
|
||||
@ -46,10 +45,8 @@ ColumnDef::~ColumnDef()
|
||||
}
|
||||
|
||||
ColumnDef::ColumnDef(const char* name, ColumnType* columnType, ColumnConstraintList* constraints,
|
||||
ColumnDefaultValue* defaultValue, const char* comment ) :
|
||||
SchemaObject(name),
|
||||
fType(columnType),
|
||||
fDefaultValue(defaultValue)
|
||||
ColumnDefaultValue* defaultValue, const char* comment)
|
||||
: SchemaObject(name), fType(columnType), fDefaultValue(defaultValue)
|
||||
{
|
||||
if (constraints)
|
||||
{
|
||||
@ -61,20 +58,16 @@ ColumnDef::ColumnDef(const char* name, ColumnType* columnType, ColumnConstraintL
|
||||
fComment = comment;
|
||||
}
|
||||
|
||||
|
||||
ostream& operator<<(ostream& os, const ColumnType& columnType)
|
||||
{
|
||||
os << setw(12) << left << DDLDatatypeString[columnType.fType]
|
||||
<< "["
|
||||
os << setw(12) << left << DDLDatatypeString[columnType.fType] << "["
|
||||
<< "L=" << setw(2) << columnType.fLength << ","
|
||||
<< "P=" << setw(2) << columnType.fPrecision << ","
|
||||
<< "S=" << setw(2) << columnType.fScale << ","
|
||||
<< "T=" << setw(2) << columnType.fWithTimezone
|
||||
<< "]";
|
||||
<< "T=" << setw(2) << columnType.fWithTimezone << "]";
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
ostream& operator<<(ostream& os, const ColumnDef& column)
|
||||
{
|
||||
os << "Column: " << column.fName << " " << *column.fType;
|
||||
@ -89,35 +82,27 @@ ostream& operator<<(ostream& os, const ColumnDef& column)
|
||||
os << column.fDefaultValue->fValue;
|
||||
}
|
||||
|
||||
os << endl << " " << column.fConstraints.size()
|
||||
<< " constraints ";
|
||||
os << endl << " " << column.fConstraints.size() << " constraints ";
|
||||
|
||||
ColumnConstraintList::const_iterator itr;
|
||||
|
||||
for (itr = column.fConstraints.begin();
|
||||
itr != column.fConstraints.end();
|
||||
++itr)
|
||||
for (itr = column.fConstraints.begin(); itr != column.fConstraints.end(); ++itr)
|
||||
{
|
||||
ColumnConstraintDef* con = *itr;
|
||||
os << *con;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
ostream& operator<<(ostream& os, const ColumnConstraintDef& con)
|
||||
{
|
||||
os << " Constraint: "
|
||||
<< con.fName << " "
|
||||
<< ConstraintString[con.fConstraintType] << " "
|
||||
<< "defer=" << con.fDeferrable << " "
|
||||
<< ConstraintAttrStrings[con.fCheckTime] << " ";
|
||||
os << " Constraint: " << con.fName << " " << ConstraintString[con.fConstraintType] << " "
|
||||
<< "defer=" << con.fDeferrable << " " << ConstraintAttrStrings[con.fCheckTime] << " ";
|
||||
|
||||
if (!con.fCheck.empty())
|
||||
os << "check=" << "\"" << con.fCheck << "\"";
|
||||
os << "check="
|
||||
<< "\"" << con.fCheck << "\"";
|
||||
|
||||
return os;
|
||||
}
|
||||
@ -134,9 +119,7 @@ std::ostream& operator<<(std::ostream& os, const ColumnDefList& clist)
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
ColumnDefaultValue::ColumnDefaultValue(const char* value) :
|
||||
fNull(false)
|
||||
ColumnDefaultValue::ColumnDefaultValue(const char* value) : fNull(false)
|
||||
{
|
||||
if (0 == value)
|
||||
fNull = true;
|
||||
@ -144,7 +127,6 @@ ColumnDefaultValue::ColumnDefaultValue(const char* value) :
|
||||
fValue = value;
|
||||
}
|
||||
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const ColumnDefaultValue& defaultValue)
|
||||
{
|
||||
os << " def=";
|
||||
@ -157,4 +139,4 @@ std::ostream& operator<<(std::ostream& os, const ColumnDefaultValue& defaultValu
|
||||
return os;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace ddlpackage
|
||||
|
@ -27,20 +27,14 @@ namespace ddlpackage
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
CreateIndexStatement::CreateIndexStatement():
|
||||
fIndexName(NULL),
|
||||
fTableName(NULL),
|
||||
fColumnNames(),
|
||||
fUnique(false)
|
||||
CreateIndexStatement::CreateIndexStatement()
|
||||
: fIndexName(NULL), fTableName(NULL), fColumnNames(), fUnique(false)
|
||||
{
|
||||
}
|
||||
|
||||
CreateIndexStatement::CreateIndexStatement(QualifiedName* indexName, QualifiedName* tableName,
|
||||
ColumnNameList* columnNames, bool unique) :
|
||||
fIndexName(indexName),
|
||||
fTableName(tableName),
|
||||
fColumnNames(*columnNames),
|
||||
fUnique(unique)
|
||||
ColumnNameList* columnNames, bool unique)
|
||||
: fIndexName(indexName), fTableName(tableName), fColumnNames(*columnNames), fUnique(unique)
|
||||
{
|
||||
delete columnNames;
|
||||
}
|
||||
@ -53,9 +47,8 @@ CreateIndexStatement::~CreateIndexStatement()
|
||||
|
||||
std::ostream& CreateIndexStatement::put(std::ostream& os) const
|
||||
{
|
||||
os << "Create Index: " << *fIndexName << " on " << *fTableName
|
||||
<< fColumnNames << endl;
|
||||
os << "Create Index: " << *fIndexName << " on " << *fTableName << fColumnNames << endl;
|
||||
return os;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace ddlpackage
|
||||
|
@ -29,20 +29,16 @@
|
||||
|
||||
namespace ddlpackage
|
||||
{
|
||||
|
||||
using namespace std;
|
||||
|
||||
CreateTableStatement::CreateTableStatement() :
|
||||
fTableDef(0)
|
||||
CreateTableStatement::CreateTableStatement() : fTableDef(0)
|
||||
{
|
||||
}
|
||||
|
||||
CreateTableStatement::CreateTableStatement(TableDef* tableDef) :
|
||||
fTableDef(tableDef)
|
||||
CreateTableStatement::CreateTableStatement(TableDef* tableDef) : fTableDef(tableDef)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CreateTableStatement::~CreateTableStatement()
|
||||
{
|
||||
if (fTableDef)
|
||||
@ -54,8 +50,7 @@ CreateTableStatement::~CreateTableStatement()
|
||||
/** \brief Put to ostream. */
|
||||
ostream& CreateTableStatement::put(ostream& os) const
|
||||
{
|
||||
os << "CreateTable "
|
||||
<< *fTableDef;
|
||||
os << "CreateTable " << *fTableDef;
|
||||
return os;
|
||||
}
|
||||
}
|
||||
} // namespace ddlpackage
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -32,7 +32,6 @@
|
||||
This special exception was added by the Free Software Foundation in
|
||||
version 2.2 of Bison. */
|
||||
|
||||
|
||||
/* Tokens. */
|
||||
#pragma once
|
||||
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
||||
@ -125,13 +124,9 @@ enum yytokentype
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if !defined YYSTYPE && !defined YYSTYPE_IS_DECLARED
|
||||
typedef union YYSTYPE
|
||||
{
|
||||
|
||||
|
||||
ddlpackage::AlterTableStatement* alterTableStmt;
|
||||
ddlpackage::AlterTableAction* ata;
|
||||
ddlpackage::AlterTableActionList* ataList;
|
||||
@ -160,13 +155,9 @@ typedef union YYSTYPE
|
||||
ddlpackage::DDL_REFERENTIAL_ACTION refActionCode;
|
||||
ddlpackage::ReferentialAction* refAction;
|
||||
|
||||
|
||||
|
||||
} YYSTYPE;
|
||||
#define YYSTYPE_IS_TRIVIAL 1
|
||||
#define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||
#define YYSTYPE_IS_DECLARED 1
|
||||
|
||||
extern YYSTYPE ddllval;
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -32,21 +32,16 @@ namespace ddlpackage
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
QualifiedName::QualifiedName(const char* name):
|
||||
fName(name)
|
||||
QualifiedName::QualifiedName(const char* name) : fName(name)
|
||||
{
|
||||
}
|
||||
|
||||
QualifiedName::QualifiedName(const char* schema, const char* name):
|
||||
fName(name),
|
||||
fSchema(schema)
|
||||
QualifiedName::QualifiedName(const char* schema, const char* name) : fName(name), fSchema(schema)
|
||||
{
|
||||
}
|
||||
|
||||
QualifiedName::QualifiedName(const char* catalog, const char* schema, const char* name):
|
||||
fCatalog(catalog),
|
||||
fName(name),
|
||||
fSchema(schema)
|
||||
QualifiedName::QualifiedName(const char* catalog, const char* schema, const char* name)
|
||||
: fCatalog(catalog), fName(name), fSchema(schema)
|
||||
{
|
||||
}
|
||||
|
||||
@ -62,85 +57,58 @@ ostream& operator<<(ostream& os, const QualifiedName& qname)
|
||||
return os;
|
||||
}
|
||||
|
||||
ColumnType::ColumnType(int prec, int scale) :
|
||||
fType(DDL_INVALID_DATATYPE),
|
||||
fLength(0),
|
||||
fPrecision(prec),
|
||||
fScale(scale),
|
||||
fWithTimezone(false),
|
||||
fCharset(NULL),
|
||||
fExplicitLength(false)
|
||||
ColumnType::ColumnType(int prec, int scale)
|
||||
: fType(DDL_INVALID_DATATYPE)
|
||||
, fLength(0)
|
||||
, fPrecision(prec)
|
||||
, fScale(scale)
|
||||
, fWithTimezone(false)
|
||||
, fCharset(NULL)
|
||||
, fExplicitLength(false)
|
||||
{
|
||||
fLength = utils::widthByPrecision(fPrecision);
|
||||
}
|
||||
|
||||
ColumnType::ColumnType(int type) :
|
||||
fType(type),
|
||||
fLength(0),
|
||||
fScale(0),
|
||||
fWithTimezone(false),
|
||||
fCharset(NULL),
|
||||
fExplicitLength(false)
|
||||
ColumnType::ColumnType(int type)
|
||||
: fType(type), fLength(0), fScale(0), fWithTimezone(false), fCharset(NULL), fExplicitLength(false)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case DDL_TINYINT:
|
||||
case DDL_UNSIGNED_TINYINT:
|
||||
fPrecision = 3;
|
||||
break;
|
||||
case DDL_UNSIGNED_TINYINT: fPrecision = 3; break;
|
||||
|
||||
case DDL_SMALLINT:
|
||||
case DDL_UNSIGNED_SMALLINT:
|
||||
fPrecision = 5;
|
||||
break;
|
||||
case DDL_UNSIGNED_SMALLINT: fPrecision = 5; break;
|
||||
|
||||
case DDL_MEDINT:
|
||||
fPrecision = 7;
|
||||
break;
|
||||
case DDL_MEDINT: fPrecision = 7; break;
|
||||
|
||||
case DDL_UNSIGNED_MEDINT:
|
||||
fPrecision = 8;
|
||||
break;
|
||||
case DDL_UNSIGNED_MEDINT: fPrecision = 8; break;
|
||||
|
||||
case DDL_INT:
|
||||
case DDL_UNSIGNED_INT:
|
||||
fPrecision = 10;
|
||||
break;
|
||||
case DDL_UNSIGNED_INT: fPrecision = 10; break;
|
||||
|
||||
case DDL_BIGINT:
|
||||
fPrecision = 19;
|
||||
break;
|
||||
case DDL_BIGINT: fPrecision = 19; break;
|
||||
|
||||
case DDL_UNSIGNED_BIGINT:
|
||||
fPrecision = 20;
|
||||
break;
|
||||
case DDL_UNSIGNED_BIGINT: fPrecision = 20; break;
|
||||
|
||||
default:
|
||||
fPrecision = 10;
|
||||
break;
|
||||
default: fPrecision = 10; break;
|
||||
}
|
||||
}
|
||||
ColumnConstraintDef::ColumnConstraintDef(DDL_CONSTRAINTS type) :
|
||||
SchemaObject(),
|
||||
fDeferrable(false),
|
||||
fCheckTime(DDL_INITIALLY_IMMEDIATE),
|
||||
fConstraintType(type),
|
||||
fCheck("")
|
||||
ColumnConstraintDef::ColumnConstraintDef(DDL_CONSTRAINTS type)
|
||||
: SchemaObject(), fDeferrable(false), fCheckTime(DDL_INITIALLY_IMMEDIATE), fConstraintType(type), fCheck("")
|
||||
{
|
||||
}
|
||||
|
||||
ColumnConstraintDef::ColumnConstraintDef(const char* check) :
|
||||
SchemaObject(),
|
||||
fDeferrable(false),
|
||||
fCheckTime(DDL_INITIALLY_IMMEDIATE),
|
||||
fConstraintType(DDL_CHECK),
|
||||
fCheck(check)
|
||||
ColumnConstraintDef::ColumnConstraintDef(const char* check)
|
||||
: SchemaObject()
|
||||
, fDeferrable(false)
|
||||
, fCheckTime(DDL_INITIALLY_IMMEDIATE)
|
||||
, fConstraintType(DDL_CHECK)
|
||||
, fCheck(check)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
AtaAddColumn::AtaAddColumn(ColumnDef* columnDef) :
|
||||
fColumnDef(columnDef)
|
||||
AtaAddColumn::AtaAddColumn(ColumnDef* columnDef) : fColumnDef(columnDef)
|
||||
{
|
||||
}
|
||||
|
||||
@ -195,4 +163,4 @@ void ColumnDef::convertDecimal()
|
||||
fType->fLength = 16;
|
||||
}
|
||||
}
|
||||
} // end of namespace
|
||||
} // namespace ddlpackage
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -32,8 +32,7 @@ DropIndexStatement::~DropIndexStatement()
|
||||
delete fIndexName;
|
||||
}
|
||||
|
||||
DropIndexStatement::DropIndexStatement(QualifiedName* qualifiedName) :
|
||||
fIndexName(qualifiedName)
|
||||
DropIndexStatement::DropIndexStatement(QualifiedName* qualifiedName) : fIndexName(qualifiedName)
|
||||
{
|
||||
}
|
||||
|
||||
@ -43,4 +42,4 @@ std::ostream& DropIndexStatement::put(std::ostream& os) const
|
||||
return os;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace ddlpackage
|
||||
|
@ -29,9 +29,7 @@ using namespace std;
|
||||
|
||||
namespace ddlpackage
|
||||
{
|
||||
|
||||
DropPartitionStatement::DropPartitionStatement(QualifiedName* qualifiedName) :
|
||||
fTableName(qualifiedName)
|
||||
DropPartitionStatement::DropPartitionStatement(QualifiedName* qualifiedName) : fTableName(qualifiedName)
|
||||
{
|
||||
}
|
||||
|
||||
@ -48,4 +46,4 @@ ostream& DropPartitionStatement::put(ostream& os) const
|
||||
return os;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace ddlpackage
|
||||
|
@ -29,21 +29,19 @@ using namespace std;
|
||||
|
||||
namespace ddlpackage
|
||||
{
|
||||
|
||||
DropTableStatement::DropTableStatement(QualifiedName* qualifiedName, bool cascade) :
|
||||
fTableName(qualifiedName),
|
||||
fCascade(cascade)
|
||||
DropTableStatement::DropTableStatement(QualifiedName* qualifiedName, bool cascade)
|
||||
: fTableName(qualifiedName), fCascade(cascade)
|
||||
{
|
||||
}
|
||||
|
||||
ostream& DropTableStatement::put(ostream& os) const
|
||||
{
|
||||
os << "Drop Table: " << *fTableName << " " << "C=" << fCascade << endl;
|
||||
os << "Drop Table: " << *fTableName << " "
|
||||
<< "C=" << fCascade << endl;
|
||||
return os;
|
||||
}
|
||||
|
||||
TruncTableStatement::TruncTableStatement(QualifiedName* qualifiedName) :
|
||||
fTableName(qualifiedName)
|
||||
TruncTableStatement::TruncTableStatement(QualifiedName* qualifiedName) : fTableName(qualifiedName)
|
||||
{
|
||||
}
|
||||
|
||||
@ -53,4 +51,4 @@ ostream& TruncTableStatement::put(ostream& os) const
|
||||
return os;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace ddlpackage
|
||||
|
@ -35,11 +35,12 @@ int main(int argc, char* argv[])
|
||||
int count;
|
||||
|
||||
po::options_description desc("Allowed options");
|
||||
desc.add_options ()
|
||||
("help", "produce help message")
|
||||
("bisond", /* po::value <string>(),*/ "Have bison produce debug output")
|
||||
("count", po::value <int>(), "number of runs")
|
||||
("sql", po::value < string > (), "sql file");
|
||||
desc.add_options()("help", "produce help message")(
|
||||
"bisond",
|
||||
/* po::value <string>(),*/ "Have bison produce debug output")("count", po::value<int>(),
|
||||
"number of runs")("sql",
|
||||
po::value<string>(),
|
||||
"sql file");
|
||||
po::variables_map vm;
|
||||
po::store(po::parse_command_line(argc, argv, desc), vm);
|
||||
po::notify(vm);
|
||||
@ -47,7 +48,6 @@ int main(int argc, char* argv[])
|
||||
if (vm.count("sql"))
|
||||
sqlfile = vm["sql"].as<string>();
|
||||
|
||||
|
||||
if (vm.count("count"))
|
||||
count = vm["count"].as<int>();
|
||||
|
||||
@ -63,7 +63,8 @@ int main(int argc, char* argv[])
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
|
||||
cout << "Parser succeeded." << endl;
|
||||
cout << ptree.fList.size() << " " << "SQL statements" << endl;
|
||||
cout << ptree.fList.size() << " "
|
||||
<< "SQL statements" << endl;
|
||||
cout << ptree;
|
||||
cout << endl;
|
||||
}
|
||||
@ -74,5 +75,3 @@ int main(int argc, char* argv[])
|
||||
|
||||
return parser.Good() ? 0 : -1;
|
||||
}
|
||||
|
||||
|
||||
|
@ -29,9 +29,7 @@ using namespace std;
|
||||
|
||||
namespace ddlpackage
|
||||
{
|
||||
|
||||
MarkPartitionStatement::MarkPartitionStatement(QualifiedName* qualifiedName) :
|
||||
fTableName(qualifiedName)
|
||||
MarkPartitionStatement::MarkPartitionStatement(QualifiedName* qualifiedName) : fTableName(qualifiedName)
|
||||
{
|
||||
}
|
||||
|
||||
@ -48,4 +46,4 @@ ostream& MarkPartitionStatement::put(ostream& os) const
|
||||
return os;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace ddlpackage
|
||||
|
@ -41,7 +41,6 @@
|
||||
#include "dropobjectddlpackage.h"
|
||||
#include "messagequeue.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace ddlpackage;
|
||||
using namespace messageqcpp;
|
||||
@ -52,7 +51,6 @@ std::string itoa(const int i);
|
||||
|
||||
class DDLWriteReadTest : public CppUnit::TestFixture
|
||||
{
|
||||
|
||||
CPPUNIT_TEST_SUITE(DDLWriteReadTest);
|
||||
|
||||
CPPUNIT_TEST(test_write_read_create_table_object);
|
||||
@ -61,28 +59,26 @@ class DDLWriteReadTest : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST(test_write_read_drop_table_object);
|
||||
CPPUNIT_TEST(test_write_read_drop_index_object);
|
||||
|
||||
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
private:
|
||||
|
||||
|
||||
public:
|
||||
void setUp()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void tearDown()
|
||||
{
|
||||
|
||||
}
|
||||
// CREATE TABLE
|
||||
void test_write_read_create_table_object()
|
||||
{
|
||||
ByteStream bytestream;
|
||||
|
||||
std::string ddl_statement = "CREATE TABLE calpont.PART(p_partkey int not null, p_a varchar(55), p_b decimal(8,2) unique, p_c int default 1, p_d varchar(25) default 'unknown' check (varchar = 'a' ), foreign key (p_partkey) references Customers(p_partkey)) engine=infinidb;";
|
||||
std::string ddl_statement =
|
||||
"CREATE TABLE calpont.PART(p_partkey int not null, p_a varchar(55), p_b decimal(8,2) unique, p_c int "
|
||||
"default 1, p_d varchar(25) default 'unknown' check (varchar = 'a' ), foreign key (p_partkey) "
|
||||
"references Customers(p_partkey)) engine=infinidb;";
|
||||
|
||||
MySQLDDLStatement* pDDLStatement = new MySQLDDLStatement();
|
||||
|
||||
@ -104,17 +100,14 @@ public:
|
||||
delete pDDLPackage;
|
||||
|
||||
read_create_table_object(bytestream);
|
||||
|
||||
}
|
||||
void write_create_table_object(ByteStream& bs, CalpontDDLPackage* pDDLPackage)
|
||||
{
|
||||
|
||||
pDDLPackage->Write(bs);
|
||||
}
|
||||
|
||||
void read_create_table_object(ByteStream& bs)
|
||||
{
|
||||
|
||||
ByteStream::byte package_type;
|
||||
bs >> package_type;
|
||||
|
||||
@ -125,7 +118,6 @@ public:
|
||||
pObject->Read(bs);
|
||||
|
||||
delete pObject;
|
||||
|
||||
}
|
||||
|
||||
// CREATE INDEX
|
||||
@ -155,17 +147,14 @@ public:
|
||||
delete pDDLPackage;
|
||||
|
||||
read_create_index_object(bytestream);
|
||||
|
||||
}
|
||||
void write_create_index_object(ByteStream& bs, CalpontDDLPackage* pDDLPackage)
|
||||
{
|
||||
|
||||
pDDLPackage->Write(bs);
|
||||
}
|
||||
|
||||
void read_create_index_object(ByteStream& bs)
|
||||
{
|
||||
|
||||
ByteStream::byte package_type;
|
||||
bs >> package_type;
|
||||
|
||||
@ -176,7 +165,6 @@ public:
|
||||
pObject->Read(bs);
|
||||
|
||||
delete pObject;
|
||||
|
||||
}
|
||||
|
||||
// ALTER TABLE
|
||||
@ -206,17 +194,14 @@ public:
|
||||
delete pDDLPackage;
|
||||
|
||||
read_alter_table_object(bytestream);
|
||||
|
||||
}
|
||||
void write_alter_table_object(ByteStream& bs, CalpontDDLPackage* pDDLPackage)
|
||||
{
|
||||
|
||||
pDDLPackage->Write(bs);
|
||||
}
|
||||
|
||||
void read_alter_table_object(ByteStream& bs)
|
||||
{
|
||||
|
||||
ByteStream::byte package_type;
|
||||
bs >> package_type;
|
||||
|
||||
@ -227,7 +212,6 @@ public:
|
||||
pObject->Read(bs);
|
||||
|
||||
delete pObject;
|
||||
|
||||
}
|
||||
|
||||
// DROP TABLE
|
||||
@ -257,17 +241,14 @@ public:
|
||||
delete pDDLPackage;
|
||||
|
||||
read_drop_table_object(bytestream);
|
||||
|
||||
}
|
||||
void write_drop_table_object(ByteStream& bs, CalpontDDLPackage* pDDLPackage)
|
||||
{
|
||||
|
||||
pDDLPackage->Write(bs);
|
||||
}
|
||||
|
||||
void read_drop_table_object(ByteStream& bs)
|
||||
{
|
||||
|
||||
ByteStream::byte package_type;
|
||||
bs >> package_type;
|
||||
|
||||
@ -278,7 +259,6 @@ public:
|
||||
pObject->Read(bs);
|
||||
|
||||
delete pObject;
|
||||
|
||||
}
|
||||
|
||||
// DROP INDEX
|
||||
@ -308,17 +288,14 @@ public:
|
||||
delete pDDLPackage;
|
||||
|
||||
read_drop_index_object(bytestream);
|
||||
|
||||
}
|
||||
void write_drop_index_object(ByteStream& bs, CalpontDDLPackage* pDDLPackage)
|
||||
{
|
||||
|
||||
pDDLPackage->Write(bs);
|
||||
}
|
||||
|
||||
void read_drop_index_object(ByteStream& bs)
|
||||
{
|
||||
|
||||
ByteStream::byte package_type;
|
||||
bs >> package_type;
|
||||
|
||||
@ -329,17 +306,13 @@ public:
|
||||
pObject->Read(bs);
|
||||
|
||||
delete pObject;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// PARSE STATEMENT TESTS
|
||||
|
||||
|
||||
class DDLCreateTableParserTest : public CppUnit::TestFixture
|
||||
{
|
||||
|
||||
CPPUNIT_TEST_SUITE(DDLCreateTableParserTest);
|
||||
|
||||
CPPUNIT_TEST(create_t1);
|
||||
@ -347,7 +320,6 @@ class DDLCreateTableParserTest : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
private:
|
||||
|
||||
public:
|
||||
void setUp()
|
||||
{
|
||||
@ -410,7 +382,6 @@ public:
|
||||
|
||||
class DDLCreateIndexParserTest : public CppUnit::TestFixture
|
||||
{
|
||||
|
||||
CPPUNIT_TEST_SUITE(DDLCreateIndexParserTest);
|
||||
|
||||
CPPUNIT_TEST(createIndex_t1);
|
||||
@ -418,7 +389,6 @@ class DDLCreateIndexParserTest : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
private:
|
||||
|
||||
public:
|
||||
void setUp()
|
||||
{
|
||||
@ -477,13 +447,10 @@ public:
|
||||
|
||||
fin.close();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
class DDLAlterTableParserTest : public CppUnit::TestFixture
|
||||
{
|
||||
|
||||
CPPUNIT_TEST_SUITE(DDLAlterTableParserTest);
|
||||
|
||||
CPPUNIT_TEST(alter_t1);
|
||||
@ -491,7 +458,6 @@ class DDLAlterTableParserTest : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
private:
|
||||
|
||||
public:
|
||||
void setUp()
|
||||
{
|
||||
@ -552,10 +518,8 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class DDLDropTableParserTest : public CppUnit::TestFixture
|
||||
{
|
||||
|
||||
CPPUNIT_TEST_SUITE(DDLDropTableParserTest);
|
||||
|
||||
CPPUNIT_TEST(drop_t1);
|
||||
@ -563,11 +527,9 @@ class DDLDropTableParserTest : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
private:
|
||||
|
||||
public:
|
||||
void setUp()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void tearDown()
|
||||
@ -623,12 +585,10 @@ public:
|
||||
|
||||
fin.close();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class DDLDropIndexParserTest : public CppUnit::TestFixture
|
||||
{
|
||||
|
||||
CPPUNIT_TEST_SUITE(DDLDropIndexParserTest);
|
||||
|
||||
CPPUNIT_TEST(dropIndex_t1);
|
||||
@ -696,7 +656,6 @@ public:
|
||||
|
||||
fin.close();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(DDLDropIndexParserTest);
|
||||
@ -711,14 +670,12 @@ CPPUNIT_TEST_SUITE_REGISTRATION( DDLWriteReadTest );
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
|
||||
CppUnit::TextUi::TestRunner runner;
|
||||
CppUnit::TestFactoryRegistry& registry = CppUnit::TestFactoryRegistry::getRegistry();
|
||||
runner.addTest(registry.makeTest());
|
||||
bool wasSuccessful = runner.run("", false);
|
||||
|
||||
return (wasSuccessful ? 0 : 1);
|
||||
|
||||
}
|
||||
|
||||
string itoa(const int i)
|
||||
@ -727,4 +684,3 @@ string itoa(const int i)
|
||||
ss << i;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
|
@ -29,9 +29,7 @@ using namespace std;
|
||||
|
||||
namespace ddlpackage
|
||||
{
|
||||
|
||||
RestorePartitionStatement::RestorePartitionStatement(QualifiedName* qualifiedName) :
|
||||
fTableName(qualifiedName)
|
||||
RestorePartitionStatement::RestorePartitionStatement(QualifiedName* qualifiedName) : fTableName(qualifiedName)
|
||||
{
|
||||
}
|
||||
|
||||
@ -48,4 +46,4 @@ ostream& RestorePartitionStatement::put(ostream& os) const
|
||||
return os;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace ddlpackage
|
||||
|
@ -60,7 +60,6 @@ void read_vec(vector<T*>& v, ByteStream& bs)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
/// CreateTableStatement Serialization
|
||||
///////////////////////////////////////
|
||||
@ -103,8 +102,6 @@ int CreateTableStatement::serialize(ByteStream& bytestream)
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
/// AlterTableStatement Serialization
|
||||
///////////////////////////////////////
|
||||
@ -206,9 +203,7 @@ int AlterTableStatement::unserialize(ByteStream& bytestream)
|
||||
fActions.push_back(ata);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw ("Bad typecode for AlterTableAction");
|
||||
break;
|
||||
default: throw("Bad typecode for AlterTableAction"); break;
|
||||
}
|
||||
|
||||
bytestream >> fSessionID;
|
||||
@ -248,8 +243,6 @@ int AlterTableStatement::serialize(ByteStream& bytestream)
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
/// CreateIndexStatement Serialization
|
||||
///////////////////////////////////////
|
||||
@ -267,11 +260,9 @@ int CreateIndexStatement::unserialize(ByteStream& bytestream)
|
||||
fTableName = new QualifiedName();
|
||||
fTableName->unserialize(bytestream);
|
||||
|
||||
|
||||
quadbyte column_count;
|
||||
bytestream >> column_count;
|
||||
|
||||
|
||||
std::string columnname;
|
||||
|
||||
for (unsigned int i = 0; i < column_count; i++)
|
||||
@ -308,9 +299,7 @@ int CreateIndexStatement::serialize(ByteStream& bytestream)
|
||||
bytestream << (quadbyte)fColumnNames.size();
|
||||
ColumnNameList::const_iterator itr;
|
||||
|
||||
for (itr = fColumnNames.begin();
|
||||
itr != fColumnNames.end();
|
||||
++itr)
|
||||
for (itr = fColumnNames.begin(); itr != fColumnNames.end(); ++itr)
|
||||
{
|
||||
bytestream << *itr;
|
||||
}
|
||||
@ -330,8 +319,6 @@ int CreateIndexStatement::serialize(ByteStream& bytestream)
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
/// DropIndexStatement Serialization
|
||||
///////////////////////////////////////
|
||||
@ -379,7 +366,6 @@ int DropIndexStatement::serialize(ByteStream& bytestream)
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
/// DropTableStatement Serialization
|
||||
///////////////////////////////////////
|
||||
@ -490,7 +476,6 @@ int TruncTableStatement::serialize(ByteStream& bytestream)
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
/// MarkPartitionStatement Serialization
|
||||
///////////////////////////////////////
|
||||
@ -531,7 +516,6 @@ int MarkPartitionStatement::serialize(ByteStream& bytestream)
|
||||
{
|
||||
int ret = 1;
|
||||
|
||||
|
||||
bytestream << (quadbyte)DDL_MARK_PARTITION_STATEMENT;
|
||||
|
||||
// write the table and schema name
|
||||
@ -709,8 +693,6 @@ int AtaAddColumn::serialize(ByteStream& bytestream)
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
/// AtaAddColumns Serialization
|
||||
///////////////////////////////////////
|
||||
@ -780,8 +762,6 @@ int AtaDropColumns::serialize(ByteStream& bytestream)
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
/// AtaAddTableConstraint Serialization
|
||||
///////////////////////////////////////
|
||||
@ -833,7 +813,6 @@ int AtaAddTableConstraint::serialize(ByteStream& bytestream)
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
/// AtaDropColumn Serialization
|
||||
///////////////////////////////////////
|
||||
@ -864,7 +843,6 @@ int AtaDropColumn::serialize(ByteStream& bytestream)
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
/// AtaSetColumnDefault Serialization
|
||||
///////////////////////////////////////
|
||||
@ -893,8 +871,6 @@ int AtaSetColumnDefault::serialize(ByteStream& bytestream)
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
/// AtaDropColumnDefault Serialization
|
||||
///////////////////////////////////////
|
||||
@ -921,8 +897,6 @@ int AtaDropColumnDefault::serialize(ByteStream& bytestream)
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
/// AtaDropTableConstraint Serialization
|
||||
///////////////////////////////////////
|
||||
@ -954,7 +928,6 @@ int AtaDropTableConstraint::serialize(ByteStream& bytestream)
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
/// AtaTableComment Serialization
|
||||
///////////////////////////////////////
|
||||
@ -981,8 +954,6 @@ int AtaTableComment::serialize(ByteStream& bytestream)
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
/// AtaRenameTable Serialization
|
||||
///////////////////////////////////////
|
||||
@ -1014,8 +985,6 @@ int AtaRenameTable::serialize(ByteStream& bytestream)
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
/// AtaModifyColumnType Serialization
|
||||
///////////////////////////////////////
|
||||
@ -1051,8 +1020,6 @@ int AtaModifyColumnType::serialize(ByteStream& bytestream)
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
/// AtaRenameColumn Serialization
|
||||
///////////////////////////////////////
|
||||
@ -1122,8 +1089,6 @@ int AtaRenameColumn::serialize(ByteStream& bytestream)
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
/// ColumnType Serialization
|
||||
///////////////////////////////////////
|
||||
@ -1195,8 +1160,6 @@ int ColumnType::serialize(ByteStream& bytestream)
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
/// ColumnConstraintDef Serialization
|
||||
///////////////////////////////////////
|
||||
@ -1243,8 +1206,6 @@ int ColumnConstraintDef::serialize(ByteStream& bytestream)
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
/// ColumnDefaultValue Serialization
|
||||
///////////////////////////////////////
|
||||
@ -1277,8 +1238,6 @@ int ColumnDefaultValue::serialize(ByteStream& bytestream)
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
/// ColumnDef Serialization
|
||||
///////////////////////////////////////
|
||||
@ -1339,14 +1298,11 @@ int ColumnDef::serialize(ByteStream& bytestream)
|
||||
fDefaultValue->serialize(bytestream);
|
||||
}
|
||||
|
||||
|
||||
// cout << "BS length = " << bytestream.length() << endl;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
/// TableConstraintDef Serialization
|
||||
///////////////////////////////////////
|
||||
@ -1363,8 +1319,6 @@ int TableConstraintDef::unserialize(ByteStream& bytestream)
|
||||
|
||||
fConstraintType = (DDL_CONSTRAINTS)constrainttype;
|
||||
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -1378,12 +1332,9 @@ int TableConstraintDef::serialize(ByteStream& bytestream)
|
||||
// write constraint def
|
||||
bytestream << constrainttype;
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
/// TableUniqueConstraintDef Serialization
|
||||
///////////////////////////////////////
|
||||
@ -1427,8 +1378,6 @@ int TableUniqueConstraintDef::serialize(ByteStream& bytestream)
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
/// TablePrimaryKeyConstraintDef Serialization
|
||||
///////////////////////////////////////
|
||||
@ -1472,8 +1421,6 @@ int TablePrimaryKeyConstraintDef::serialize(ByteStream& bytestream)
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
/// ReferentialAction Serialization
|
||||
///////////////////////////////////////
|
||||
@ -1493,7 +1440,6 @@ int ReferentialAction::unserialize(ByteStream& bytestream)
|
||||
fOnUpdate = (DDL_REFERENTIAL_ACTION)onupdate;
|
||||
fOnDelete = (DDL_REFERENTIAL_ACTION)ondelete;
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -1509,12 +1455,9 @@ int ReferentialAction::serialize(ByteStream& bytestream)
|
||||
bytestream << onupdate;
|
||||
bytestream << ondelete;
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
/// TableReferencesConstraintDef Serialization
|
||||
///////////////////////////////////////
|
||||
@ -1615,8 +1558,6 @@ int TableReferencesConstraintDef::serialize(ByteStream& bytestream)
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
/// TableCheckConstraintDef Serialization
|
||||
///////////////////////////////////////
|
||||
@ -1643,8 +1584,6 @@ int TableCheckConstraintDef::serialize(ByteStream& bytestream)
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
/// TableDef Serialization
|
||||
///////////////////////////////////////
|
||||
@ -1697,9 +1636,7 @@ int TableDef::unserialize(ByteStream& bytestream)
|
||||
fConstraints.push_back(constraint);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw ("Bad typecode for TableConstraintDef");
|
||||
break;
|
||||
default: throw("Bad typecode for TableConstraintDef"); break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1735,9 +1672,7 @@ int TableDef::serialize(ByteStream& bytestream)
|
||||
|
||||
TableConstraintDefList::const_iterator itr;
|
||||
|
||||
for (itr = fConstraints.begin();
|
||||
itr != fConstraints.end();
|
||||
++itr)
|
||||
for (itr = fConstraints.begin(); itr != fConstraints.end(); ++itr)
|
||||
{
|
||||
bytestream << (quadbyte)(*itr)->getSerialType();
|
||||
(*itr)->serialize(bytestream);
|
||||
@ -1750,9 +1685,7 @@ int TableDef::serialize(ByteStream& bytestream)
|
||||
pair<string, string> oval;
|
||||
TableOptionMap::const_iterator itr2;
|
||||
|
||||
for (itr2 = fOptions.begin();
|
||||
itr2 != fOptions.end();
|
||||
++itr2)
|
||||
for (itr2 = fOptions.begin(); itr2 != fOptions.end(); ++itr2)
|
||||
{
|
||||
oval = *itr2;
|
||||
bytestream << oval.first;
|
||||
@ -1775,7 +1708,6 @@ int QualifiedName::unserialize(ByteStream& bytestream)
|
||||
bytestream >> fSchema;
|
||||
bytestream >> fName;
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -1791,12 +1723,10 @@ int QualifiedName::serialize(ByteStream& bytestream)
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
/// ConstraintAttributes Serialization
|
||||
///////////////////////////////////////
|
||||
|
||||
|
||||
/** @brief Construct from Bytestream */
|
||||
int ConstraintAttributes::unserialize(ByteStream& bytestream)
|
||||
{
|
||||
@ -1812,7 +1742,6 @@ int ConstraintAttributes::unserialize(ByteStream& bytestream)
|
||||
fCheckTime = (DDL_CONSTRAINT_ATTRIBUTES)checktime;
|
||||
fDeferrable = (deferrable != 0);
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -1828,9 +1757,5 @@ int ConstraintAttributes::serialize(ByteStream& bytestream)
|
||||
bytestream << checktime;
|
||||
bytestream << deferrable;
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -45,14 +45,10 @@ namespace ddlpackage
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
SqlParser::SqlParser() :
|
||||
fStatus(-1),
|
||||
fDebug(false),
|
||||
x(&fParseTree)
|
||||
SqlParser::SqlParser() : fStatus(-1), fDebug(false), x(&fParseTree)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void SqlParser::SetDebug(bool debug)
|
||||
{
|
||||
fDebug = debug;
|
||||
@ -76,7 +72,6 @@ int SqlParser::Parse(const char* sqltext)
|
||||
return fStatus;
|
||||
}
|
||||
|
||||
|
||||
const ParseTree& SqlParser::GetParseTree(void)
|
||||
{
|
||||
if (!Good())
|
||||
@ -87,26 +82,21 @@ const ParseTree& SqlParser::GetParseTree(void)
|
||||
return fParseTree;
|
||||
}
|
||||
|
||||
|
||||
bool SqlParser::Good()
|
||||
{
|
||||
return fStatus == 0;
|
||||
}
|
||||
|
||||
|
||||
SqlParser::~SqlParser()
|
||||
{
|
||||
scanner_finish(x.scanner); // free scanner allocated memory
|
||||
ddllex_destroy(x.scanner);
|
||||
}
|
||||
|
||||
|
||||
SqlFileParser::SqlFileParser() :
|
||||
SqlParser()
|
||||
SqlFileParser::SqlFileParser() : SqlParser()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
int SqlFileParser::Parse(const string& sqlfile)
|
||||
{
|
||||
fStatus = -1;
|
||||
@ -145,4 +135,4 @@ int SqlFileParser::Parse(const string& sqlfile)
|
||||
|
||||
return SqlParser::Parse(sqlbuf);
|
||||
}
|
||||
}
|
||||
} // namespace ddlpackage
|
||||
|
@ -38,7 +38,6 @@
|
||||
|
||||
namespace ddlpackage
|
||||
{
|
||||
|
||||
typedef SqlStatementList ParseTree;
|
||||
|
||||
/** @brief SqlParser is a class interface around the Bison parser
|
||||
@ -138,7 +137,6 @@ protected:
|
||||
pass_to_bison x;
|
||||
};
|
||||
|
||||
|
||||
/** SqlFileParser is a testing device.
|
||||
*/
|
||||
class SqlFileParser : public SqlParser
|
||||
@ -148,6 +146,6 @@ public:
|
||||
int Parse(const std::string& fileName);
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace ddlpackage
|
||||
|
||||
#undef EXPORT
|
||||
|
@ -44,4 +44,4 @@ ostream& operator<<(ostream& os, const SqlStatement& stmt)
|
||||
{
|
||||
return stmt.put(os);
|
||||
}
|
||||
}
|
||||
} // namespace ddlpackage
|
||||
|
@ -29,7 +29,6 @@ namespace ddlpackage
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
|
||||
ostream& operator<<(ostream& os, const SqlStatementList& ssl)
|
||||
{
|
||||
vector<SqlStatement*>::const_iterator itr;
|
||||
@ -43,13 +42,11 @@ ostream& operator<<(ostream& os, const SqlStatementList& ssl)
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
void SqlStatementList::push_back(SqlStatement* v)
|
||||
{
|
||||
fList.push_back(v);
|
||||
}
|
||||
|
||||
|
||||
SqlStatementList::~SqlStatementList()
|
||||
{
|
||||
vector<SqlStatement*>::iterator itr;
|
||||
@ -60,4 +57,4 @@ SqlStatementList::~SqlStatementList()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace ddlpackage
|
||||
|
@ -30,7 +30,6 @@ namespace ddlpackage
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
|
||||
TableDef::~TableDef()
|
||||
{
|
||||
{
|
||||
@ -53,9 +52,8 @@ TableDef::~TableDef()
|
||||
delete fQualifiedName;
|
||||
}
|
||||
|
||||
|
||||
TableDef::TableDef(QualifiedName* name, TableElementList* elements, TableOptionMap* options) :
|
||||
fQualifiedName(name)
|
||||
TableDef::TableDef(QualifiedName* name, TableElementList* elements, TableOptionMap* options)
|
||||
: fQualifiedName(name)
|
||||
{
|
||||
if (options)
|
||||
{
|
||||
@ -94,7 +92,6 @@ TableDef::TableDef(QualifiedName* name, TableElementList* elements, TableOptionM
|
||||
delete elements;
|
||||
}
|
||||
|
||||
|
||||
/** \brief Put to ostream. */
|
||||
ostream& operator<<(ostream& os, const TableDef& tableDef)
|
||||
{
|
||||
@ -102,29 +99,23 @@ ostream& operator<<(ostream& os, const TableDef& tableDef)
|
||||
|
||||
if (tableDef.fQualifiedName->fSchema != "")
|
||||
// cout << tableDef.fQualifiedName->fSchema << ".";
|
||||
os << tableDef.fQualifiedName->fName
|
||||
<< " " << tableDef.fConstraints.size()
|
||||
<< " table constraints"
|
||||
os << tableDef.fQualifiedName->fName << " " << tableDef.fConstraints.size() << " table constraints"
|
||||
<< endl;
|
||||
|
||||
{
|
||||
ColumnDefList::const_iterator itr;
|
||||
|
||||
for (itr = tableDef.fColumns.begin();
|
||||
itr != tableDef.fColumns.end(); ++itr)
|
||||
for (itr = tableDef.fColumns.begin(); itr != tableDef.fColumns.end(); ++itr)
|
||||
{
|
||||
ColumnDef* col = *itr;
|
||||
os << *col << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
TableConstraintDefList::const_iterator itr;
|
||||
|
||||
for (itr = tableDef.fConstraints.begin();
|
||||
itr != tableDef.fConstraints.end();
|
||||
++itr)
|
||||
for (itr = tableDef.fConstraints.begin(); itr != tableDef.fConstraints.end(); ++itr)
|
||||
{
|
||||
os << (**itr);
|
||||
}
|
||||
@ -138,8 +129,7 @@ ostream& operator<<(ostream& os, const TableDef& tableDef)
|
||||
{
|
||||
TableOptionMap::const_iterator oitr;
|
||||
|
||||
for (oitr = tableDef.fOptions.begin();
|
||||
oitr != tableDef.fOptions.end(); ++oitr)
|
||||
for (oitr = tableDef.fOptions.begin(); oitr != tableDef.fOptions.end(); ++oitr)
|
||||
{
|
||||
oval = *oitr;
|
||||
os << " " << oval.first << "=" << oval.second << endl;
|
||||
@ -149,9 +139,6 @@ ostream& operator<<(ostream& os, const TableDef& tableDef)
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ostream& operator<<(ostream& os, const TableConstraintDef& constraint)
|
||||
{
|
||||
return constraint.put(os);
|
||||
@ -164,51 +151,40 @@ std::ostream& TableConstraintDef::put(std::ostream& os) const
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
TableConstraintDef::TableConstraintDef(DDL_CONSTRAINTS cType) :
|
||||
fConstraintType(cType)
|
||||
TableConstraintDef::TableConstraintDef(DDL_CONSTRAINTS cType) : fConstraintType(cType)
|
||||
{
|
||||
}
|
||||
|
||||
TableConstraintDef::TableConstraintDef() :
|
||||
fConstraintType(DDL_INVALID_CONSTRAINT)
|
||||
TableConstraintDef::TableConstraintDef() : fConstraintType(DDL_INVALID_CONSTRAINT)
|
||||
{
|
||||
}
|
||||
|
||||
TableCheckConstraintDef::TableCheckConstraintDef(const char* check) :
|
||||
TableConstraintDef(DDL_CHECK),
|
||||
fCheck(check)
|
||||
TableCheckConstraintDef::TableCheckConstraintDef(const char* check)
|
||||
: TableConstraintDef(DDL_CHECK), fCheck(check)
|
||||
{
|
||||
}
|
||||
std::ostream& TableCheckConstraintDef::put(std::ostream& os) const
|
||||
{
|
||||
os << "Constraint: "
|
||||
<< ConstraintString[fConstraintType] << " ";
|
||||
os << "Constraint: " << ConstraintString[fConstraintType] << " ";
|
||||
os << "\"" << fCheck << "\"";
|
||||
os << endl;
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
TableUniqueConstraintDef::TableUniqueConstraintDef(ColumnNameList* columns) :
|
||||
TableConstraintDef(DDL_UNIQUE),
|
||||
fColumnNameList(*columns)
|
||||
TableUniqueConstraintDef::TableUniqueConstraintDef(ColumnNameList* columns)
|
||||
: TableConstraintDef(DDL_UNIQUE), fColumnNameList(*columns)
|
||||
{
|
||||
delete columns;
|
||||
}
|
||||
std::ostream& TableUniqueConstraintDef::put(std::ostream& os) const
|
||||
{
|
||||
os << "Constraint: "
|
||||
<< fName << " "
|
||||
<< ConstraintString[fConstraintType] << " ";
|
||||
os << "Constraint: " << fName << " " << ConstraintString[fConstraintType] << " ";
|
||||
|
||||
ColumnNameList::const_iterator itr;
|
||||
os << "(";
|
||||
|
||||
for (itr = fColumnNameList.begin();
|
||||
itr != fColumnNameList.end();
|
||||
++itr)
|
||||
for (itr = fColumnNameList.begin(); itr != fColumnNameList.end(); ++itr)
|
||||
{
|
||||
os << *itr << " ";
|
||||
}
|
||||
@ -217,24 +193,19 @@ std::ostream& TableUniqueConstraintDef::put(std::ostream& os) const
|
||||
return os;
|
||||
}
|
||||
|
||||
TablePrimaryKeyConstraintDef::TablePrimaryKeyConstraintDef(ColumnNameList* columns) :
|
||||
TableConstraintDef(DDL_PRIMARY_KEY),
|
||||
fColumnNameList(*columns)
|
||||
TablePrimaryKeyConstraintDef::TablePrimaryKeyConstraintDef(ColumnNameList* columns)
|
||||
: TableConstraintDef(DDL_PRIMARY_KEY), fColumnNameList(*columns)
|
||||
{
|
||||
delete columns;
|
||||
}
|
||||
std::ostream& TablePrimaryKeyConstraintDef::put(std::ostream& os) const
|
||||
{
|
||||
os << "Constraint: "
|
||||
<< fName << " "
|
||||
<< ConstraintString[fConstraintType] << " ";
|
||||
os << "Constraint: " << fName << " " << ConstraintString[fConstraintType] << " ";
|
||||
|
||||
ColumnNameList::const_iterator itr;
|
||||
os << "(";
|
||||
|
||||
for (itr = fColumnNameList.begin();
|
||||
itr != fColumnNameList.end();
|
||||
++itr)
|
||||
for (itr = fColumnNameList.begin(); itr != fColumnNameList.end(); ++itr)
|
||||
{
|
||||
os << *itr << " ";
|
||||
}
|
||||
@ -244,34 +215,28 @@ std::ostream& TablePrimaryKeyConstraintDef::put(std::ostream& os) const
|
||||
return os;
|
||||
}
|
||||
|
||||
TableReferencesConstraintDef::TableReferencesConstraintDef
|
||||
(ColumnNameList* columns,
|
||||
QualifiedName* tableName,
|
||||
TableReferencesConstraintDef::TableReferencesConstraintDef(ColumnNameList* columns, QualifiedName* tableName,
|
||||
ColumnNameList* foreignColumns,
|
||||
DDL_MATCH_TYPE matchType,
|
||||
ReferentialAction* refAction) :
|
||||
TableConstraintDef(DDL_REFERENCES),
|
||||
fColumns(*columns),
|
||||
fTableName(tableName),
|
||||
fForeignColumns(*foreignColumns),
|
||||
fMatchType(matchType),
|
||||
fRefAction(refAction)
|
||||
ReferentialAction* refAction)
|
||||
: TableConstraintDef(DDL_REFERENCES)
|
||||
, fColumns(*columns)
|
||||
, fTableName(tableName)
|
||||
, fForeignColumns(*foreignColumns)
|
||||
, fMatchType(matchType)
|
||||
, fRefAction(refAction)
|
||||
{
|
||||
delete columns;
|
||||
delete foreignColumns;
|
||||
}
|
||||
std::ostream& TableReferencesConstraintDef::put(std::ostream& os) const
|
||||
{
|
||||
os << "Constraint: "
|
||||
<< fName << " "
|
||||
<< ConstraintString[fConstraintType] << " ";
|
||||
os << "Constraint: " << fName << " " << ConstraintString[fConstraintType] << " ";
|
||||
|
||||
ColumnNameList::const_iterator itr;
|
||||
os << "lcols (";
|
||||
|
||||
for (itr = fColumns.begin();
|
||||
itr != fColumns.end();
|
||||
++itr)
|
||||
for (itr = fColumns.begin(); itr != fColumns.end(); ++itr)
|
||||
{
|
||||
os << *itr << " ";
|
||||
}
|
||||
@ -284,9 +249,7 @@ std::ostream& TableReferencesConstraintDef::put(std::ostream& os) const
|
||||
|
||||
os << "fcols (";
|
||||
|
||||
for (itr = fForeignColumns.begin();
|
||||
itr != fForeignColumns.end();
|
||||
++itr)
|
||||
for (itr = fForeignColumns.begin(); itr != fForeignColumns.end(); ++itr)
|
||||
{
|
||||
os << *itr << " ";
|
||||
}
|
||||
@ -300,9 +263,7 @@ std::ostream& operator<<(std::ostream& os, const ColumnNameList& columnNames)
|
||||
ColumnNameList::const_iterator itr;
|
||||
os << '(';
|
||||
|
||||
for (itr = columnNames.begin();
|
||||
itr != columnNames.end();
|
||||
++itr)
|
||||
for (itr = columnNames.begin(); itr != columnNames.end(); ++itr)
|
||||
{
|
||||
os << *itr << " ";
|
||||
}
|
||||
@ -311,12 +272,10 @@ std::ostream& operator<<(std::ostream& os, const ColumnNameList& columnNames)
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
TableReferencesConstraintDef::~TableReferencesConstraintDef()
|
||||
{
|
||||
delete fTableName;
|
||||
delete fRefAction;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace ddlpackage
|
||||
|
@ -95,9 +95,8 @@ class ParserTest : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST(foo);
|
||||
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
private:
|
||||
|
||||
|
||||
public:
|
||||
void setUp()
|
||||
{
|
||||
@ -267,7 +266,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <class T>
|
||||
void u_sertest(T* x)
|
||||
{
|
||||
@ -283,14 +281,12 @@ void u_sertest(T* x)
|
||||
|
||||
cout << "String Compare" << endl;
|
||||
cout << "------------------" << endl;
|
||||
cout << s1.str() << endl
|
||||
<< s2.str() << endl;
|
||||
cout << s1.str() << endl << s2.str() << endl;
|
||||
cout << "------------------" << endl;
|
||||
|
||||
CPPUNIT_ASSERT(s1.str() == s2.str());
|
||||
}
|
||||
|
||||
|
||||
/** @brief Just like u_sertest except that a typecode is pulled off
|
||||
the ByteStream before the unserialize. */
|
||||
template <class T>
|
||||
@ -312,17 +308,14 @@ void t_sertest(T* x)
|
||||
|
||||
cout << "String Compare" << endl;
|
||||
cout << "------------------" << endl;
|
||||
cout << s1.str() << endl
|
||||
<< s2.str() << endl;
|
||||
cout << s1.str() << endl << s2.str() << endl;
|
||||
cout << "------------------" << endl;
|
||||
|
||||
CPPUNIT_ASSERT(s1.str() == s2.str());
|
||||
}
|
||||
|
||||
|
||||
class SerializeTest : public CppUnit::TestFixture
|
||||
{
|
||||
|
||||
CPPUNIT_TEST_SUITE(SerializeTest);
|
||||
CPPUNIT_TEST(qname);
|
||||
CPPUNIT_TEST(columntype);
|
||||
@ -357,18 +350,14 @@ class SerializeTest : public CppUnit::TestFixture
|
||||
|
||||
CPPUNIT_TEST(altertablerenamecolumn);
|
||||
|
||||
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
private:
|
||||
|
||||
|
||||
public:
|
||||
void setUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void tearDown()
|
||||
{
|
||||
}
|
||||
@ -387,7 +376,6 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void altertablemodifycolumntype()
|
||||
{
|
||||
SqlFileParser p;
|
||||
@ -402,7 +390,6 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void altertablerenametable()
|
||||
{
|
||||
SqlFileParser p;
|
||||
@ -459,7 +446,6 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void altertabledropcolumn()
|
||||
{
|
||||
SqlFileParser p;
|
||||
@ -488,7 +474,6 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void altertableaddcolumn()
|
||||
{
|
||||
cout << "Serialize test: AtaAddColumn" << endl;
|
||||
@ -524,9 +509,7 @@ public:
|
||||
|
||||
ColumnDefList::const_iterator itr;
|
||||
|
||||
for (itr = columns->begin();
|
||||
itr != columns->end();
|
||||
++itr)
|
||||
for (itr = columns->begin(); itr != columns->end(); ++itr)
|
||||
{
|
||||
ata->fColumnDef = *itr;
|
||||
t_sertest<AtaAddColumn>(ata.get());
|
||||
@ -578,7 +561,6 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void altertabledropcolumns()
|
||||
{
|
||||
ColumnNameList* names = new ColumnNameList;
|
||||
@ -588,7 +570,6 @@ public:
|
||||
t_sertest<AtaDropColumns>(stmt.get());
|
||||
}
|
||||
|
||||
|
||||
void qname()
|
||||
{
|
||||
cout << "Serialize test: QualifiedName" << endl;
|
||||
@ -596,7 +577,6 @@ public:
|
||||
u_sertest<QualifiedName>(name.get());
|
||||
}
|
||||
|
||||
|
||||
void columntype()
|
||||
{
|
||||
cout << "Serialize test: ColumnType" << endl;
|
||||
@ -682,15 +662,12 @@ public:
|
||||
|
||||
ColumnDefList::const_iterator itr;
|
||||
|
||||
for (itr = columns->begin();
|
||||
itr != columns->end();
|
||||
++itr)
|
||||
for (itr = columns->begin(); itr != columns->end(); ++itr)
|
||||
{
|
||||
u_sertest<ColumnDef>(*itr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void referentialaction()
|
||||
@ -749,7 +726,6 @@ public:
|
||||
qname->fName = "table_fooby";
|
||||
tc->fTableName = qname;
|
||||
|
||||
|
||||
tc->fForeignColumns.push_back("F1");
|
||||
tc->fForeignColumns.push_back("F2");
|
||||
tc->fForeignColumns.push_back("F3");
|
||||
@ -801,10 +777,8 @@ public:
|
||||
u_sertest<TableDef>(ct->fTableDef);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void createtable()
|
||||
{
|
||||
vector<string> files;
|
||||
@ -933,7 +907,6 @@ CPPUNIT_TEST_SUITE_REGISTRATION(ParserTest);
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
|
||||
CppUnit::TextUi::TestRunner runner;
|
||||
CppUnit::TestFactoryRegistry& registry = CppUnit::TestFactoryRegistry::getRegistry();
|
||||
runner.addTest(registry.makeTest());
|
||||
@ -941,7 +914,6 @@ int main(int argc, char* argv[])
|
||||
bool wasSuccessful = runner.run("", false);
|
||||
|
||||
return (wasSuccessful ? 0 : 1);
|
||||
|
||||
}
|
||||
|
||||
string itoa(const int i)
|
||||
@ -950,4 +922,3 @@ string itoa(const int i)
|
||||
ss << i;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
|
@ -62,14 +62,13 @@ using namespace cacheutils;
|
||||
#include "IDBPolicy.h"
|
||||
using namespace idbdatafile;
|
||||
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wpotentially-evaluated-expression"
|
||||
// for warnings on typeid :expression with side effects will be evaluated despite being used as an operand to 'typeid'
|
||||
// for warnings on typeid :expression with side effects will be evaluated despite being used as an operand to
|
||||
// 'typeid'
|
||||
#endif
|
||||
|
||||
|
||||
// TODO: this should be in a common header somewhere
|
||||
struct extentInfo
|
||||
{
|
||||
@ -88,19 +87,20 @@ struct extentInfo
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
bool typesAreSame(const CalpontSystemCatalog::ColType& colType, const ColumnType& newType)
|
||||
{
|
||||
switch (colType.colDataType)
|
||||
{
|
||||
case (CalpontSystemCatalog::BIT):
|
||||
if (newType.fType == DDL_BIT) return true;
|
||||
if (newType.fType == DDL_BIT)
|
||||
return true;
|
||||
|
||||
break;
|
||||
|
||||
case (CalpontSystemCatalog::TINYINT):
|
||||
if (newType.fType == DDL_TINYINT && colType.precision == newType.fPrecision &&
|
||||
colType.scale == newType.fScale) return true;
|
||||
colType.scale == newType.fScale)
|
||||
return true;
|
||||
|
||||
//@Bug 5443 Not allow user change data type.
|
||||
// Not sure this is possible...
|
||||
@ -110,18 +110,21 @@ bool typesAreSame(const CalpontSystemCatalog::ColType& colType, const ColumnType
|
||||
|
||||
case (CalpontSystemCatalog::UTINYINT):
|
||||
if (newType.fType == DDL_UNSIGNED_TINYINT && colType.precision == newType.fPrecision &&
|
||||
colType.scale == newType.fScale) return true;
|
||||
colType.scale == newType.fScale)
|
||||
return true;
|
||||
|
||||
break;
|
||||
|
||||
case (CalpontSystemCatalog::CHAR):
|
||||
if (newType.fType == DDL_CHAR && colType.colWidth == newType.fLength) return true;
|
||||
if (newType.fType == DDL_CHAR && colType.colWidth == newType.fLength)
|
||||
return true;
|
||||
|
||||
break;
|
||||
|
||||
case (CalpontSystemCatalog::SMALLINT):
|
||||
if (newType.fType == DDL_SMALLINT && colType.precision == newType.fPrecision &&
|
||||
colType.scale == newType.fScale) return true;
|
||||
colType.scale == newType.fScale)
|
||||
return true;
|
||||
|
||||
// if (newType.fType == DDL_DECIMAL && colType.precision == newType.fPrecision &&
|
||||
// colType.scale == newType.fScale) return true;
|
||||
@ -129,7 +132,8 @@ bool typesAreSame(const CalpontSystemCatalog::ColType& colType, const ColumnType
|
||||
|
||||
case (CalpontSystemCatalog::USMALLINT):
|
||||
if (newType.fType == DDL_UNSIGNED_SMALLINT && colType.precision == newType.fPrecision &&
|
||||
colType.scale == newType.fScale) return true;
|
||||
colType.scale == newType.fScale)
|
||||
return true;
|
||||
|
||||
break;
|
||||
|
||||
@ -149,7 +153,8 @@ bool typesAreSame(const CalpontSystemCatalog::ColType& colType, const ColumnType
|
||||
|
||||
case (CalpontSystemCatalog::MEDINT):
|
||||
if (newType.fType == DDL_MEDINT && colType.precision == newType.fPrecision &&
|
||||
colType.scale == newType.fScale) return true;
|
||||
colType.scale == newType.fScale)
|
||||
return true;
|
||||
|
||||
//@Bug 5443 Not allow user change data type.
|
||||
// if (newType.fType == DDL_DECIMAL && colType.precision == newType.fPrecision &&
|
||||
@ -158,13 +163,15 @@ bool typesAreSame(const CalpontSystemCatalog::ColType& colType, const ColumnType
|
||||
|
||||
case (CalpontSystemCatalog::UMEDINT):
|
||||
if (newType.fType == DDL_UNSIGNED_MEDINT && colType.precision == newType.fPrecision &&
|
||||
colType.scale == newType.fScale) return true;
|
||||
colType.scale == newType.fScale)
|
||||
return true;
|
||||
|
||||
break;
|
||||
|
||||
case (CalpontSystemCatalog::INT):
|
||||
if (newType.fType == DDL_INT && colType.precision == newType.fPrecision &&
|
||||
colType.scale == newType.fScale) return true;
|
||||
colType.scale == newType.fScale)
|
||||
return true;
|
||||
|
||||
// if (newType.fType == DDL_DECIMAL && colType.precision == newType.fPrecision &&
|
||||
// colType.scale == newType.fScale) return true;
|
||||
@ -172,28 +179,33 @@ bool typesAreSame(const CalpontSystemCatalog::ColType& colType, const ColumnType
|
||||
|
||||
case (CalpontSystemCatalog::UINT):
|
||||
if (newType.fType == DDL_UNSIGNED_INT && colType.precision == newType.fPrecision &&
|
||||
colType.scale == newType.fScale) return true;
|
||||
colType.scale == newType.fScale)
|
||||
return true;
|
||||
|
||||
break;
|
||||
|
||||
case (CalpontSystemCatalog::FLOAT):
|
||||
if (newType.fType == DDL_FLOAT) return true;
|
||||
if (newType.fType == DDL_FLOAT)
|
||||
return true;
|
||||
|
||||
break;
|
||||
|
||||
case (CalpontSystemCatalog::UFLOAT):
|
||||
if (newType.fType == DDL_UNSIGNED_FLOAT) return true;
|
||||
if (newType.fType == DDL_UNSIGNED_FLOAT)
|
||||
return true;
|
||||
|
||||
break;
|
||||
|
||||
case (CalpontSystemCatalog::DATE):
|
||||
if (newType.fType == DDL_DATE) return true;
|
||||
if (newType.fType == DDL_DATE)
|
||||
return true;
|
||||
|
||||
break;
|
||||
|
||||
case (CalpontSystemCatalog::BIGINT):
|
||||
if (newType.fType == DDL_BIGINT && colType.precision == newType.fPrecision &&
|
||||
colType.scale == newType.fScale) return true;
|
||||
colType.scale == newType.fScale)
|
||||
return true;
|
||||
|
||||
//@Bug 5443 Not allow user change data type.
|
||||
// decimal is mapped to bigint in syscat
|
||||
@ -203,87 +215,92 @@ bool typesAreSame(const CalpontSystemCatalog::ColType& colType, const ColumnType
|
||||
|
||||
case (CalpontSystemCatalog::UBIGINT):
|
||||
if (newType.fType == DDL_UNSIGNED_BIGINT && colType.precision == newType.fPrecision &&
|
||||
colType.scale == newType.fScale) return true;
|
||||
colType.scale == newType.fScale)
|
||||
return true;
|
||||
|
||||
break;
|
||||
|
||||
case (CalpontSystemCatalog::DOUBLE):
|
||||
if (newType.fType == DDL_DOUBLE) return true;
|
||||
if (newType.fType == DDL_DOUBLE)
|
||||
return true;
|
||||
|
||||
break;
|
||||
|
||||
case (CalpontSystemCatalog::UDOUBLE):
|
||||
if (newType.fType == DDL_UNSIGNED_DOUBLE) return true;
|
||||
if (newType.fType == DDL_UNSIGNED_DOUBLE)
|
||||
return true;
|
||||
|
||||
break;
|
||||
|
||||
case (CalpontSystemCatalog::DATETIME):
|
||||
if (newType.fType == DDL_DATETIME) return true;
|
||||
if (newType.fType == DDL_DATETIME)
|
||||
return true;
|
||||
|
||||
break;
|
||||
|
||||
case (CalpontSystemCatalog::TIMESTAMP):
|
||||
if (newType.fType == DDL_TIMESTAMP) return true;
|
||||
if (newType.fType == DDL_TIMESTAMP)
|
||||
return true;
|
||||
|
||||
break;
|
||||
|
||||
case (CalpontSystemCatalog::TIME):
|
||||
if (newType.fType == DDL_TIME) return true;
|
||||
if (newType.fType == DDL_TIME)
|
||||
return true;
|
||||
|
||||
break;
|
||||
|
||||
case (CalpontSystemCatalog::VARCHAR):
|
||||
if (newType.fType == DDL_VARCHAR && colType.colWidth == newType.fLength) return true;
|
||||
if (newType.fType == DDL_VARCHAR && colType.colWidth == newType.fLength)
|
||||
return true;
|
||||
|
||||
break;
|
||||
|
||||
case (CalpontSystemCatalog::VARBINARY):
|
||||
if (newType.fType == DDL_VARBINARY && colType.colWidth == newType.fLength) return true;
|
||||
if (newType.fType == DDL_VARBINARY && colType.colWidth == newType.fLength)
|
||||
return true;
|
||||
|
||||
break;
|
||||
|
||||
case (CalpontSystemCatalog::CLOB):
|
||||
break;
|
||||
case (CalpontSystemCatalog::CLOB): break;
|
||||
|
||||
case (CalpontSystemCatalog::BLOB):
|
||||
if (newType.fType == DDL_BLOB && colType.colWidth == newType.fLength) return true;
|
||||
if (newType.fType == DDL_BLOB && colType.colWidth == newType.fLength)
|
||||
return true;
|
||||
|
||||
break;
|
||||
|
||||
case (CalpontSystemCatalog::TEXT):
|
||||
if (newType.fType == DDL_TEXT && colType.colWidth == newType.fLength) return true;
|
||||
if (newType.fType == DDL_TEXT && colType.colWidth == newType.fLength)
|
||||
return true;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool comptypesAreCompat(int oldCtype, int newCtype)
|
||||
{
|
||||
switch (oldCtype)
|
||||
{
|
||||
case 1:
|
||||
case 2:
|
||||
return (newCtype == 1 || newCtype == 2);
|
||||
case 2: return (newCtype == 1 || newCtype == 2);
|
||||
|
||||
default:
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
return (oldCtype == newCtype);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace ddlpackageprocessor
|
||||
{
|
||||
|
||||
AlterTableProcessor::DDLResult AlterTableProcessor::processPackage(ddlpackage::AlterTableStatement& alterTableStmt)
|
||||
AlterTableProcessor::DDLResult AlterTableProcessor::processPackage(
|
||||
ddlpackage::AlterTableStatement& alterTableStmt)
|
||||
{
|
||||
SUMMARY_INFO("AlterTableProcessor::processPackage");
|
||||
|
||||
@ -352,7 +369,8 @@ AlterTableProcessor::DDLResult AlterTableProcessor::processPackage(ddlpackage::A
|
||||
try
|
||||
{
|
||||
// check table lock
|
||||
boost::shared_ptr<CalpontSystemCatalog> systemCatalogPtr = CalpontSystemCatalog::makeCalpontSystemCatalog(alterTableStmt.fSessionID);
|
||||
boost::shared_ptr<CalpontSystemCatalog> systemCatalogPtr =
|
||||
CalpontSystemCatalog::makeCalpontSystemCatalog(alterTableStmt.fSessionID);
|
||||
systemCatalogPtr->identity(CalpontSystemCatalog::EC);
|
||||
systemCatalogPtr->sessionID(alterTableStmt.fSessionID);
|
||||
CalpontSystemCatalog::TableName tableName;
|
||||
@ -376,7 +394,8 @@ AlterTableProcessor::DDLResult AlterTableProcessor::processPackage(ddlpackage::A
|
||||
|
||||
try
|
||||
{
|
||||
tableLockId = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, &sessionId, &txnid, BRM::LOADING );
|
||||
tableLockId =
|
||||
fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, &sessionId, &txnid, BRM::LOADING);
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
@ -406,8 +425,7 @@ AlterTableProcessor::DDLResult AlterTableProcessor::processPackage(ddlpackage::A
|
||||
{
|
||||
abs_ts.tv_sec = rm_ts.tv_sec;
|
||||
abs_ts.tv_nsec = rm_ts.tv_nsec;
|
||||
}
|
||||
while (nanosleep(&abs_ts, &rm_ts) < 0);
|
||||
} while (nanosleep(&abs_ts, &rm_ts) < 0);
|
||||
|
||||
#endif
|
||||
|
||||
@ -415,9 +433,11 @@ AlterTableProcessor::DDLResult AlterTableProcessor::processPackage(ddlpackage::A
|
||||
{
|
||||
processID = ::getpid();
|
||||
txnid = txnID.id;
|
||||
sessionId = alterTableStmt.fSessionID;;
|
||||
sessionId = alterTableStmt.fSessionID;
|
||||
;
|
||||
processName = "DDLProc";
|
||||
tableLockId = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, &sessionId, &txnid, BRM::LOADING );
|
||||
tableLockId = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, &sessionId, &txnid,
|
||||
BRM::LOADING);
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
@ -465,19 +485,21 @@ AlterTableProcessor::DDLResult AlterTableProcessor::processPackage(ddlpackage::A
|
||||
columnDefPtr = addColumns.fColumns[0];
|
||||
}
|
||||
|
||||
addColumn (alterTableStmt.fSessionID, txnID.id, result, columnDefPtr, *(alterTableStmt.fTableName), uniqueId);
|
||||
addColumn(alterTableStmt.fSessionID, txnID.id, result, columnDefPtr, *(alterTableStmt.fTableName),
|
||||
uniqueId);
|
||||
|
||||
if (result.result != NO_ERROR)
|
||||
{
|
||||
err = "AlterTable: add column failed";
|
||||
throw std::runtime_error(err);
|
||||
}
|
||||
|
||||
}
|
||||
else if (s.find(AlterActionString[6]) != string::npos)
|
||||
{
|
||||
// Drop Column Default
|
||||
dropColumnDefault (alterTableStmt.fSessionID, txnID.id, result, *(dynamic_cast<AtaDropColumnDefault*> (*action_iterator)), *(alterTableStmt.fTableName), uniqueId);
|
||||
dropColumnDefault(alterTableStmt.fSessionID, txnID.id, result,
|
||||
*(dynamic_cast<AtaDropColumnDefault*>(*action_iterator)),
|
||||
*(alterTableStmt.fTableName), uniqueId);
|
||||
|
||||
if (result.result != NO_ERROR)
|
||||
{
|
||||
@ -488,13 +510,15 @@ AlterTableProcessor::DDLResult AlterTableProcessor::processPackage(ddlpackage::A
|
||||
else if (s.find(AlterActionString[3]) != string::npos)
|
||||
{
|
||||
// Drop Columns
|
||||
dropColumns (alterTableStmt.fSessionID, txnID.id, result, *(dynamic_cast<AtaDropColumns*> (*action_iterator)), *(alterTableStmt.fTableName), uniqueId);
|
||||
dropColumns(alterTableStmt.fSessionID, txnID.id, result,
|
||||
*(dynamic_cast<AtaDropColumns*>(*action_iterator)), *(alterTableStmt.fTableName),
|
||||
uniqueId);
|
||||
}
|
||||
else if (s.find(AlterActionString[2]) != string::npos)
|
||||
{
|
||||
// Drop a column
|
||||
dropColumn (alterTableStmt.fSessionID, txnID.id, result, *(dynamic_cast<AtaDropColumn*> (*action_iterator)), *(alterTableStmt.fTableName), uniqueId);
|
||||
|
||||
dropColumn(alterTableStmt.fSessionID, txnID.id, result,
|
||||
*(dynamic_cast<AtaDropColumn*>(*action_iterator)), *(alterTableStmt.fTableName), uniqueId);
|
||||
}
|
||||
|
||||
#if 0
|
||||
@ -509,8 +533,9 @@ AlterTableProcessor::DDLResult AlterTableProcessor::processPackage(ddlpackage::A
|
||||
else if (s.find(AlterActionString[5]) != string::npos)
|
||||
{
|
||||
// Set Column Default
|
||||
setColumnDefault (alterTableStmt.fSessionID, txnID.id, result, *(dynamic_cast<AtaSetColumnDefault*> (*action_iterator)), *(alterTableStmt.fTableName), uniqueId);
|
||||
|
||||
setColumnDefault(alterTableStmt.fSessionID, txnID.id, result,
|
||||
*(dynamic_cast<AtaSetColumnDefault*>(*action_iterator)),
|
||||
*(alterTableStmt.fTableName), uniqueId);
|
||||
}
|
||||
|
||||
#if 0
|
||||
@ -526,29 +551,31 @@ AlterTableProcessor::DDLResult AlterTableProcessor::processPackage(ddlpackage::A
|
||||
else if (s.find(AlterActionString[8]) != string::npos)
|
||||
{
|
||||
// Rename Table
|
||||
renameTable (alterTableStmt.fSessionID, txnID.id, result, *(dynamic_cast<AtaRenameTable*> (*action_iterator)), *(alterTableStmt.fTableName), uniqueId);
|
||||
|
||||
renameTable(alterTableStmt.fSessionID, txnID.id, result,
|
||||
*(dynamic_cast<AtaRenameTable*>(*action_iterator)), *(alterTableStmt.fTableName),
|
||||
uniqueId);
|
||||
}
|
||||
|
||||
else if (s.find(AlterActionString[10]) != string::npos)
|
||||
{
|
||||
// Rename a Column
|
||||
renameColumn (alterTableStmt.fSessionID, txnID.id, result, *(dynamic_cast<AtaRenameColumn*> (*action_iterator)), *(alterTableStmt.fTableName), uniqueId);
|
||||
|
||||
renameColumn(alterTableStmt.fSessionID, txnID.id, result,
|
||||
*(dynamic_cast<AtaRenameColumn*>(*action_iterator)), *(alterTableStmt.fTableName),
|
||||
uniqueId);
|
||||
}
|
||||
else if (s.find(AlterActionString[11]) != string::npos)
|
||||
{
|
||||
// Table Comment
|
||||
tableComment (alterTableStmt.fSessionID, txnID.id, result, *(dynamic_cast<AtaTableComment*> (*action_iterator)), *(alterTableStmt.fTableName), uniqueId);
|
||||
tableComment(alterTableStmt.fSessionID, txnID.id, result,
|
||||
*(dynamic_cast<AtaTableComment*>(*action_iterator)), *(alterTableStmt.fTableName),
|
||||
uniqueId);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error("Altertable: Error in the action type");
|
||||
|
||||
}
|
||||
|
||||
++action_iterator;
|
||||
|
||||
}
|
||||
|
||||
// Log the DDL statement.
|
||||
@ -591,11 +618,10 @@ AlterTableProcessor::DDLResult AlterTableProcessor::processPackage(ddlpackage::A
|
||||
|
||||
fWEClient->removeQueue(uniqueId);
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
void AlterTableProcessor::rollBackAlter(const string& error, BRM::TxnID txnID,
|
||||
int sessionId, DDLResult& result, uint64_t uniqueId)
|
||||
void AlterTableProcessor::rollBackAlter(const string& error, BRM::TxnID txnID, int sessionId,
|
||||
DDLResult& result, uint64_t uniqueId)
|
||||
{
|
||||
DETAIL_INFO("Rolling back transaction");
|
||||
cerr << "AltertableProcessor::processPackage: " << error << endl;
|
||||
@ -614,8 +640,9 @@ void AlterTableProcessor::rollBackAlter(const string& error, BRM::TxnID txnID,
|
||||
result.message = message;
|
||||
}
|
||||
|
||||
void AlterTableProcessor::addColumn (uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
ddlpackage::ColumnDef* columnDefPtr, ddlpackage::QualifiedName& inTableName, const uint64_t uniqueId)
|
||||
void AlterTableProcessor::addColumn(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
||||
DDLResult& result, ddlpackage::ColumnDef* columnDefPtr,
|
||||
ddlpackage::QualifiedName& inTableName, const uint64_t uniqueId)
|
||||
{
|
||||
std::string err("AlterTableProcessor::addColumn ");
|
||||
SUMMARY_INFO(err);
|
||||
@ -657,8 +684,8 @@ void AlterTableProcessor::addColumn (uint32_t sessionID, execplan::CalpontSystem
|
||||
|
||||
if (columnOid > 0) // Column exists already
|
||||
{
|
||||
err = err + "Internal add column error for " + tableColName.schema + "." + tableColName.table + "." + tableColName.column
|
||||
+ ". Column exists already. Your table is probably out-of-sync";
|
||||
err = err + "Internal add column error for " + tableColName.schema + "." + tableColName.table + "." +
|
||||
tableColName.column + ". Column exists already. Your table is probably out-of-sync";
|
||||
|
||||
throw std::runtime_error(err);
|
||||
}
|
||||
@ -716,18 +743,15 @@ void AlterTableProcessor::addColumn (uint32_t sessionID, execplan::CalpontSystem
|
||||
else
|
||||
{
|
||||
// Add columns to SYSTABLE and SYSCOLUMN
|
||||
if ((inTableName.fName == SYSTABLE_TABLE) &&
|
||||
(columnDefPtr->fName == AUTOINC_COL))
|
||||
if ((inTableName.fName == SYSTABLE_TABLE) && (columnDefPtr->fName == AUTOINC_COL))
|
||||
{
|
||||
fStartingColOID = OID_SYSTABLE_AUTOINCREMENT;
|
||||
}
|
||||
else if ((inTableName.fName == SYSCOLUMN_TABLE) &&
|
||||
(columnDefPtr->fName == COMPRESSIONTYPE_COL))
|
||||
else if ((inTableName.fName == SYSCOLUMN_TABLE) && (columnDefPtr->fName == COMPRESSIONTYPE_COL))
|
||||
{
|
||||
fStartingColOID = OID_SYSCOLUMN_COMPRESSIONTYPE;
|
||||
}
|
||||
else if ((inTableName.fName == SYSCOLUMN_TABLE) &&
|
||||
(columnDefPtr->fName == NEXTVALUE_COL))
|
||||
else if ((inTableName.fName == SYSCOLUMN_TABLE) && (columnDefPtr->fName == NEXTVALUE_COL))
|
||||
{
|
||||
fStartingColOID = OID_SYSCOLUMN_NEXTVALUE;
|
||||
}
|
||||
@ -834,7 +858,6 @@ void AlterTableProcessor::addColumn (uint32_t sessionID, execplan::CalpontSystem
|
||||
|
||||
if (rc != 0)
|
||||
throw std::runtime_error(errorMsg);
|
||||
|
||||
}
|
||||
|
||||
if ((columnDefPtr->fType->fAutoincrement).compare("y") == 0)
|
||||
@ -917,10 +940,10 @@ void AlterTableProcessor::addColumn (uint32_t sessionID, execplan::CalpontSystem
|
||||
else
|
||||
oidList.push_back(fStartingColOID);
|
||||
|
||||
|
||||
createWriteDropLogFile(ropair.objnum, uniqueId, oidList);
|
||||
|
||||
//@Bug 1358,1427 Always use the first column in the table, not the first one in columnlist to prevent random result
|
||||
//@Bug 1358,1427 Always use the first column in the table, not the first one in columnlist to prevent
|
||||
//random result
|
||||
//@Bug 4182. Use widest column as reference column
|
||||
|
||||
// Find the widest column
|
||||
@ -937,8 +960,8 @@ void AlterTableProcessor::addColumn (uint32_t sessionID, execplan::CalpontSystem
|
||||
{
|
||||
if (column_iterator->colType.colWidth == maxColwidth)
|
||||
{
|
||||
//If there is atleast one existing column then use that as a reference to initialize the new column rows.
|
||||
//get dbroot information
|
||||
// If there is atleast one existing column then use that as a reference to initialize the new column
|
||||
// rows. get dbroot information
|
||||
|
||||
// fDbrm->getStartExtent((*column_iterator).oid, dbroot, partitionNum, true);
|
||||
|
||||
@ -953,12 +976,10 @@ void AlterTableProcessor::addColumn (uint32_t sessionID, execplan::CalpontSystem
|
||||
throw std::runtime_error(oss.str());
|
||||
}
|
||||
|
||||
|
||||
int dataType1;
|
||||
dataType1 = convertDataType(columnDefPtr->fType->fType);
|
||||
|
||||
if (dataType1 == CalpontSystemCatalog::DECIMAL ||
|
||||
dataType1 == CalpontSystemCatalog::UDECIMAL)
|
||||
if (dataType1 == CalpontSystemCatalog::DECIMAL || dataType1 == CalpontSystemCatalog::UDECIMAL)
|
||||
{
|
||||
columnDefPtr->convertDecimal();
|
||||
}
|
||||
@ -1174,8 +1195,9 @@ void AlterTableProcessor::addColumn (uint32_t sessionID, execplan::CalpontSystem
|
||||
fWEClient->addQueue(uniqueId);
|
||||
}
|
||||
|
||||
void AlterTableProcessor::dropColumn (uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
ddlpackage::AtaDropColumn& ataDropColumn, ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId)
|
||||
void AlterTableProcessor::dropColumn(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
||||
DDLResult& result, ddlpackage::AtaDropColumn& ataDropColumn,
|
||||
ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId)
|
||||
{
|
||||
// 1. Get the OIDs for the column
|
||||
// 2. Get the OIDs for the dictionary
|
||||
@ -1531,9 +1553,9 @@ void AlterTableProcessor::dropColumn (uint32_t sessionID, execplan::CalpontSyste
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AlterTableProcessor::dropColumns (uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
ddlpackage::AtaDropColumns& ataDropColumns, ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId)
|
||||
void AlterTableProcessor::dropColumns(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
||||
DDLResult& result, ddlpackage::AtaDropColumns& ataDropColumns,
|
||||
ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId)
|
||||
{
|
||||
SUMMARY_INFO("AlterTableProcessor::dropColumns");
|
||||
ddlpackage::ColumnNameList colList = ataDropColumns.fColumns;
|
||||
@ -1572,7 +1594,10 @@ void AlterTableProcessor::dropColumns (uint32_t sessionID, execplan::CalpontSyst
|
||||
}
|
||||
}
|
||||
|
||||
void AlterTableProcessor::addTableConstraint (uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result, ddlpackage::AtaAddTableConstraint& ataAddTableConstraint, ddlpackage::QualifiedName& fTableName)
|
||||
void AlterTableProcessor::addTableConstraint(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
||||
DDLResult& result,
|
||||
ddlpackage::AtaAddTableConstraint& ataAddTableConstraint,
|
||||
ddlpackage::QualifiedName& fTableName)
|
||||
{
|
||||
/*TODO: Check if existing row satisfy the constraint.
|
||||
If not, the constraint will not be added. */
|
||||
@ -1601,8 +1626,10 @@ void AlterTableProcessor::addTableConstraint (uint32_t sessionID, execplan::Calp
|
||||
}
|
||||
}
|
||||
|
||||
void AlterTableProcessor::setColumnDefault (uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
ddlpackage::AtaSetColumnDefault& ataSetColumnDefault, ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId)
|
||||
void AlterTableProcessor::setColumnDefault(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
||||
DDLResult& result,
|
||||
ddlpackage::AtaSetColumnDefault& ataSetColumnDefault,
|
||||
ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId)
|
||||
{
|
||||
SUMMARY_INFO("AlterTableProcessor::setColumnDefault");
|
||||
/*Steps:
|
||||
@ -1629,7 +1656,6 @@ void AlterTableProcessor::setColumnDefault (uint32_t sessionID, execplan::Calpon
|
||||
|
||||
string err;
|
||||
|
||||
|
||||
// Update SYSCOLUMN
|
||||
bs.restart();
|
||||
bs << (ByteStream::byte)WE_SVR_UPDATE_SYSCOLUMN_DEFAULTVAL;
|
||||
@ -1689,8 +1715,10 @@ void AlterTableProcessor::setColumnDefault (uint32_t sessionID, execplan::Calpon
|
||||
if (rc != 0)
|
||||
throw std::runtime_error(errorMsg);
|
||||
}
|
||||
void AlterTableProcessor::dropColumnDefault (uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
ddlpackage::AtaDropColumnDefault& ataDropColumnDefault, ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId)
|
||||
void AlterTableProcessor::dropColumnDefault(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
||||
DDLResult& result,
|
||||
ddlpackage::AtaDropColumnDefault& ataDropColumnDefault,
|
||||
ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId)
|
||||
{
|
||||
SUMMARY_INFO("AlterTableProcessor::setColumnDefault");
|
||||
/*Steps:
|
||||
@ -1717,7 +1745,6 @@ void AlterTableProcessor::dropColumnDefault (uint32_t sessionID, execplan::Calpo
|
||||
|
||||
string err;
|
||||
|
||||
|
||||
// Update SYSCOLUMN
|
||||
bs.restart();
|
||||
bs << (ByteStream::byte)WE_SVR_UPDATE_SYSCOLUMN_DEFAULTVAL;
|
||||
@ -1862,7 +1889,8 @@ void AlterTableProcessor::dropTableConstraint (uint32_t sessionID, execplan::Cal
|
||||
}
|
||||
#endif
|
||||
|
||||
void AlterTableProcessor::renameTable (uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result, ddlpackage::AtaRenameTable& ataRenameTable,
|
||||
void AlterTableProcessor::renameTable(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
||||
DDLResult& result, ddlpackage::AtaRenameTable& ataRenameTable,
|
||||
ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId)
|
||||
{
|
||||
/*Steps:
|
||||
@ -2182,8 +2210,7 @@ void AlterTableProcessor::tableComment(uint32_t sessionID, execplan::CalpontSyst
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
if (!validated)
|
||||
@ -2241,7 +2268,6 @@ void AlterTableProcessor::tableComment(uint32_t sessionID, execplan::CalpontSyst
|
||||
|
||||
if (rc != 0)
|
||||
throw std::runtime_error(errorMsg);
|
||||
|
||||
}
|
||||
|
||||
void AlterTableProcessor::renameColumn(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
||||
@ -2273,7 +2299,6 @@ void AlterTableProcessor::renameColumn(uint32_t sessionID, execplan::CalpontSyst
|
||||
pmNum = (*dbRootPMMap)[dbRoot];
|
||||
boost::shared_ptr<messageqcpp::ByteStream> bsIn;
|
||||
|
||||
|
||||
CalpontSystemCatalog::TableName tableName;
|
||||
CalpontSystemCatalog::TableColName tableColName;
|
||||
tableColName.schema = fTableName.fSchema;
|
||||
@ -2327,7 +2352,8 @@ void AlterTableProcessor::renameColumn(uint32_t sessionID, execplan::CalpontSyst
|
||||
|
||||
CalpontSystemCatalog::TableInfo tblInfo = systemCatalogPtr->tableInfo(tableName);
|
||||
|
||||
if (((tblInfo.tablewithautoincr == 1) && (colType.autoincrement) && (ataRenameColumn.fNewType->fAutoincrement.compare("n") == 0)) ||
|
||||
if (((tblInfo.tablewithautoincr == 1) && (colType.autoincrement) &&
|
||||
(ataRenameColumn.fNewType->fAutoincrement.compare("n") == 0)) ||
|
||||
((tblInfo.tablewithautoincr == 0) && (ataRenameColumn.fNewType->fAutoincrement.compare("y") == 0)))
|
||||
{
|
||||
// update systable autoincrement column
|
||||
@ -2388,17 +2414,20 @@ void AlterTableProcessor::renameColumn(uint32_t sessionID, execplan::CalpontSyst
|
||||
throw std::runtime_error(errorMsg);
|
||||
|
||||
// change a sequence in controller
|
||||
if ((!(tblInfo.tablewithautoincr == 1) || (colType.autoincrement)) && (ataRenameColumn.fNewType->fAutoincrement.compare("y") == 0))
|
||||
if ((!(tblInfo.tablewithautoincr == 1) || (colType.autoincrement)) &&
|
||||
(ataRenameColumn.fNewType->fAutoincrement.compare("y") == 0))
|
||||
{
|
||||
fDbrm->startAISequence(ropair.objnum, ataRenameColumn.fNewType->fNextvalue, ataRenameColumn.fNewType->fLength,
|
||||
fDbrm->startAISequence(ropair.objnum, ataRenameColumn.fNewType->fNextvalue,
|
||||
ataRenameColumn.fNewType->fLength,
|
||||
convertDataType(ataRenameColumn.fNewType->fType));
|
||||
// Reset it in case there is a sequence already
|
||||
fDbrm->resetAISequence(ropair.objnum, ataRenameColumn.fNewType->fNextvalue);
|
||||
}
|
||||
|
||||
}
|
||||
else if ((tblInfo.tablewithautoincr == 1) && (colType.autoincrement) && (ataRenameColumn.fNewType->fAutoincrement.compare("y") == 0))
|
||||
{}
|
||||
else if ((tblInfo.tablewithautoincr == 1) && (colType.autoincrement) &&
|
||||
(ataRenameColumn.fNewType->fAutoincrement.compare("y") == 0))
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
fDbrm->resetAISequence(ropair.objnum, 0);
|
||||
@ -2418,10 +2447,10 @@ void AlterTableProcessor::renameColumn(uint32_t sessionID, execplan::CalpontSyst
|
||||
//@Bug 5913. for autoincrement column, find the next value from SYSCOLUMN
|
||||
long long nextVal = ataRenameColumn.fNewType->fNextvalue;
|
||||
|
||||
if ((tblInfo.tablewithautoincr == 1) && (colType.autoincrement) && (ataRenameColumn.fNewType->fAutoincrement.compare("y") == 0))
|
||||
if ((tblInfo.tablewithautoincr == 1) && (colType.autoincrement) &&
|
||||
(ataRenameColumn.fNewType->fAutoincrement.compare("y") == 0))
|
||||
nextVal = systemCatalogPtr->nextAutoIncrValue(tableName);
|
||||
|
||||
|
||||
bs << (uint64_t)nextVal;
|
||||
uint32_t nullable = 1;
|
||||
string defaultValue("");
|
||||
@ -2506,10 +2535,9 @@ void AlterTableProcessor::renameColumn(uint32_t sessionID, execplan::CalpontSyst
|
||||
err = "renameColumn:Unknown exception caught";
|
||||
throw std::runtime_error(err);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace ddlpackageprocessor
|
||||
// vim:ts=4 sw=4:
|
||||
|
||||
#ifdef __clang__
|
||||
|
@ -40,7 +40,9 @@ namespace ddlpackageprocessor
|
||||
class AlterTableProcessor : public DDLPackageProcessor
|
||||
{
|
||||
public:
|
||||
AlterTableProcessor(BRM::DBRM* aDbrm) : DDLPackageProcessor(aDbrm) {}
|
||||
AlterTableProcessor(BRM::DBRM* aDbrm) : DDLPackageProcessor(aDbrm)
|
||||
{
|
||||
}
|
||||
/** @brief process an alter table statement
|
||||
*
|
||||
* @param alterTableStmt the AlterTableStatement
|
||||
@ -53,8 +55,8 @@ public:
|
||||
* @param fTableName the QualifiedName of the table
|
||||
*/
|
||||
EXPORT void addColumn(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
ddlpackage::ColumnDef* columnDefPtr,
|
||||
ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId);
|
||||
ddlpackage::ColumnDef* columnDefPtr, ddlpackage::QualifiedName& fTableName,
|
||||
const uint64_t uniqueId);
|
||||
|
||||
/** @brief drop a column
|
||||
*
|
||||
@ -63,8 +65,8 @@ public:
|
||||
* @param fTableName the QualifiedName for the table
|
||||
*/
|
||||
EXPORT void dropColumn(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
ddlpackage::AtaDropColumn& ataDropColumn,
|
||||
ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId);
|
||||
ddlpackage::AtaDropColumn& ataDropColumn, ddlpackage::QualifiedName& fTableName,
|
||||
const uint64_t uniqueId);
|
||||
|
||||
/** @brief drop columns
|
||||
*
|
||||
@ -73,8 +75,8 @@ public:
|
||||
* @param fTableName the QualifiedName for the table
|
||||
*/
|
||||
EXPORT void dropColumns(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
ddlpackage::AtaDropColumns& ataDropColumns,
|
||||
ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId );
|
||||
ddlpackage::AtaDropColumns& ataDropColumns, ddlpackage::QualifiedName& fTableName,
|
||||
const uint64_t uniqueId);
|
||||
|
||||
/** @brief add table constraint
|
||||
*
|
||||
@ -82,8 +84,8 @@ public:
|
||||
* @param ataAddTableConstraint the AtaDropColumn object
|
||||
* @param fTableName the QualifiedName for the table
|
||||
*/
|
||||
EXPORT void addTableConstraint(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
ddlpackage::AtaAddTableConstraint& ataAddTableConstraint,
|
||||
EXPORT void addTableConstraint(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
||||
DDLResult& result, ddlpackage::AtaAddTableConstraint& ataAddTableConstraint,
|
||||
ddlpackage::QualifiedName& fTableName);
|
||||
|
||||
/** @brief set column default
|
||||
@ -92,8 +94,8 @@ public:
|
||||
* @param ataSetColumnDefault the AtaSetColumnDefault object
|
||||
* @param fTableName the QualifiedName for the table
|
||||
*/
|
||||
EXPORT void setColumnDefault(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
ddlpackage::AtaSetColumnDefault& ataSetColumnDefault,
|
||||
EXPORT void setColumnDefault(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
||||
DDLResult& result, ddlpackage::AtaSetColumnDefault& ataSetColumnDefault,
|
||||
ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId);
|
||||
|
||||
/** @brief drop column default
|
||||
@ -102,8 +104,8 @@ public:
|
||||
* @param ataDropColumnDefault the AtaDropColumnDefault object
|
||||
* @param fTableName the QualifiedName for the table
|
||||
*/
|
||||
EXPORT void dropColumnDefault(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
ddlpackage::AtaDropColumnDefault& ataDropColumnDefault,
|
||||
EXPORT void dropColumnDefault(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
||||
DDLResult& result, ddlpackage::AtaDropColumnDefault& ataDropColumnDefault,
|
||||
ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId);
|
||||
|
||||
/** @brief drop table constraint
|
||||
@ -112,7 +114,8 @@ public:
|
||||
* @param ataDropTableConstraint the AtaDropTableConstraint object
|
||||
* @param fTableName the QualifiedName for the table
|
||||
*/
|
||||
EXPORT void dropTableConstraint(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
EXPORT void dropTableConstraint(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
||||
DDLResult& result,
|
||||
ddlpackage::AtaDropTableConstraint& ataDropTableConstraint,
|
||||
ddlpackage::QualifiedName& fTableName);
|
||||
/** @brief rename a table
|
||||
@ -121,9 +124,9 @@ public:
|
||||
* @param ataRenameTable the AtaRenameTable object
|
||||
* @param fTableName the QualifiedName for the table
|
||||
*/
|
||||
EXPORT void renameTable(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
||||
DDLResult& result, ddlpackage::AtaRenameTable& ataRenameTable,
|
||||
ddlpackage::QualifiedName& fTableName, const uint64_t uniqueId);
|
||||
EXPORT void renameTable(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
ddlpackage::AtaRenameTable& ataRenameTable, ddlpackage::QualifiedName& fTableName,
|
||||
const uint64_t uniqueId);
|
||||
|
||||
/** @brief rename a column
|
||||
*
|
||||
@ -148,13 +151,12 @@ public:
|
||||
std::string fTimeZone;
|
||||
|
||||
protected:
|
||||
void rollBackAlter(const std::string& error, BRM::TxnID txnID, int sessionId, DDLResult& result, uint64_t uniqueId);
|
||||
void rollBackAlter(const std::string& error, BRM::TxnID txnID, int sessionId, DDLResult& result,
|
||||
uint64_t uniqueId);
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
} // namespace ddlpackageprocessor
|
||||
|
||||
#undef EXPORT
|
||||
|
||||
|
@ -37,8 +37,8 @@ using namespace logging;
|
||||
using namespace BRM;
|
||||
namespace ddlpackageprocessor
|
||||
{
|
||||
|
||||
CreateIndexProcessor::DDLResult CreateIndexProcessor::processPackage(ddlpackage::CreateIndexStatement& createIndexStmt)
|
||||
CreateIndexProcessor::DDLResult CreateIndexProcessor::processPackage(
|
||||
ddlpackage::CreateIndexStatement& createIndexStmt)
|
||||
{
|
||||
/*
|
||||
get OIDs for the list & tree files
|
||||
@ -65,7 +65,8 @@ CreateIndexProcessor::DDLResult CreateIndexProcessor::processPackage(ddlpackage:
|
||||
tableName.schema = (createIndexStmt.fTableName)->fSchema;
|
||||
tableName.table = (createIndexStmt.fTableName)->fName;
|
||||
CalpontSystemCatalog::ROPair roPair;
|
||||
boost::shared_ptr<CalpontSystemCatalog> systemCatalogPtr = CalpontSystemCatalog::makeCalpontSystemCatalog( createIndexStmt.fSessionID );
|
||||
boost::shared_ptr<CalpontSystemCatalog> systemCatalogPtr =
|
||||
CalpontSystemCatalog::makeCalpontSystemCatalog(createIndexStmt.fSessionID);
|
||||
|
||||
try
|
||||
{
|
||||
@ -76,7 +77,6 @@ CreateIndexProcessor::DDLResult CreateIndexProcessor::processPackage(ddlpackage:
|
||||
// store primary key name in fPKName
|
||||
fPKName = createIndexStmt.fIndexName->fName;
|
||||
return result;
|
||||
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
@ -91,7 +91,6 @@ CreateIndexProcessor::DDLResult CreateIndexProcessor::processPackage(ddlpackage:
|
||||
fPKName = createIndexStmt.fIndexName->fName;
|
||||
int err = 0;
|
||||
|
||||
|
||||
SQLLogger logger(createIndexStmt.fSql, fDDLLoggingId, createIndexStmt.fSessionID, txnID.id);
|
||||
|
||||
VERBOSE_INFO("Allocating object IDs for columns");
|
||||
@ -100,10 +99,10 @@ CreateIndexProcessor::DDLResult CreateIndexProcessor::processPackage(ddlpackage:
|
||||
// fIdxOID.listOID = oidbase;
|
||||
// fIdxOID.treeOID = ++oidbase;
|
||||
|
||||
|
||||
VERBOSE_INFO("Starting a new transaction");
|
||||
|
||||
ddlpackage::DDL_CONSTRAINTS type = createIndexStmt.fUnique ? ddlpackage::DDL_UNIQUE : ddlpackage::DDL_INVALID_CONSTRAINT;
|
||||
ddlpackage::DDL_CONSTRAINTS type =
|
||||
createIndexStmt.fUnique ? ddlpackage::DDL_UNIQUE : ddlpackage::DDL_INVALID_CONSTRAINT;
|
||||
|
||||
VERBOSE_INFO("Writing meta data to SYSINDEX");
|
||||
bool multicol = false;
|
||||
@ -122,12 +121,13 @@ CreateIndexProcessor::DDLResult CreateIndexProcessor::processPackage(ddlpackage:
|
||||
ColumnNameList::const_iterator colIter;
|
||||
int totalWidth = 0;
|
||||
DDLIndexPopulator pop(&fWriteEngine, &fSessionManager, createIndexStmt.fSessionID, txnID.id, result,
|
||||
fIdxOID, createIndexStmt.fColumnNames, *createIndexStmt.fTableName,
|
||||
type, getDebugLevel());
|
||||
fIdxOID, createIndexStmt.fColumnNames, *createIndexStmt.fTableName, type,
|
||||
getDebugLevel());
|
||||
|
||||
if (multicol)
|
||||
{
|
||||
for ( colIter = createIndexStmt.fColumnNames.begin(); colIter != createIndexStmt.fColumnNames.end(); colIter++)
|
||||
for (colIter = createIndexStmt.fColumnNames.begin(); colIter != createIndexStmt.fColumnNames.end();
|
||||
colIter++)
|
||||
{
|
||||
tableColName.column = *colIter;
|
||||
|
||||
@ -157,13 +157,15 @@ CreateIndexProcessor::DDLResult CreateIndexProcessor::processPackage(ddlpackage:
|
||||
|
||||
try
|
||||
{
|
||||
//writeSysIndexMetaData(createIndexStmt.fSessionID, txnID.id, result, *createIndexStmt.fTableName, type, createIndexStmt.fIndexName->fName, multicol);
|
||||
// writeSysIndexMetaData(createIndexStmt.fSessionID, txnID.id, result, *createIndexStmt.fTableName, type,
|
||||
// createIndexStmt.fIndexName->fName, multicol);
|
||||
|
||||
// fIdxOID values are set in writeSysIndexMetaData.
|
||||
pop.setIdxOID(fIdxOID);
|
||||
|
||||
VERBOSE_INFO("Writing meta data to SYSINDEXCOL");
|
||||
//writeSysIndexColMetaData(createIndexStmt.fSessionID, txnID.id, result,*createIndexStmt.fTableName, createIndexStmt.fColumnNames, createIndexStmt.fIndexName->fName );
|
||||
// writeSysIndexColMetaData(createIndexStmt.fSessionID, txnID.id, result,*createIndexStmt.fTableName,
|
||||
// createIndexStmt.fColumnNames, createIndexStmt.fIndexName->fName );
|
||||
|
||||
if (createIndexStmt.fUnique)
|
||||
{
|
||||
@ -187,7 +189,8 @@ CreateIndexProcessor::DDLResult CreateIndexProcessor::processPackage(ddlpackage:
|
||||
// get the columns for the SYSCONSTRAINT table
|
||||
ColumnList sysConsColumns;
|
||||
ColumnList::const_iterator sysCons_iterator;
|
||||
getColumnsForTable(createIndexStmt.fSessionID, sysConsTableName.schema, sysConsTableName.table, sysConsColumns);
|
||||
getColumnsForTable(createIndexStmt.fSessionID, sysConsTableName.schema, sysConsTableName.table,
|
||||
sysConsColumns);
|
||||
sysCons_iterator = sysConsColumns.begin();
|
||||
std::string idxData;
|
||||
|
||||
@ -267,8 +270,8 @@ CreateIndexProcessor::DDLResult CreateIndexProcessor::processPackage(ddlpackage:
|
||||
// error = fWriteEngine.insertColumnRec( txnID.id, colStructs, colValuesList, ridList );
|
||||
if (error != WriteEngine::NO_ERROR)
|
||||
{
|
||||
|
||||
return rollBackCreateIndex(errorString( "WE: Error inserting Column Record: ", error), txnID, createIndexStmt.fSessionID);
|
||||
return rollBackCreateIndex(errorString("WE: Error inserting Column Record: ", error), txnID,
|
||||
createIndexStmt.fSessionID);
|
||||
// logging::Message::Args args;
|
||||
// logging::Message message(9);
|
||||
// args.add("Error updating: ");
|
||||
@ -302,7 +305,8 @@ CreateIndexProcessor::DDLResult CreateIndexProcessor::processPackage(ddlpackage:
|
||||
// get the columns for the SYSCONSTRAINTCOL table
|
||||
ColumnList sysConsColColumns;
|
||||
ColumnList::const_iterator sysConsCol_iterator;
|
||||
getColumnsForTable(createIndexStmt.fSessionID, sysConsColTableName.schema, sysConsColTableName.table, sysConsColColumns);
|
||||
getColumnsForTable(createIndexStmt.fSessionID, sysConsColTableName.schema, sysConsColTableName.table,
|
||||
sysConsColColumns);
|
||||
// write sysconstraintcol
|
||||
sysConsCol_iterator = sysConsColColumns.begin();
|
||||
std::string colData;
|
||||
@ -327,7 +331,6 @@ CreateIndexProcessor::DDLResult CreateIndexProcessor::processPackage(ddlpackage:
|
||||
{
|
||||
colData = createIndexStmt.fColumnNames[0];
|
||||
colTupleCol.data = colData;
|
||||
|
||||
}
|
||||
else if (CONSTRAINTNAME_COL == column.tableColName.column)
|
||||
{
|
||||
@ -368,7 +371,8 @@ CreateIndexProcessor::DDLResult CreateIndexProcessor::processPackage(ddlpackage:
|
||||
// error = fWriteEngine.insertColumnRec( txnID.id, colStructsCol, colValuesListCol, ridList );
|
||||
if (error != WriteEngine::NO_ERROR)
|
||||
{
|
||||
return rollBackCreateIndex(errorString( "WE: Error inserting Column Record: ", error), txnID, createIndexStmt.fSessionID);
|
||||
return rollBackCreateIndex(errorString("WE: Error inserting Column Record: ", error), txnID,
|
||||
createIndexStmt.fSessionID);
|
||||
|
||||
/* logging::Message::Args args;
|
||||
logging::Message message(9);
|
||||
@ -393,7 +397,8 @@ CreateIndexProcessor::DDLResult CreateIndexProcessor::processPackage(ddlpackage:
|
||||
|
||||
if (err)
|
||||
{
|
||||
return rollBackCreateIndex(errorString("Write engine failed to create the new index. ", err), txnID, createIndexStmt.fSessionID);
|
||||
return rollBackCreateIndex(errorString("Write engine failed to create the new index. ", err), txnID,
|
||||
createIndexStmt.fSessionID);
|
||||
}
|
||||
|
||||
// new if BULK_LOAD close
|
||||
@ -401,10 +406,10 @@ CreateIndexProcessor::DDLResult CreateIndexProcessor::processPackage(ddlpackage:
|
||||
|
||||
if (err)
|
||||
{
|
||||
return rollBackCreateIndex(errorString("Failed to populate index with current data. ", err), txnID, createIndexStmt.fSessionID);
|
||||
return rollBackCreateIndex(errorString("Failed to populate index with current data. ", err), txnID,
|
||||
createIndexStmt.fSessionID);
|
||||
}
|
||||
|
||||
|
||||
// Log the DDL statement.
|
||||
logging::logDDL(createIndexStmt.fSessionID, txnID.id, createIndexStmt.fSql, createIndexStmt.fOwner);
|
||||
|
||||
@ -413,7 +418,8 @@ CreateIndexProcessor::DDLResult CreateIndexProcessor::processPackage(ddlpackage:
|
||||
|
||||
if (err)
|
||||
{
|
||||
return rollBackCreateIndex(errorString("Failed to commit the create index transaction. ", err), txnID, createIndexStmt.fSessionID);
|
||||
return rollBackCreateIndex(errorString("Failed to commit the create index transaction. ", err), txnID,
|
||||
createIndexStmt.fSessionID);
|
||||
}
|
||||
|
||||
fSessionManager.committed(txnID);
|
||||
@ -439,8 +445,8 @@ string CreateIndexProcessor::errorString(const string& msg, int error)
|
||||
return string(msg + ec.errorString(error));
|
||||
}
|
||||
|
||||
|
||||
CreateIndexProcessor::DDLResult CreateIndexProcessor::rollBackCreateIndex(const string& error, BRM::TxnID& txnID, int sessionId)
|
||||
CreateIndexProcessor::DDLResult CreateIndexProcessor::rollBackCreateIndex(const string& error,
|
||||
BRM::TxnID& txnID, int sessionId)
|
||||
{
|
||||
cerr << "CreatetableProcessor::processPackage: " << error << endl;
|
||||
DETAIL_INFO(error);
|
||||
@ -470,13 +476,12 @@ void CreateIndexProcessor::rollBackIndex(BRM::TxnID& txnID, int sessionId)
|
||||
}
|
||||
catch (exception& ex)
|
||||
{
|
||||
|
||||
}
|
||||
catch (...)
|
||||
{ }
|
||||
{
|
||||
}
|
||||
|
||||
fSessionManager.rolledback(txnID);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} // namespace ddlpackageprocessor
|
||||
|
@ -45,8 +45,8 @@ protected:
|
||||
DDLResult rollBackCreateIndex(const std::string& error, BRM::TxnID& txnID, int sessionId);
|
||||
void rollBackIndex(BRM::TxnID& txnID);
|
||||
std::string errorString(const std::string& msg, int error);
|
||||
private:
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
} // namespace ddlpackageprocessor
|
||||
|
@ -47,7 +47,6 @@ using namespace logging;
|
||||
|
||||
namespace ddlpackageprocessor
|
||||
{
|
||||
|
||||
CreateTableProcessor::DDLResult CreateTableProcessor::processPackage(
|
||||
ddlpackage::CreateTableStatement& createTableStmt)
|
||||
{
|
||||
@ -209,7 +208,6 @@ keepGoing:
|
||||
string stmt = createTableStmt.fSql + "|" + tableDef.fQualifiedName->fSchema + "|";
|
||||
SQLLogger logger(stmt, fDDLLoggingId, createTableStmt.fSessionID, txnID.id);
|
||||
|
||||
|
||||
std::string err;
|
||||
execplan::ObjectIDManager fObjectIDManager;
|
||||
OamCache* oamcache = OamCache::makeOamCache();
|
||||
@ -269,7 +267,8 @@ keepGoing:
|
||||
numDictCols++;
|
||||
}
|
||||
|
||||
fStartingColOID = fObjectIDManager.allocOIDs(numColumns + numDictCols + 1); //include column, oids,dictionary oids and tableoid
|
||||
fStartingColOID = fObjectIDManager.allocOIDs(numColumns + numDictCols +
|
||||
1); // include column, oids,dictionary oids and tableoid
|
||||
#ifdef IDB_DDL_DEBUG
|
||||
cout << fTxnid.id << " Create table allocOIDs got the starting oid " << fStartingColOID << endl;
|
||||
#endif
|
||||
@ -520,7 +519,6 @@ keepGoing:
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// Get the number of tables in the database, the current table is included.
|
||||
int tableCount = systemCatalogPtr->getTableCount();
|
||||
|
||||
@ -549,8 +547,7 @@ keepGoing:
|
||||
|
||||
CalpontSystemCatalog::ColDataType dataType = convertDataType(colDefPtr->fType->fType);
|
||||
|
||||
if (dataType == CalpontSystemCatalog::DECIMAL ||
|
||||
dataType == CalpontSystemCatalog::UDECIMAL)
|
||||
if (dataType == CalpontSystemCatalog::DECIMAL || dataType == CalpontSystemCatalog::UDECIMAL)
|
||||
{
|
||||
if (colDefPtr->fType->fPrecision == -1 || colDefPtr->fType->fPrecision == 0)
|
||||
{
|
||||
@ -712,7 +709,6 @@ keepGoing:
|
||||
|
||||
//@Bug 5464. Delete from extent map.
|
||||
fDbrm->deleteOIDs(oidList);
|
||||
|
||||
}
|
||||
}
|
||||
catch (runtime_error&)
|
||||
@ -797,8 +793,7 @@ void CreateTableProcessor::rollBackCreateTable(const string& error, BRM::TxnID t
|
||||
{
|
||||
execplan::ObjectIDManager fObjectIDManager;
|
||||
fObjectIDManager.returnOID(fTableOID);
|
||||
fObjectIDManager.returnOIDs(fStartingColOID,
|
||||
fStartingColOID + tableDef.fColumns.size() - 1);
|
||||
fObjectIDManager.returnOIDs(fStartingColOID, fStartingColOID + tableDef.fColumns.size() - 1);
|
||||
}
|
||||
catch (std::exception& ex)
|
||||
{
|
||||
|
@ -33,7 +33,6 @@
|
||||
|
||||
namespace ddlpackageprocessor
|
||||
{
|
||||
|
||||
/** @brief specialization of a DDLPackageProcessor
|
||||
* for interacting with the Write Engine
|
||||
* to process create table ddl statements.
|
||||
@ -41,8 +40,9 @@ namespace ddlpackageprocessor
|
||||
class CreateTableProcessor : public DDLPackageProcessor
|
||||
{
|
||||
public:
|
||||
|
||||
CreateTableProcessor(BRM::DBRM* aDbrm) : DDLPackageProcessor(aDbrm) {}
|
||||
CreateTableProcessor(BRM::DBRM* aDbrm) : DDLPackageProcessor(aDbrm)
|
||||
{
|
||||
}
|
||||
/** @brief process a create table statement
|
||||
*
|
||||
* @param createTableStmt the CreateTableStatement
|
||||
@ -50,13 +50,12 @@ public:
|
||||
EXPORT DDLResult processPackage(ddlpackage::CreateTableStatement& createTableStmt);
|
||||
|
||||
protected:
|
||||
void rollBackCreateTable(const std::string& error, BRM::TxnID txnID, int sessionId, ddlpackage::TableDef& tableDef, DDLResult& result);
|
||||
void rollBackCreateTable(const std::string& error, BRM::TxnID txnID, int sessionId,
|
||||
ddlpackage::TableDef& tableDef, DDLResult& result);
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
} // namespace ddlpackageprocessor
|
||||
|
||||
#undef EXPORT
|
||||
|
||||
|
@ -51,7 +51,6 @@ using namespace messageqcpp;
|
||||
|
||||
namespace ddlpackageprocessor
|
||||
{
|
||||
|
||||
bool DDLIndexPopulator::populateIndex(DDLPackageProcessor::DDLResult& result)
|
||||
{
|
||||
if (makeIndexStructs())
|
||||
@ -61,7 +60,6 @@ bool DDLIndexPopulator::populateIndex(DDLPackageProcessor::DDLResult& result)
|
||||
return NO_ERROR != fResult.result;
|
||||
}
|
||||
|
||||
|
||||
bool DDLIndexPopulator::makeIndexStructs()
|
||||
{
|
||||
CalpontSelectExecutionPlan csep;
|
||||
@ -131,14 +129,10 @@ bool DDLIndexPopulator::makeIndexStructs( )
|
||||
}
|
||||
|
||||
return (fIdxValueList.size() && NO_ERROR == fResult.result);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DDLIndexPopulator::makeCsep(CalpontSelectExecutionPlan& csep)
|
||||
{
|
||||
|
||||
csep.sessionID(fSessionID);
|
||||
|
||||
csep.txnID(fTxnID);
|
||||
@ -170,8 +164,8 @@ void DDLIndexPopulator::makeCsep(CalpontSelectExecutionPlan& csep)
|
||||
csep.returnedCols(colList);
|
||||
}
|
||||
|
||||
|
||||
CalpontSystemCatalog::ColType DDLIndexPopulator::makeIdxStruct(const ColumnResult* cr, size_t cols, boost::shared_ptr<CalpontSystemCatalog> csc )
|
||||
CalpontSystemCatalog::ColType DDLIndexPopulator::makeIdxStruct(const ColumnResult* cr, size_t cols,
|
||||
boost::shared_ptr<CalpontSystemCatalog> csc)
|
||||
{
|
||||
IdxStruct idx;
|
||||
idx.treeOid = fIdxOID.treeOID;
|
||||
@ -187,8 +181,10 @@ CalpontSystemCatalog::ColType DDLIndexPopulator::makeIdxStruct(const ColumnResul
|
||||
} //@bug 410: index sizes are either 1, 4 or 8
|
||||
else if (exeplan::isCharType(coltype))
|
||||
{
|
||||
if (1 == coltype.colWidth) idx.idxWidth = 1;
|
||||
else idx.idxWidth = (coltype.colWidth > 4) ? 8 : 4;
|
||||
if (1 == coltype.colWidth)
|
||||
idx.idxWidth = 1;
|
||||
else
|
||||
idx.idxWidth = (coltype.colWidth > 4) ? 8 : 4;
|
||||
|
||||
idx.idxType = WR_CHAR;
|
||||
}
|
||||
@ -199,14 +195,14 @@ CalpontSystemCatalog::ColType DDLIndexPopulator::makeIdxStruct(const ColumnResul
|
||||
return coltype;
|
||||
}
|
||||
|
||||
void DDLIndexPopulator::addColumnData(const execplan::ColumnResult* cr, const CalpontSystemCatalog::ColType colType, int added)
|
||||
void DDLIndexPopulator::addColumnData(const execplan::ColumnResult* cr,
|
||||
const CalpontSystemCatalog::ColType colType, int added)
|
||||
{
|
||||
WriteEngine::IdxTupleList tupleList;
|
||||
WriteEngine::IdxTuple tuple;
|
||||
|
||||
for (int i = 0; i < cr->dataCount(); ++i)
|
||||
{
|
||||
|
||||
WriteEngine::IdxTuple tuple;
|
||||
convertColData(cr, i, colType, tuple);
|
||||
|
||||
@ -225,9 +221,9 @@ void DDLIndexPopulator::addColumnData(const execplan::ColumnResult* cr, const Ca
|
||||
fIdxValueList.push_back(tupleList);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DDLIndexPopulator::convertColData(const execplan::ColumnResult* cr, int idx, const CalpontSystemCatalog::ColType& colType, WriteEngine::IdxTuple& tuple)
|
||||
void DDLIndexPopulator::convertColData(const execplan::ColumnResult* cr, int idx,
|
||||
const CalpontSystemCatalog::ColType& colType,
|
||||
WriteEngine::IdxTuple& tuple)
|
||||
{
|
||||
if (isDictionaryType(colType))
|
||||
{
|
||||
@ -235,7 +231,8 @@ void DDLIndexPopulator::convertColData(const execplan::ColumnResult* cr, int idx
|
||||
/* tuple.data = tokenizeData ( cr->GetRid(idx) );*/
|
||||
tuple.data = convertTokenData(cr->GetStringData(idx));
|
||||
}
|
||||
else tuple.data = convertData( colType, cr, idx);
|
||||
else
|
||||
tuple.data = convertData(colType, cr, idx);
|
||||
}
|
||||
|
||||
boost::any DDLIndexPopulator::convertTokenData(const std::string& data)
|
||||
@ -281,8 +278,8 @@ boost::any DDLIndexPopulator::tokenizeData( WriteEngine::RID rid )
|
||||
return token;
|
||||
}
|
||||
|
||||
|
||||
boost::any DDLIndexPopulator::tokenizeData( const execplan::CalpontSystemCatalog::ColType& colType, const std::string& data )
|
||||
boost::any DDLIndexPopulator::tokenizeData(const execplan::CalpontSystemCatalog::ColType& colType,
|
||||
const std::string& data)
|
||||
{
|
||||
WriteEngine::DctnryTuple dictTuple;
|
||||
|
||||
@ -309,46 +306,42 @@ boost::any DDLIndexPopulator::tokenizeData( const execplan::CalpontSystemCatalog
|
||||
return dictTuple.token;
|
||||
}
|
||||
|
||||
|
||||
|
||||
boost::any DDLIndexPopulator::convertData(const CalpontSystemCatalog::ColType& colType, const execplan::ColumnResult* cr, int idx )
|
||||
boost::any DDLIndexPopulator::convertData(const CalpontSystemCatalog::ColType& colType,
|
||||
const execplan::ColumnResult* cr, int idx)
|
||||
{
|
||||
uint64_t data = cr->GetData(idx);
|
||||
|
||||
switch (colType.colDataType)
|
||||
{
|
||||
case CalpontSystemCatalog::BIT:
|
||||
case execplan::CalpontSystemCatalog::TINYINT:
|
||||
return *reinterpret_cast<char*>(&data);
|
||||
case execplan::CalpontSystemCatalog::TINYINT: return *reinterpret_cast<char*>(&data);
|
||||
|
||||
case execplan::CalpontSystemCatalog::SMALLINT:
|
||||
return *reinterpret_cast<short*>(&data);
|
||||
case execplan::CalpontSystemCatalog::SMALLINT: return *reinterpret_cast<short*>(&data);
|
||||
|
||||
case execplan::CalpontSystemCatalog::DATE: // @bug 375
|
||||
case execplan::CalpontSystemCatalog::MEDINT:
|
||||
case execplan::CalpontSystemCatalog::INT:
|
||||
return *reinterpret_cast<int*>(&data);
|
||||
case execplan::CalpontSystemCatalog::INT: return *reinterpret_cast<int*>(&data);
|
||||
|
||||
case execplan::CalpontSystemCatalog::DATETIME: // @bug 375
|
||||
case execplan::CalpontSystemCatalog::TIME:
|
||||
case execplan::CalpontSystemCatalog::TIMESTAMP:
|
||||
case execplan::CalpontSystemCatalog::BIGINT:
|
||||
return *reinterpret_cast<long long*>(&data);
|
||||
case execplan::CalpontSystemCatalog::BIGINT: return *reinterpret_cast<long long*>(&data);
|
||||
|
||||
case execplan::CalpontSystemCatalog::DECIMAL:
|
||||
{
|
||||
if (colType.colWidth <= CalpontSystemCatalog::FOUR_BYTE) return *reinterpret_cast<short*>(&data);
|
||||
if (colType.colWidth <= CalpontSystemCatalog::FOUR_BYTE)
|
||||
return *reinterpret_cast<short*>(&data);
|
||||
|
||||
else if (colType.colWidth <= 9) return *reinterpret_cast<int*>(&data);
|
||||
else if (colType.colWidth <= 9)
|
||||
return *reinterpret_cast<int*>(&data);
|
||||
|
||||
else return *reinterpret_cast<long long*>(&data);
|
||||
else
|
||||
return *reinterpret_cast<long long*>(&data);
|
||||
}
|
||||
|
||||
case execplan::CalpontSystemCatalog::FLOAT:
|
||||
return *reinterpret_cast<float*>(&data);
|
||||
case execplan::CalpontSystemCatalog::FLOAT: return *reinterpret_cast<float*>(&data);
|
||||
|
||||
case execplan::CalpontSystemCatalog::DOUBLE:
|
||||
return *reinterpret_cast<double*>(&data);
|
||||
case execplan::CalpontSystemCatalog::DOUBLE: return *reinterpret_cast<double*>(&data);
|
||||
|
||||
case execplan::CalpontSystemCatalog::CHAR:
|
||||
case execplan::CalpontSystemCatalog::VARCHAR:
|
||||
@ -357,45 +350,37 @@ boost::any DDLIndexPopulator::convertData(const CalpontSystemCatalog::ColType&
|
||||
return *reinterpret_cast<string*>(&strData);
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
logError("Invalid column type");
|
||||
throw std::runtime_error("Invalid data");
|
||||
|
||||
return *reinterpret_cast<long long*>(&data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void DDLIndexPopulator::insertIndex()
|
||||
{
|
||||
// @bug 359 use bulk load build
|
||||
int rc = (1 < fIdxStructList.size()) ?
|
||||
(void)0
|
||||
: (void)0;
|
||||
int rc = (1 < fIdxStructList.size()) ? (void)0 : (void)0;
|
||||
|
||||
if (rc)
|
||||
logError("Error inserting index values", rc);
|
||||
|
||||
}
|
||||
|
||||
bool DDLIndexPopulator::isDictionaryType(const CalpontSystemCatalog::ColType& colType)
|
||||
{
|
||||
return ( (CalpontSystemCatalog::CHAR == colType.colDataType && 8 < colType.colWidth )
|
||||
|| (CalpontSystemCatalog::VARCHAR == colType.colDataType && 7 < colType.colWidth )
|
||||
|| (CalpontSystemCatalog::DECIMAL == colType.colDataType && 18 < colType.precision ));
|
||||
|
||||
return ((CalpontSystemCatalog::CHAR == colType.colDataType && 8 < colType.colWidth) ||
|
||||
(CalpontSystemCatalog::VARCHAR == colType.colDataType && 7 < colType.colWidth) ||
|
||||
(CalpontSystemCatalog::DECIMAL == colType.colDataType && 18 < colType.precision));
|
||||
}
|
||||
|
||||
bool DDLIndexPopulator::checkConstraints( const IdxTuple& data, const CalpontSystemCatalog::ColType& ctype, int i, int column)
|
||||
bool DDLIndexPopulator::checkConstraints(const IdxTuple& data, const CalpontSystemCatalog::ColType& ctype,
|
||||
int i, int column)
|
||||
{
|
||||
|
||||
switch (fConstraint)
|
||||
{
|
||||
case DDL_INVALID_CONSTRAINT:
|
||||
return true;
|
||||
case DDL_INVALID_CONSTRAINT: return true;
|
||||
|
||||
case DDL_UNIQUE:
|
||||
case DDL_PRIMARY_KEY:
|
||||
@ -404,16 +389,12 @@ bool DDLIndexPopulator::checkConstraints( const IdxTuple& data, const CalpontSys
|
||||
|
||||
return checkUnique(i, ctype);
|
||||
|
||||
case DDL_NOT_NULL:
|
||||
return checkNotNull( data, ctype );
|
||||
case DDL_NOT_NULL: return checkNotNull(data, ctype);
|
||||
|
||||
case DDL_CHECK:
|
||||
return checkCheck( data, ctype );
|
||||
case DDL_CHECK: return checkCheck(data, ctype);
|
||||
|
||||
default:
|
||||
return true; //?
|
||||
default: return true; //?
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Check if the row of data at idx is already in fUniqueColResultList
|
||||
@ -470,17 +451,14 @@ bool DDLIndexPopulator::checkUnique( int idx, const CalpontSystemCatalog::ColTyp
|
||||
return unique;
|
||||
}
|
||||
|
||||
|
||||
bool DDLIndexPopulator::checkNotNull(const IdxTuple& data, const CalpontSystemCatalog::ColType& colType)
|
||||
{
|
||||
|
||||
any nullvalue = DDLNullValueForType(colType);
|
||||
bool isNull = false;
|
||||
|
||||
switch (colType.colDataType)
|
||||
{
|
||||
case CalpontSystemCatalog::BIT:
|
||||
break;
|
||||
case CalpontSystemCatalog::BIT: break;
|
||||
|
||||
case execplan::CalpontSystemCatalog::TINYINT:
|
||||
isNull = any_cast<char>(data.data) == any_cast<char>(nullvalue);
|
||||
@ -508,7 +486,8 @@ bool DDLIndexPopulator::checkNotNull(const IdxTuple& data, const CalpontSystemCa
|
||||
else if (colType.colWidth <= 18)
|
||||
isNull = any_cast<long long>(data.data) == any_cast<long long>(nullvalue);
|
||||
else
|
||||
isNull = compareToken(any_cast<WriteEngine::Token>(data.data), any_cast<WriteEngine::Token>(nullvalue));
|
||||
isNull =
|
||||
compareToken(any_cast<WriteEngine::Token>(data.data), any_cast<WriteEngine::Token>(nullvalue));
|
||||
|
||||
break;
|
||||
}
|
||||
@ -540,10 +519,10 @@ bool DDLIndexPopulator::checkNotNull(const IdxTuple& data, const CalpontSystemCa
|
||||
else if (colType.colWidth <= execplan::CalpontSystemCatalog::FOUR_BYTE)
|
||||
isNull = any_cast<string>(data.data) == any_cast<string>(nullvalue);
|
||||
else
|
||||
isNull = compareToken(any_cast<WriteEngine::Token>(data.data), any_cast<WriteEngine::Token>(nullvalue));
|
||||
isNull =
|
||||
compareToken(any_cast<WriteEngine::Token>(data.data), any_cast<WriteEngine::Token>(nullvalue));
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case execplan::CalpontSystemCatalog::VARCHAR:
|
||||
@ -553,25 +532,23 @@ bool DDLIndexPopulator::checkNotNull(const IdxTuple& data, const CalpontSystemCa
|
||||
else if (colType.colWidth < execplan::CalpontSystemCatalog::FOUR_BYTE)
|
||||
isNull = any_cast<string>(data.data) == any_cast<string>(nullvalue);
|
||||
else
|
||||
isNull = compareToken(any_cast<WriteEngine::Token>(data.data), any_cast<WriteEngine::Token>(nullvalue));
|
||||
isNull =
|
||||
compareToken(any_cast<WriteEngine::Token>(data.data), any_cast<WriteEngine::Token>(nullvalue));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
throw std::runtime_error("getNullValueForType: unkown column data type");
|
||||
default: throw std::runtime_error("getNullValueForType: unkown column data type");
|
||||
}
|
||||
|
||||
if (isNull)
|
||||
logError("Null value not allowed in index");
|
||||
|
||||
return !isNull;
|
||||
|
||||
}
|
||||
|
||||
void DDLIndexPopulator::logError(const string& msg, int error)
|
||||
{
|
||||
|
||||
Message::Args args;
|
||||
Message message(9);
|
||||
args.add((string)__FILE__ + ": ");
|
||||
@ -589,11 +566,4 @@ void DDLIndexPopulator::logError(const string& msg, int error)
|
||||
fResult.message = message;
|
||||
}
|
||||
|
||||
|
||||
} //namespace
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace ddlpackageprocessor
|
||||
|
@ -40,7 +40,6 @@
|
||||
#include <boost/any.hpp>
|
||||
#include <boost/tuple/tuple.hpp>
|
||||
|
||||
|
||||
#include "joblistfactory.h"
|
||||
|
||||
namespace joblist
|
||||
@ -50,40 +49,44 @@ class DistributedEngineComm;
|
||||
|
||||
namespace ddlpackageprocessor
|
||||
{
|
||||
|
||||
/** @brief Populate an new Index
|
||||
* implementation of a DDLPopulator
|
||||
*/
|
||||
class DDLIndexPopulator
|
||||
{
|
||||
|
||||
public:
|
||||
/** @brief constructor
|
||||
*
|
||||
*/
|
||||
DDLIndexPopulator(WriteEngine::WriteEngineWrapper* writeEngine,
|
||||
execplan::SessionManager* sessionManager,
|
||||
uint32_t sessionID,
|
||||
execplan::CalpontSystemCatalog::SCN txnID,
|
||||
DDLPackageProcessor::DDLResult& result,
|
||||
const DDLPackageProcessor::IndexOID& idxOID,
|
||||
const ddlpackage::ColumnNameList& colNames,
|
||||
const ddlpackage::QualifiedName& table,
|
||||
const ddlpackage::DDL_CONSTRAINTS constraint,
|
||||
const DDLPackageProcessor::DebugLevel debug):
|
||||
fWriteEngine(writeEngine), fSessionManager(sessionManager),
|
||||
fSessionID(sessionID), fTxnID(txnID), fResult(result),
|
||||
fIdxOID(idxOID), fColNames(colNames), fTable(table), fDebugLevel(debug),
|
||||
fEC(0), fRidList(), fIdxStructList(), fIdxValueList(),
|
||||
DDLIndexPopulator(WriteEngine::WriteEngineWrapper* writeEngine, execplan::SessionManager* sessionManager,
|
||||
uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
||||
DDLPackageProcessor::DDLResult& result, const DDLPackageProcessor::IndexOID& idxOID,
|
||||
const ddlpackage::ColumnNameList& colNames, const ddlpackage::QualifiedName& table,
|
||||
const ddlpackage::DDL_CONSTRAINTS constraint, const DDLPackageProcessor::DebugLevel debug)
|
||||
: fWriteEngine(writeEngine)
|
||||
, fSessionManager(sessionManager)
|
||||
, fSessionID(sessionID)
|
||||
, fTxnID(txnID)
|
||||
, fResult(result)
|
||||
, fIdxOID(idxOID)
|
||||
, fColNames(colNames)
|
||||
, fTable(table)
|
||||
, fDebugLevel(debug)
|
||||
, fEC(0)
|
||||
, fRidList()
|
||||
, fIdxStructList()
|
||||
, fIdxValueList()
|
||||
,
|
||||
/* fTOKENSIZE(sizeof(WriteEngine::Token) ) {}*/
|
||||
fConstraint(constraint), fUniqueColResultList() {}
|
||||
|
||||
fConstraint(constraint)
|
||||
, fUniqueColResultList()
|
||||
{
|
||||
}
|
||||
|
||||
/** @brief destructor
|
||||
*/
|
||||
virtual ~DDLIndexPopulator(){};
|
||||
|
||||
|
||||
/** @brief Is it required to debug
|
||||
*/
|
||||
const bool isDebug(const DDLPackageProcessor::DebugLevel level) const
|
||||
@ -98,7 +101,6 @@ public:
|
||||
return fDebugLevel;
|
||||
}
|
||||
|
||||
|
||||
/** @brief set distributedEngineComm pointer ( for
|
||||
* loading index).
|
||||
*/
|
||||
@ -116,7 +118,6 @@ public:
|
||||
return fResult;
|
||||
}
|
||||
|
||||
|
||||
/** @brief add data to the index from the statement
|
||||
*
|
||||
* populate the newly made index with data in the index columns.
|
||||
@ -132,7 +133,6 @@ public:
|
||||
void setConstraint(ddlpackage::DDL_CONSTRAINTS constraint);
|
||||
|
||||
protected:
|
||||
|
||||
/** @brief make the structures to update the index
|
||||
*
|
||||
* builds and executes a query to retrieve all the data from the index columns
|
||||
@ -146,7 +146,8 @@ protected:
|
||||
* Fills in the values from the column result and calpont system catalog for
|
||||
* the WriteEngine::IdxStruct
|
||||
*/
|
||||
execplan::CalpontSystemCatalog::ColType makeIdxStruct(const execplan::ColumnResult* cr, size_t cols, boost::shared_ptr<execplan::CalpontSystemCatalog> csc );
|
||||
execplan::CalpontSystemCatalog::ColType makeIdxStruct(
|
||||
const execplan::ColumnResult* cr, size_t cols, boost::shared_ptr<execplan::CalpontSystemCatalog> csc);
|
||||
|
||||
/** @brief add the column result data to the value list
|
||||
*
|
||||
@ -154,7 +155,8 @@ protected:
|
||||
* Adds the rid to the rid list if it is the first column (not been added)
|
||||
* Adds the completed tuple list to the fValueList
|
||||
*/
|
||||
void addColumnData(const execplan::ColumnResult* cr, const execplan::CalpontSystemCatalog::ColType ctype, int added);
|
||||
void addColumnData(const execplan::ColumnResult* cr, const execplan::CalpontSystemCatalog::ColType ctype,
|
||||
int added);
|
||||
|
||||
/** @brief insert data into index.
|
||||
*
|
||||
@ -163,7 +165,6 @@ protected:
|
||||
*/
|
||||
void insertIndex();
|
||||
|
||||
|
||||
private:
|
||||
DDLIndexPopulator(const DDLIndexPopulator&);
|
||||
void operator=(const DDLIndexPopulator&);
|
||||
@ -181,23 +182,23 @@ private:
|
||||
|
||||
bool isStringType(int type) const
|
||||
{
|
||||
return (type == execplan::CalpontSystemCatalog::CHAR
|
||||
|| type == execplan::CalpontSystemCatalog::VARCHAR
|
||||
|| type == execplan::CalpontSystemCatalog::FLOAT
|
||||
|| type == execplan::CalpontSystemCatalog::DOUBLE
|
||||
|| type == execplan::CalpontSystemCatalog::UFLOAT
|
||||
|| type == execplan::CalpontSystemCatalog::UDOUBLE );
|
||||
return (type == execplan::CalpontSystemCatalog::CHAR || type == execplan::CalpontSystemCatalog::VARCHAR ||
|
||||
type == execplan::CalpontSystemCatalog::FLOAT || type == execplan::CalpontSystemCatalog::DOUBLE ||
|
||||
type == execplan::CalpontSystemCatalog::UFLOAT ||
|
||||
type == execplan::CalpontSystemCatalog::UDOUBLE);
|
||||
}
|
||||
|
||||
/** @brief converts column result data
|
||||
*
|
||||
* Converts or tokenizes data, depending on column type
|
||||
*/
|
||||
void convertColData(const execplan::ColumnResult* cr, int idx, const execplan::CalpontSystemCatalog::ColType& cType, WriteEngine::IdxTuple& tuple);
|
||||
void convertColData(const execplan::ColumnResult* cr, int idx,
|
||||
const execplan::CalpontSystemCatalog::ColType& cType, WriteEngine::IdxTuple& tuple);
|
||||
|
||||
/** @brief converts non token data to its original type
|
||||
*/
|
||||
boost::any convertData(const execplan::CalpontSystemCatalog::ColType& colType, const execplan::ColumnResult* cr, int idx );
|
||||
boost::any convertData(const execplan::CalpontSystemCatalog::ColType& colType,
|
||||
const execplan::ColumnResult* cr, int idx);
|
||||
|
||||
/** @brief returns token for string data
|
||||
*
|
||||
@ -231,7 +232,8 @@ private:
|
||||
* checks data according to contraint in coltype and sets result to error
|
||||
* if constraint violated. Returns if no error.
|
||||
*/
|
||||
bool checkConstraints(const WriteEngine::IdxTuple& data, const execplan::CalpontSystemCatalog::ColType& ctype, int i, int column);
|
||||
bool checkConstraints(const WriteEngine::IdxTuple& data,
|
||||
const execplan::CalpontSystemCatalog::ColType& ctype, int i, int column);
|
||||
|
||||
/** @brief returns if data not null
|
||||
*
|
||||
@ -245,7 +247,8 @@ private:
|
||||
*/
|
||||
bool checkUnique(int i, const execplan::CalpontSystemCatalog::ColType& colType);
|
||||
|
||||
bool checkCheck( const WriteEngine::IdxTuple& data, const execplan::CalpontSystemCatalog::ColType& ctype) const
|
||||
bool checkCheck(const WriteEngine::IdxTuple& data,
|
||||
const execplan::CalpontSystemCatalog::ColType& ctype) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -288,15 +291,16 @@ private:
|
||||
struct DDLNullValueForType : DDLPackageProcessor
|
||||
{
|
||||
DDLNullValueForType(const execplan::CalpontSystemCatalog::ColType& ctype)
|
||||
: DDLPackageProcessor(), fType(ctype) {}
|
||||
: DDLPackageProcessor(), fType(ctype)
|
||||
{
|
||||
}
|
||||
boost::any operator()(execplan::CalpontSystemCatalog::ColType& ctype)
|
||||
{
|
||||
return ctype.getNullValueForType();
|
||||
}
|
||||
const execplan::CalpontSystemCatalog::ColType& fType;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace ddlpackageprocessor
|
||||
#endif // DDLPINDEXPOPULATOR_H
|
||||
|
@ -67,11 +67,11 @@ const SOP opne(new Operator("<>"));
|
||||
const SOP opor(new Operator("or"));
|
||||
const SOP opand(new Operator("and"));
|
||||
const SOP opis(new Operator("is"));
|
||||
}
|
||||
} // namespace
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
using boost::lexical_cast;
|
||||
using boost::any_cast;
|
||||
using boost::lexical_cast;
|
||||
|
||||
using namespace std;
|
||||
using namespace execplan;
|
||||
@ -90,7 +90,6 @@ DDLPackageProcessor::~DDLPackageProcessor()
|
||||
void DDLPackageProcessor::getColumnsForTable(uint32_t sessionID, std::string schema, std::string table,
|
||||
ColumnList& colList)
|
||||
{
|
||||
|
||||
CalpontSystemCatalog::TableName tableName;
|
||||
tableName.schema = schema;
|
||||
tableName.table = table;
|
||||
@ -98,7 +97,8 @@ void DDLPackageProcessor::getColumnsForTable(uint32_t sessionID, std::string sc
|
||||
|
||||
try
|
||||
{
|
||||
boost::shared_ptr<CalpontSystemCatalog> systemCatalogPtr = CalpontSystemCatalog::makeCalpontSystemCatalog(sessionID);
|
||||
boost::shared_ptr<CalpontSystemCatalog> systemCatalogPtr =
|
||||
CalpontSystemCatalog::makeCalpontSystemCatalog(sessionID);
|
||||
systemCatalogPtr->identity(CalpontSystemCatalog::EC);
|
||||
|
||||
const CalpontSystemCatalog::RIDList ridList = systemCatalogPtr->columnRIDs(tableName);
|
||||
@ -118,12 +118,11 @@ void DDLPackageProcessor::getColumnsForTable(uint32_t sessionID, std::string sc
|
||||
|
||||
++rid_iterator;
|
||||
}
|
||||
|
||||
}
|
||||
catch (std::exception& ex)
|
||||
{
|
||||
|
||||
err = "DDLPackageProcessor::getColumnsForTable: while reading columns for table " + schema + '.' + table + ": " + ex.what();
|
||||
err = "DDLPackageProcessor::getColumnsForTable: while reading columns for table " + schema + '.' + table +
|
||||
": " + ex.what();
|
||||
throw std::runtime_error(err);
|
||||
}
|
||||
catch (...)
|
||||
@ -131,7 +130,6 @@ void DDLPackageProcessor::getColumnsForTable(uint32_t sessionID, std::string sc
|
||||
err = "DDLPackageProcessor::getColumnsForTable: caught unkown exception!";
|
||||
throw std::runtime_error(err);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
execplan::CalpontSystemCatalog::ColDataType DDLPackageProcessor::convertDataType(int dataType)
|
||||
@ -140,129 +138,72 @@ execplan::CalpontSystemCatalog::ColDataType DDLPackageProcessor::convertDataType
|
||||
|
||||
switch (dataType)
|
||||
{
|
||||
case ddlpackage::DDL_CHAR:
|
||||
colDataType = CalpontSystemCatalog::CHAR;
|
||||
break;
|
||||
case ddlpackage::DDL_CHAR: colDataType = CalpontSystemCatalog::CHAR; break;
|
||||
|
||||
case ddlpackage::DDL_VARCHAR:
|
||||
colDataType = CalpontSystemCatalog::VARCHAR;
|
||||
break;
|
||||
case ddlpackage::DDL_VARCHAR: colDataType = CalpontSystemCatalog::VARCHAR; break;
|
||||
|
||||
case ddlpackage::DDL_VARBINARY:
|
||||
colDataType = CalpontSystemCatalog::VARBINARY;
|
||||
break;
|
||||
case ddlpackage::DDL_VARBINARY: colDataType = CalpontSystemCatalog::VARBINARY; break;
|
||||
|
||||
case ddlpackage::DDL_BIT:
|
||||
colDataType = CalpontSystemCatalog::BIT;
|
||||
break;
|
||||
case ddlpackage::DDL_BIT: colDataType = CalpontSystemCatalog::BIT; break;
|
||||
|
||||
case ddlpackage::DDL_REAL:
|
||||
case ddlpackage::DDL_DECIMAL:
|
||||
case ddlpackage::DDL_NUMERIC:
|
||||
case ddlpackage::DDL_NUMBER:
|
||||
colDataType = CalpontSystemCatalog::DECIMAL;
|
||||
break;
|
||||
case ddlpackage::DDL_NUMBER: colDataType = CalpontSystemCatalog::DECIMAL; break;
|
||||
|
||||
case ddlpackage::DDL_FLOAT:
|
||||
colDataType = CalpontSystemCatalog::FLOAT;
|
||||
break;
|
||||
case ddlpackage::DDL_FLOAT: colDataType = CalpontSystemCatalog::FLOAT; break;
|
||||
|
||||
case ddlpackage::DDL_DOUBLE:
|
||||
colDataType = CalpontSystemCatalog::DOUBLE;
|
||||
break;
|
||||
case ddlpackage::DDL_DOUBLE: colDataType = CalpontSystemCatalog::DOUBLE; break;
|
||||
|
||||
case ddlpackage::DDL_INT:
|
||||
case ddlpackage::DDL_INTEGER:
|
||||
colDataType = CalpontSystemCatalog::INT;
|
||||
break;
|
||||
case ddlpackage::DDL_INTEGER: colDataType = CalpontSystemCatalog::INT; break;
|
||||
|
||||
case ddlpackage::DDL_BIGINT:
|
||||
colDataType = CalpontSystemCatalog::BIGINT;
|
||||
break;
|
||||
case ddlpackage::DDL_BIGINT: colDataType = CalpontSystemCatalog::BIGINT; break;
|
||||
|
||||
case ddlpackage::DDL_MEDINT:
|
||||
colDataType = CalpontSystemCatalog::MEDINT;
|
||||
break;
|
||||
case ddlpackage::DDL_MEDINT: colDataType = CalpontSystemCatalog::MEDINT; break;
|
||||
|
||||
case ddlpackage::DDL_SMALLINT:
|
||||
colDataType = CalpontSystemCatalog::SMALLINT;
|
||||
break;
|
||||
case ddlpackage::DDL_SMALLINT: colDataType = CalpontSystemCatalog::SMALLINT; break;
|
||||
|
||||
case ddlpackage::DDL_TINYINT:
|
||||
colDataType = CalpontSystemCatalog::TINYINT;
|
||||
break;
|
||||
case ddlpackage::DDL_TINYINT: colDataType = CalpontSystemCatalog::TINYINT; break;
|
||||
|
||||
case ddlpackage::DDL_UNSIGNED_DECIMAL:
|
||||
case ddlpackage::DDL_UNSIGNED_NUMERIC:
|
||||
colDataType = CalpontSystemCatalog::UDECIMAL;
|
||||
break;
|
||||
case ddlpackage::DDL_UNSIGNED_NUMERIC: colDataType = CalpontSystemCatalog::UDECIMAL; break;
|
||||
|
||||
case ddlpackage::DDL_UNSIGNED_FLOAT:
|
||||
colDataType = CalpontSystemCatalog::UFLOAT;
|
||||
break;
|
||||
case ddlpackage::DDL_UNSIGNED_FLOAT: colDataType = CalpontSystemCatalog::UFLOAT; break;
|
||||
|
||||
case ddlpackage::DDL_UNSIGNED_DOUBLE:
|
||||
colDataType = CalpontSystemCatalog::UDOUBLE;
|
||||
break;
|
||||
case ddlpackage::DDL_UNSIGNED_DOUBLE: colDataType = CalpontSystemCatalog::UDOUBLE; break;
|
||||
|
||||
case ddlpackage::DDL_UNSIGNED_INT:
|
||||
colDataType = CalpontSystemCatalog::UINT;
|
||||
break;
|
||||
case ddlpackage::DDL_UNSIGNED_INT: colDataType = CalpontSystemCatalog::UINT; break;
|
||||
|
||||
case ddlpackage::DDL_UNSIGNED_BIGINT:
|
||||
colDataType = CalpontSystemCatalog::UBIGINT;
|
||||
break;
|
||||
case ddlpackage::DDL_UNSIGNED_BIGINT: colDataType = CalpontSystemCatalog::UBIGINT; break;
|
||||
|
||||
case ddlpackage::DDL_UNSIGNED_MEDINT:
|
||||
colDataType = CalpontSystemCatalog::UMEDINT;
|
||||
break;
|
||||
case ddlpackage::DDL_UNSIGNED_MEDINT: colDataType = CalpontSystemCatalog::UMEDINT; break;
|
||||
|
||||
case ddlpackage::DDL_UNSIGNED_SMALLINT:
|
||||
colDataType = CalpontSystemCatalog::USMALLINT;
|
||||
break;
|
||||
case ddlpackage::DDL_UNSIGNED_SMALLINT: colDataType = CalpontSystemCatalog::USMALLINT; break;
|
||||
|
||||
case ddlpackage::DDL_UNSIGNED_TINYINT:
|
||||
colDataType = CalpontSystemCatalog::UTINYINT;
|
||||
break;
|
||||
case ddlpackage::DDL_UNSIGNED_TINYINT: colDataType = CalpontSystemCatalog::UTINYINT; break;
|
||||
|
||||
case ddlpackage::DDL_DATE:
|
||||
colDataType = CalpontSystemCatalog::DATE;
|
||||
break;
|
||||
case ddlpackage::DDL_DATE: colDataType = CalpontSystemCatalog::DATE; break;
|
||||
|
||||
case ddlpackage::DDL_DATETIME:
|
||||
colDataType = CalpontSystemCatalog::DATETIME;
|
||||
break;
|
||||
case ddlpackage::DDL_DATETIME: colDataType = CalpontSystemCatalog::DATETIME; break;
|
||||
|
||||
case ddlpackage::DDL_TIME:
|
||||
colDataType = CalpontSystemCatalog::TIME;
|
||||
break;
|
||||
case ddlpackage::DDL_TIME: colDataType = CalpontSystemCatalog::TIME; break;
|
||||
|
||||
case ddlpackage::DDL_TIMESTAMP:
|
||||
colDataType = CalpontSystemCatalog::TIMESTAMP;
|
||||
break;
|
||||
case ddlpackage::DDL_TIMESTAMP: colDataType = CalpontSystemCatalog::TIMESTAMP; break;
|
||||
|
||||
case ddlpackage::DDL_CLOB:
|
||||
colDataType = CalpontSystemCatalog::CLOB;
|
||||
break;
|
||||
case ddlpackage::DDL_CLOB: colDataType = CalpontSystemCatalog::CLOB; break;
|
||||
|
||||
case ddlpackage::DDL_BLOB:
|
||||
colDataType = CalpontSystemCatalog::BLOB;
|
||||
break;
|
||||
case ddlpackage::DDL_BLOB: colDataType = CalpontSystemCatalog::BLOB; break;
|
||||
|
||||
case ddlpackage::DDL_TEXT:
|
||||
colDataType = CalpontSystemCatalog::TEXT;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw runtime_error("Unsupported datatype!");
|
||||
case ddlpackage::DDL_TEXT: colDataType = CalpontSystemCatalog::TEXT; break;
|
||||
|
||||
default: throw runtime_error("Unsupported datatype!");
|
||||
}
|
||||
|
||||
return colDataType;
|
||||
}
|
||||
|
||||
std::string DDLPackageProcessor::buildTableConstraintName(const int oid,
|
||||
ddlpackage::DDL_CONSTRAINTS type)
|
||||
std::string DDLPackageProcessor::buildTableConstraintName(const int oid, ddlpackage::DDL_CONSTRAINTS type)
|
||||
{
|
||||
std::stringstream oid_number;
|
||||
oid_number << oid;
|
||||
@ -279,25 +220,15 @@ std::string DDLPackageProcessor::buildTableConstraintName(const int oid,
|
||||
break;
|
||||
|
||||
case ddlpackage::DDL_FOREIGN_KEY:
|
||||
case ddlpackage::DDL_REFERENCES:
|
||||
prefix = "fk_";
|
||||
break;
|
||||
case ddlpackage::DDL_REFERENCES: prefix = "fk_"; break;
|
||||
|
||||
case ddlpackage::DDL_UNIQUE:
|
||||
prefix = "uk_";
|
||||
break;
|
||||
case ddlpackage::DDL_UNIQUE: prefix = "uk_"; break;
|
||||
|
||||
case ddlpackage::DDL_CHECK:
|
||||
prefix = "ck_";
|
||||
break;
|
||||
case ddlpackage::DDL_CHECK: prefix = "ck_"; break;
|
||||
|
||||
case ddlpackage::DDL_NOT_NULL:
|
||||
prefix = "nk_";
|
||||
break;
|
||||
case ddlpackage::DDL_NOT_NULL: prefix = "nk_"; break;
|
||||
|
||||
default:
|
||||
throw runtime_error("Unsupported constraint type!");
|
||||
break;
|
||||
default: throw runtime_error("Unsupported constraint type!"); break;
|
||||
}
|
||||
|
||||
if (type != ddlpackage::DDL_PRIMARY_KEY)
|
||||
@ -319,30 +250,18 @@ std::string DDLPackageProcessor::buildColumnConstraintName(const std::string& sc
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case ddlpackage::DDL_PRIMARY_KEY:
|
||||
prefix = "pk_";
|
||||
break;
|
||||
case ddlpackage::DDL_PRIMARY_KEY: prefix = "pk_"; break;
|
||||
|
||||
case ddlpackage::DDL_FOREIGN_KEY:
|
||||
case ddlpackage::DDL_REFERENCES:
|
||||
prefix = "fk_";
|
||||
break;
|
||||
case ddlpackage::DDL_REFERENCES: prefix = "fk_"; break;
|
||||
|
||||
case ddlpackage::DDL_UNIQUE:
|
||||
prefix = "uk_";
|
||||
break;
|
||||
case ddlpackage::DDL_UNIQUE: prefix = "uk_"; break;
|
||||
|
||||
case ddlpackage::DDL_CHECK:
|
||||
prefix = "ck_";
|
||||
break;
|
||||
case ddlpackage::DDL_CHECK: prefix = "ck_"; break;
|
||||
|
||||
case ddlpackage::DDL_NOT_NULL:
|
||||
prefix = "nk_";
|
||||
break;
|
||||
case ddlpackage::DDL_NOT_NULL: prefix = "nk_"; break;
|
||||
|
||||
default:
|
||||
throw runtime_error("Unsupported constraint type!");
|
||||
break;
|
||||
default: throw runtime_error("Unsupported constraint type!"); break;
|
||||
}
|
||||
|
||||
indexName = prefix + schema + "_" + table + "_" + column;
|
||||
@ -358,36 +277,23 @@ char DDLPackageProcessor::getConstraintCode(ddlpackage::DDL_CONSTRAINTS type)
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case ddlpackage::DDL_PRIMARY_KEY:
|
||||
constraint_type = 'p';
|
||||
break;
|
||||
case ddlpackage::DDL_PRIMARY_KEY: constraint_type = 'p'; break;
|
||||
|
||||
case ddlpackage::DDL_REFERENCES:
|
||||
case ddlpackage::DDL_FOREIGN_KEY:
|
||||
constraint_type = 'f';
|
||||
break;
|
||||
case ddlpackage::DDL_FOREIGN_KEY: constraint_type = 'f'; break;
|
||||
|
||||
case ddlpackage::DDL_UNIQUE:
|
||||
constraint_type = 'u';
|
||||
break;
|
||||
case ddlpackage::DDL_UNIQUE: constraint_type = 'u'; break;
|
||||
|
||||
case ddlpackage::DDL_CHECK:
|
||||
constraint_type = 'c';
|
||||
break;
|
||||
case ddlpackage::DDL_CHECK: constraint_type = 'c'; break;
|
||||
|
||||
case ddlpackage::DDL_NOT_NULL:
|
||||
constraint_type = 'n';
|
||||
break;
|
||||
case ddlpackage::DDL_NOT_NULL: constraint_type = 'n'; break;
|
||||
|
||||
default:
|
||||
constraint_type = '0';
|
||||
break;
|
||||
default: constraint_type = '0'; break;
|
||||
}
|
||||
|
||||
return constraint_type;
|
||||
}
|
||||
|
||||
|
||||
bool DDLPackageProcessor::isIndexConstraint(ddlpackage::DDL_CONSTRAINTS type)
|
||||
{
|
||||
bool indexConstraint = false;
|
||||
@ -398,13 +304,9 @@ bool DDLPackageProcessor::isIndexConstraint(ddlpackage::DDL_CONSTRAINTS type)
|
||||
|
||||
// @bug fix for #418, #416. Do not insert into sysindex
|
||||
// case ddlpackage::DDL_REFERENCES:
|
||||
case ddlpackage::DDL_UNIQUE:
|
||||
indexConstraint = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
case ddlpackage::DDL_UNIQUE: indexConstraint = true; break;
|
||||
|
||||
default: break;
|
||||
}
|
||||
|
||||
return indexConstraint;
|
||||
@ -413,7 +315,6 @@ bool DDLPackageProcessor::isIndexConstraint(ddlpackage::DDL_CONSTRAINTS type)
|
||||
void DDLPackageProcessor::getColumnReferences(ddlpackage::TableConstraintDef& tableConstraint,
|
||||
ddlpackage::ColumnNameList& columns)
|
||||
{
|
||||
|
||||
switch (tableConstraint.fConstraintType)
|
||||
{
|
||||
case ddlpackage::DDL_PRIMARY_KEY:
|
||||
@ -443,13 +344,12 @@ void DDLPackageProcessor::getColumnReferences(ddlpackage::TableConstraintDef& ta
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
boost::any DDLPackageProcessor::tokenizeData(execplan::CalpontSystemCatalog::SCN txnID, const DDLResult& result,
|
||||
boost::any DDLPackageProcessor::tokenizeData(execplan::CalpontSystemCatalog::SCN txnID,
|
||||
const DDLResult& result,
|
||||
const execplan::CalpontSystemCatalog::ColType& colType,
|
||||
const boost::any& data)
|
||||
{
|
||||
@ -459,7 +359,6 @@ boost::any DDLPackageProcessor::tokenizeData(execplan::CalpontSystemCatalog::SCN
|
||||
|
||||
if (result.result == NO_ERROR)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
std::string str;
|
||||
@ -491,7 +390,8 @@ boost::any DDLPackageProcessor::tokenizeData(execplan::CalpontSystemCatalog::SCN
|
||||
dictTuple.sigSize = str.length();
|
||||
int error = NO_ERROR;
|
||||
|
||||
if (NO_ERROR != (error = fWriteEngine.tokenize(txnID, dictStruct, dictTuple, false))) // @bug 5572 HDFS tmp file
|
||||
if (NO_ERROR !=
|
||||
(error = fWriteEngine.tokenize(txnID, dictStruct, dictTuple, false))) // @bug 5572 HDFS tmp file
|
||||
{
|
||||
WErrorCodes ec;
|
||||
throw std::runtime_error("WE: Tokenization failed " + ec.errorString(error));
|
||||
@ -500,7 +400,6 @@ boost::any DDLPackageProcessor::tokenizeData(execplan::CalpontSystemCatalog::SCN
|
||||
WriteEngine::Token aToken = dictTuple.token;
|
||||
|
||||
value = aToken;
|
||||
|
||||
}
|
||||
catch (std::exception& ex)
|
||||
{
|
||||
@ -511,7 +410,6 @@ boost::any DDLPackageProcessor::tokenizeData(execplan::CalpontSystemCatalog::SCN
|
||||
{
|
||||
err += "Unknown exception caught, tokenizeData failed.";
|
||||
throw std::runtime_error(err);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -583,9 +481,8 @@ void DDLPackageProcessor::flushPrimprocCache(std::vector<execplan::CalpontSystem
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DDLPackageProcessor::removeFiles(const uint64_t uniqueId, std::vector<execplan::CalpontSystemCatalog::OID>& oidList)
|
||||
void DDLPackageProcessor::removeFiles(const uint64_t uniqueId,
|
||||
std::vector<execplan::CalpontSystemCatalog::OID>& oidList)
|
||||
{
|
||||
SUMMARY_INFO("DDLPackageProcessor::removeFiles");
|
||||
ByteStream bytestream;
|
||||
@ -664,7 +561,8 @@ void DDLPackageProcessor::createFiles(CalpontSystemCatalog::TableName aTableName
|
||||
const uint64_t uniqueId, const uint32_t numOids)
|
||||
{
|
||||
SUMMARY_INFO("DDLPackageProcessor::createFiles");
|
||||
boost::shared_ptr<CalpontSystemCatalog> systemCatalogPtr = CalpontSystemCatalog::makeCalpontSystemCatalog(1);
|
||||
boost::shared_ptr<CalpontSystemCatalog> systemCatalogPtr =
|
||||
CalpontSystemCatalog::makeCalpontSystemCatalog(1);
|
||||
CalpontSystemCatalog::RIDList ridList = systemCatalogPtr->columnRIDs(aTableName);
|
||||
fWEClient->addQueue(uniqueId);
|
||||
CalpontSystemCatalog::ColType colType;
|
||||
@ -752,8 +650,7 @@ void DDLPackageProcessor::createFiles(CalpontSystemCatalog::TableName aTableName
|
||||
}
|
||||
|
||||
void DDLPackageProcessor::removePartitionFiles(std::vector<execplan::CalpontSystemCatalog::OID>& oidList,
|
||||
const PartitionNums& partitions,
|
||||
uint64_t uniqueId)
|
||||
const PartitionNums& partitions, uint64_t uniqueId)
|
||||
{
|
||||
SUMMARY_INFO("DDLPackageProcessor::removeFiles");
|
||||
|
||||
@ -846,11 +743,11 @@ void DDLPackageProcessor::removeExtents(std::vector<execplan::CalpontSystemCatal
|
||||
BRM::errString(err, errMsg);
|
||||
throw std::runtime_error(errMsg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void DDLPackageProcessor::createWriteDropLogFile(execplan::CalpontSystemCatalog::OID tableOid,
|
||||
uint64_t uniqueId, std::vector<execplan::CalpontSystemCatalog::OID>& oidList)
|
||||
uint64_t uniqueId,
|
||||
std::vector<execplan::CalpontSystemCatalog::OID>& oidList)
|
||||
{
|
||||
SUMMARY_INFO("DDLPackageProcessor::createWriteDropLogFile");
|
||||
// For shared nothing, the meta files are created under data1 with controllernode.
|
||||
@ -915,7 +812,8 @@ void DDLPackageProcessor::createWriteDropLogFile(execplan::CalpontSystemCatalog:
|
||||
throw std::runtime_error(errorMsg);
|
||||
}
|
||||
|
||||
void DDLPackageProcessor::deleteLogFile(LogFileType fileType, execplan::CalpontSystemCatalog::OID tableOid, uint64_t uniqueId)
|
||||
void DDLPackageProcessor::deleteLogFile(LogFileType fileType, execplan::CalpontSystemCatalog::OID tableOid,
|
||||
uint64_t uniqueId)
|
||||
{
|
||||
SUMMARY_INFO("DDLPackageProcessor::deleteLogFile");
|
||||
OamCache* oamcache = OamCache::makeOamCache();
|
||||
@ -1074,11 +972,10 @@ void DDLPackageProcessor::fetchLogFile(TableLogInfo& tableLogInfos, uint64_t uni
|
||||
|
||||
if (rc != 0)
|
||||
throw std::runtime_error(errorMsg);
|
||||
|
||||
}
|
||||
|
||||
void DDLPackageProcessor::createWritePartitionLogFile(execplan::CalpontSystemCatalog::OID tableOid,
|
||||
const PartitionNums& partitionNums,
|
||||
void DDLPackageProcessor::createWritePartitionLogFile(
|
||||
execplan::CalpontSystemCatalog::OID tableOid, const PartitionNums& partitionNums,
|
||||
std::vector<execplan::CalpontSystemCatalog::OID>& oidList, uint64_t uniqueId)
|
||||
{
|
||||
SUMMARY_INFO("DDLPackageProcessor::createWritePartitionLogFile");
|
||||
@ -1152,7 +1049,9 @@ void DDLPackageProcessor::createWritePartitionLogFile(execplan::CalpontSystemCat
|
||||
throw std::runtime_error(errorMsg);
|
||||
}
|
||||
|
||||
void DDLPackageProcessor::createWriteTruncateTableLogFile(execplan::CalpontSystemCatalog::OID tableOid, uint64_t uniqueId, std::vector<execplan::CalpontSystemCatalog::OID>& oidList)
|
||||
void DDLPackageProcessor::createWriteTruncateTableLogFile(
|
||||
execplan::CalpontSystemCatalog::OID tableOid, uint64_t uniqueId,
|
||||
std::vector<execplan::CalpontSystemCatalog::OID>& oidList)
|
||||
{
|
||||
SUMMARY_INFO("DDLPackageProcessor::createWriteTruncateTableLogFile");
|
||||
// For shared nothing, the meta files are created under data1 with controllernode.
|
||||
@ -1413,9 +1312,9 @@ void DDLPackageProcessor::returnOIDs(execplan::CalpontSystemCatalog::RIDList& ri
|
||||
}
|
||||
}
|
||||
|
||||
void DDLPackageProcessor::findColumnData(uint32_t sessionID, execplan::CalpontSystemCatalog::TableName& systableName,
|
||||
const std::string& colName,
|
||||
DDLColumn& sysCol)
|
||||
void DDLPackageProcessor::findColumnData(uint32_t sessionID,
|
||||
execplan::CalpontSystemCatalog::TableName& systableName,
|
||||
const std::string& colName, DDLColumn& sysCol)
|
||||
{
|
||||
ColumnList columns;
|
||||
ColumnList::const_iterator column_iterator;
|
||||
@ -1464,7 +1363,6 @@ void DDLPackageProcessor::cleanString(string& s)
|
||||
{
|
||||
s = s.substr(0, pos);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (s[0] == '\'')
|
||||
@ -1483,13 +1381,16 @@ void DDLPackageProcessor::convertRidToColumn(uint64_t& rid, unsigned& dbRoot, un
|
||||
{
|
||||
partition = rid / (filesPerColumnPartition * extentsPerSegmentFile * extentRows);
|
||||
|
||||
segment = (((rid % (filesPerColumnPartition * extentsPerSegmentFile * extentRows)) / extentRows)) % filesPerColumnPartition;
|
||||
segment = (((rid % (filesPerColumnPartition * extentsPerSegmentFile * extentRows)) / extentRows)) %
|
||||
filesPerColumnPartition;
|
||||
|
||||
dbRoot = ((startDBRoot - 1 + segment) % dbrootCnt) + 1;
|
||||
|
||||
// Calculate the relative rid for this segment file
|
||||
uint64_t relRidInPartition = rid - ((uint64_t)partition * (uint64_t)filesPerColumnPartition * (uint64_t)extentsPerSegmentFile * (uint64_t)extentRows);
|
||||
idbassert(relRidInPartition <= (uint64_t)filesPerColumnPartition * (uint64_t)extentsPerSegmentFile * (uint64_t)extentRows);
|
||||
uint64_t relRidInPartition = rid - ((uint64_t)partition * (uint64_t)filesPerColumnPartition *
|
||||
(uint64_t)extentsPerSegmentFile * (uint64_t)extentRows);
|
||||
idbassert(relRidInPartition <=
|
||||
(uint64_t)filesPerColumnPartition * (uint64_t)extentsPerSegmentFile * (uint64_t)extentRows);
|
||||
uint32_t numExtentsInThisPart = relRidInPartition / extentRows;
|
||||
unsigned numExtentsInThisSegPart = numExtentsInThisPart / filesPerColumnPartition;
|
||||
uint64_t relRidInThisExtent = relRidInPartition - numExtentsInThisPart * extentRows;
|
||||
@ -1576,7 +1477,6 @@ int DDLPackageProcessor::rollBackTransaction(uint64_t uniqueId, BRM::TxnID txnID
|
||||
}
|
||||
else
|
||||
msgRecived++;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1590,6 +1490,5 @@ int DDLPackageProcessor::commitTransaction(uint64_t uniqueId, BRM::TxnID txnID)
|
||||
return rc;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace ddlpackageprocessor
|
||||
// vim:ts=4 sw=4:
|
||||
|
||||
|
@ -56,7 +56,6 @@
|
||||
//#define IDB_DDL_DEBUG
|
||||
namespace ddlpackageprocessor
|
||||
{
|
||||
|
||||
#define SUMMARY_INFO(message) \
|
||||
if (isDebug(SUMMARY)) \
|
||||
{ \
|
||||
@ -80,14 +79,25 @@ namespace ddlpackageprocessor
|
||||
*/
|
||||
class DDLPackageProcessor
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
/** @brief Result code
|
||||
*/
|
||||
enum ResultCode { NO_ERROR, CREATE_ERROR, ALTER_ERROR, DROP_ERROR, TRUNC_ERROR,
|
||||
TOKENIZATION_ERROR, NOT_ACCEPTING_PACKAGES, PK_NOTNULL_ERROR, WARNING, USER_ERROR, NETWORK_ERROR, PARTITION_WARNING,
|
||||
WARN_NO_PARTITION, DROP_TABLE_NOT_IN_CATALOG_ERROR
|
||||
enum ResultCode
|
||||
{
|
||||
NO_ERROR,
|
||||
CREATE_ERROR,
|
||||
ALTER_ERROR,
|
||||
DROP_ERROR,
|
||||
TRUNC_ERROR,
|
||||
TOKENIZATION_ERROR,
|
||||
NOT_ACCEPTING_PACKAGES,
|
||||
PK_NOTNULL_ERROR,
|
||||
WARNING,
|
||||
USER_ERROR,
|
||||
NETWORK_ERROR,
|
||||
PARTITION_WARNING,
|
||||
WARN_NO_PARTITION,
|
||||
DROP_TABLE_NOT_IN_CATALOG_ERROR
|
||||
};
|
||||
|
||||
enum DebugLevel /** @brief Debug level type enumeration */
|
||||
@ -98,7 +108,12 @@ public:
|
||||
VERBOSE = 3, /** @brief Detailed debug info */
|
||||
};
|
||||
|
||||
enum LogFileType { DROPTABLE_LOG, DROPPART_LOG, TRUNCATE_LOG};
|
||||
enum LogFileType
|
||||
{
|
||||
DROPTABLE_LOG,
|
||||
DROPPART_LOG,
|
||||
TRUNCATE_LOG
|
||||
};
|
||||
typedef std::vector<execplan::CalpontSystemCatalog::OID> OidList;
|
||||
typedef std::set<BRM::LogicalPartition> PartitionNums;
|
||||
struct LogInfo
|
||||
@ -262,7 +277,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/** @brief constructor
|
||||
*/
|
||||
DDLPackageProcessor(BRM::DBRM* aDbrm) : fStartingColOID(0), fDDLLoggingId(23), fDebugLevel(NONE)
|
||||
@ -277,7 +291,6 @@ public:
|
||||
*/
|
||||
EXPORT virtual ~DDLPackageProcessor();
|
||||
|
||||
|
||||
/** @brief Is it required to debug
|
||||
*/
|
||||
bool isDebug(const DebugLevel level) const
|
||||
@ -338,7 +351,8 @@ public:
|
||||
*/
|
||||
EXPORT void removeFiles(const uint64_t uniqueId, std::vector<execplan::CalpontSystemCatalog::OID>& oidList);
|
||||
|
||||
EXPORT void createFiles(execplan::CalpontSystemCatalog::TableName aTableName, const int useDBRoot, const uint64_t uniqueId, const uint32_t numOids);
|
||||
EXPORT void createFiles(execplan::CalpontSystemCatalog::TableName aTableName, const int useDBRoot,
|
||||
const uint64_t uniqueId, const uint32_t numOids);
|
||||
|
||||
/** @brief remove the physical files for the specified partition
|
||||
*
|
||||
@ -347,8 +361,7 @@ public:
|
||||
* @param partition number
|
||||
*/
|
||||
EXPORT void removePartitionFiles(std::vector<execplan::CalpontSystemCatalog::OID>& oidList,
|
||||
const PartitionNums& partitions,
|
||||
uint64_t uniqueId);
|
||||
const PartitionNums& partitions, uint64_t uniqueId);
|
||||
|
||||
/** @brief remove the extents from extent map
|
||||
*
|
||||
@ -359,14 +372,13 @@ public:
|
||||
*/
|
||||
EXPORT void removeExtents(std::vector<execplan::CalpontSystemCatalog::OID>& oidList);
|
||||
|
||||
|
||||
/** @brief create and open log file to log a table information
|
||||
*
|
||||
* @param tableOid the oid of the table
|
||||
* @param tableName the shcema, table name
|
||||
*/
|
||||
EXPORT void createWriteDropLogFile(execplan::CalpontSystemCatalog::OID tableOid,
|
||||
uint64_t uniqueId, std::vector<execplan::CalpontSystemCatalog::OID>& oidList);
|
||||
EXPORT void createWriteDropLogFile(execplan::CalpontSystemCatalog::OID tableOid, uint64_t uniqueId,
|
||||
std::vector<execplan::CalpontSystemCatalog::OID>& oidList);
|
||||
|
||||
/** @brief create and open log file to log a table partition information
|
||||
*
|
||||
@ -379,20 +391,22 @@ public:
|
||||
std::vector<execplan::CalpontSystemCatalog::OID>& oidList,
|
||||
uint64_t uniqueId);
|
||||
|
||||
// EXPORT void createOpenTruncateTableLogFile(execplan::CalpontSystemCatalog::OID tableOid, execplan::CalpontSystemCatalog::TableName tableName);
|
||||
// EXPORT void createOpenTruncateTableLogFile(execplan::CalpontSystemCatalog::OID tableOid,
|
||||
// execplan::CalpontSystemCatalog::TableName tableName);
|
||||
|
||||
/** @brief create and open log file to log a truncae table information
|
||||
*
|
||||
* @param tableOid the oid of the table
|
||||
* @param tableName the shcema, table name
|
||||
*/
|
||||
EXPORT void createWriteTruncateTableLogFile(execplan::CalpontSystemCatalog::OID tableOid, uint64_t uniqueId, std::vector<execplan::CalpontSystemCatalog::OID>& oidList);
|
||||
|
||||
EXPORT void createWriteTruncateTableLogFile(execplan::CalpontSystemCatalog::OID tableOid, uint64_t uniqueId,
|
||||
std::vector<execplan::CalpontSystemCatalog::OID>& oidList);
|
||||
|
||||
/** @brief delete log file
|
||||
*
|
||||
*/
|
||||
EXPORT void deleteLogFile(LogFileType fileType, execplan::CalpontSystemCatalog::OID tableOid, uint64_t uniqueId);
|
||||
EXPORT void deleteLogFile(LogFileType fileType, execplan::CalpontSystemCatalog::OID tableOid,
|
||||
uint64_t uniqueId);
|
||||
|
||||
/** @brief fetch log file infomation
|
||||
*
|
||||
@ -424,8 +438,7 @@ protected:
|
||||
* @param data the value to tokenize
|
||||
*/
|
||||
boost::any tokenizeData(execplan::CalpontSystemCatalog::SCN txnID, const DDLResult& result,
|
||||
const execplan::CalpontSystemCatalog::ColType& colType,
|
||||
const boost::any& data );
|
||||
const execplan::CalpontSystemCatalog::ColType& colType, const boost::any& data);
|
||||
|
||||
/** @brief does the supplied constraint type require an index
|
||||
*
|
||||
@ -454,8 +467,7 @@ protected:
|
||||
* @param constraintNumber the constraint number
|
||||
* @param type the constraint type
|
||||
*/
|
||||
std::string buildTableConstraintName(int oid,
|
||||
ddlpackage::DDL_CONSTRAINTS type);
|
||||
std::string buildTableConstraintName(int oid, ddlpackage::DDL_CONSTRAINTS type);
|
||||
|
||||
/** @brief build a column constraint name
|
||||
*
|
||||
@ -464,11 +476,8 @@ protected:
|
||||
* @param column the column name
|
||||
* @param type the constraint type
|
||||
*/
|
||||
std::string buildColumnConstraintName(const std::string& schema,
|
||||
const std::string& table,
|
||||
const std::string& column,
|
||||
ddlpackage::DDL_CONSTRAINTS type);
|
||||
|
||||
std::string buildColumnConstraintName(const std::string& schema, const std::string& table,
|
||||
const std::string& column, ddlpackage::DDL_CONSTRAINTS type);
|
||||
|
||||
/** @brief write the tables meta data to the SYSTABLE table
|
||||
*
|
||||
@ -476,7 +485,8 @@ protected:
|
||||
* @param result the result of the operation
|
||||
* @param tableDef the table definition
|
||||
*/
|
||||
//void writeSysTableMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, const DDLResult& result,
|
||||
// void writeSysTableMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, const
|
||||
// DDLResult& result,
|
||||
// ddlpackage::TableDef& tableDef, uint32_t tableWithAutoi=0);
|
||||
|
||||
/** @brief write the table columns meta data to the SYSCOLUMN table
|
||||
@ -486,7 +496,8 @@ protected:
|
||||
* @param tableDefCols the table columns definition
|
||||
* @param qualifiedName the name of catalog, schema, object names
|
||||
*/
|
||||
//void writeSysColumnMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, const DDLResult& result,
|
||||
// void writeSysColumnMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, const
|
||||
// DDLResult& result,
|
||||
// ddlpackage::ColumnDefList& tableDefCols,
|
||||
// ddlpackage::QualifiedName& qualifiedName, int colpos, bool alterFlag=false );
|
||||
|
||||
@ -497,8 +508,10 @@ protected:
|
||||
* @param constraintList the table constrain list
|
||||
* @param qualifiedName the name of catalog, schema, object names
|
||||
*/
|
||||
// void writeTableSysConstraintMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
// ddlpackage::TableConstraintDefList& constraintList, ddlpackage::QualifiedName&
|
||||
// void writeTableSysConstraintMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
||||
// DDLResult& result,
|
||||
// ddlpackage::TableConstraintDefList& constraintList,
|
||||
// ddlpackage::QualifiedName&
|
||||
// qualifiedName, bool alterFlag=false );
|
||||
/** @brief write the table constraint meta data to the SYSCONSTRAINTCOL table
|
||||
*
|
||||
@ -508,8 +521,9 @@ protected:
|
||||
* @param qualifiedName the name of catalog, schema, object names
|
||||
*/
|
||||
// void writeTableSysConstraintColMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
||||
// const DDLResult& result, ddlpackage::TableConstraintDefList& constraintList,
|
||||
// ddlpackage::QualifiedName& qualifiedName, bool alterFlag=false );
|
||||
// const DDLResult& result, ddlpackage::TableConstraintDefList&
|
||||
// constraintList, ddlpackage::QualifiedName& qualifiedName, bool
|
||||
// alterFlag=false );
|
||||
|
||||
/** @brief write the column constraint meta data to the SYSCONTRAINT table
|
||||
*
|
||||
@ -518,7 +532,8 @@ protected:
|
||||
* @param constraintList the table constrain list
|
||||
* @param qualifiedName the name of catalog, schema, object names
|
||||
*/
|
||||
// void writeColumnSysConstraintMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, const DDLResult& result,
|
||||
// void writeColumnSysConstraintMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
||||
// const DDLResult& result,
|
||||
// ddlpackage::ColumnDefList& tableDefCols,
|
||||
// ddlpackage::QualifiedName& qualifiedName );
|
||||
|
||||
@ -528,11 +543,11 @@ protected:
|
||||
* @param result the result of the operation
|
||||
* @param tableDef the table definition
|
||||
*/
|
||||
// void writeColumnSysConstraintColMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
||||
// void writeColumnSysConstraintColMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN
|
||||
// txnID,
|
||||
// const DDLResult& result, ddlpackage::ColumnDefList& tableDefCols,
|
||||
// ddlpackage::QualifiedName& qualifiedName);
|
||||
|
||||
|
||||
/** @brief write the index meta data to the SYSINDEX table
|
||||
*
|
||||
* @param txnID the transaction id
|
||||
@ -541,7 +556,8 @@ protected:
|
||||
* @param consDef the table constraint
|
||||
* @param indexName name of the index
|
||||
*/
|
||||
// void writeSysIndexMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, const DDLResult& result,
|
||||
// void writeSysIndexMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, const
|
||||
// DDLResult& result,
|
||||
// ddlpackage::QualifiedName& qualifiedName,
|
||||
// ddlpackage::DDL_CONSTRAINTS type,
|
||||
// std::string& indexName, bool multicol, bool alterFlag=false);
|
||||
@ -554,7 +570,8 @@ protected:
|
||||
* @param constraintCols the list of columns in this index
|
||||
* @param indexName name of the index
|
||||
*/
|
||||
// void writeSysIndexColMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, const DDLResult& result,
|
||||
// void writeSysIndexColMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, const
|
||||
// DDLResult& result,
|
||||
// ddlpackage::QualifiedName& qualifiedName,
|
||||
// ddlpackage::ColumnNameList& constraintCols,
|
||||
// std::string& indexName, bool alterFlag=false);
|
||||
@ -583,7 +600,8 @@ protected:
|
||||
* @param result the result of the operation
|
||||
* @param indexName the qualified name of the index
|
||||
*/
|
||||
// void removeSysIndexMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
// void removeSysIndexMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult&
|
||||
// result,
|
||||
// ddlpackage::QualifiedName& indexName);
|
||||
|
||||
/** @brief remove index columns from the SYSINDEXCOL table
|
||||
@ -592,7 +610,8 @@ protected:
|
||||
* @param result the result of the operation
|
||||
* @param indexName the qualified name of the index
|
||||
*/
|
||||
// void removeSysIndexColMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
// void removeSysIndexColMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult&
|
||||
// result,
|
||||
// ddlpackage::QualifiedName& indexName);
|
||||
|
||||
/** @brief remove the table meta data from the SYSTABLE table
|
||||
@ -601,7 +620,8 @@ protected:
|
||||
* @param result the result of the operation
|
||||
* @param tableName the qualified name of the table to remove
|
||||
*/
|
||||
// void removeSysTableMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
// void removeSysTableMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult&
|
||||
// result,
|
||||
// ddlpackage::QualifiedName& tableName);
|
||||
|
||||
/** @brief remove the column meta data from the SYSCOLUMN table
|
||||
@ -611,7 +631,8 @@ protected:
|
||||
* @param tableName the qualified name of the table whose columns
|
||||
* are to be removed
|
||||
*/
|
||||
// void removeSysColMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
// void removeSysColMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult&
|
||||
// result,
|
||||
// ddlpackage::QualifiedName& tableName);
|
||||
|
||||
/** @brief remove the column meta data from the SYSCOLUMN table
|
||||
@ -621,7 +642,8 @@ protected:
|
||||
* @param columnInfo the qualified name of the column
|
||||
* to be removed
|
||||
*/
|
||||
// void removeColSysColMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
// void removeColSysColMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult&
|
||||
// result,
|
||||
// ddlpackage::QualifiedName& columnInfo);
|
||||
|
||||
/** @brief remove the constraint meta data from the SYSCONSTRAINT table
|
||||
@ -631,7 +653,8 @@ protected:
|
||||
* @param tableName the qualified name of the table whose constraints
|
||||
* are to be removed
|
||||
*/
|
||||
// void removeSysContraintMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
// void removeSysContraintMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
||||
// DDLResult& result,
|
||||
// ddlpackage::QualifiedName& tableName);
|
||||
|
||||
/** @brief remove the constraint meta data from the SYSCONSTRAINT table
|
||||
@ -651,7 +674,8 @@ protected:
|
||||
* @param tableName the qualified name of the table whose column constraints
|
||||
* are to be removed
|
||||
*/
|
||||
// void removeSysConstraintColMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, DDLResult& result,
|
||||
// void removeSysConstraintColMetaData(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
||||
// DDLResult& result,
|
||||
// ddlpackage::QualifiedName& tableName);
|
||||
/** @brief remove the column constraint meta data from the SYSCONSTRAINT table
|
||||
*
|
||||
@ -748,8 +772,9 @@ protected:
|
||||
* @param sysCatalogTableName the qualified name of the system catalog table
|
||||
* @param rid the id of the row to remove
|
||||
*/
|
||||
void removeRowFromSysCatalog(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, const DDLResult& result,
|
||||
ddlpackage::QualifiedName& sysCatalogTableName, WriteEngine::RID& rid);
|
||||
void removeRowFromSysCatalog(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
||||
const DDLResult& result, ddlpackage::QualifiedName& sysCatalogTableName,
|
||||
WriteEngine::RID& rid);
|
||||
|
||||
/** @brief validate reference constraint for altering existing table
|
||||
*
|
||||
@ -759,8 +784,7 @@ protected:
|
||||
* @param refIndexName the index name of the referenced primary key constraint
|
||||
* @return true if violation
|
||||
*/
|
||||
bool referenceConstraintViolation(uint32_t sessionID,
|
||||
DDLResult& result,
|
||||
bool referenceConstraintViolation(uint32_t sessionID, DDLResult& result,
|
||||
execplan::CalpontSystemCatalog::TableColName tcn,
|
||||
execplan::CalpontSystemCatalog::IndexName refIndexName);
|
||||
|
||||
@ -772,9 +796,7 @@ protected:
|
||||
* @param constraintCols the columns associated with the primary key
|
||||
* @return true if violation
|
||||
*/
|
||||
bool PKConstraintViolation(uint32_t sessionID,
|
||||
DDLResult& result,
|
||||
ddlpackage::QualifiedName& qualifiedName,
|
||||
bool PKConstraintViolation(uint32_t sessionID, DDLResult& result, ddlpackage::QualifiedName& qualifiedName,
|
||||
ddlpackage::ColumnNameList& constraintCols);
|
||||
/** @brief validate check constraint for altering existing table
|
||||
*
|
||||
@ -784,11 +806,8 @@ protected:
|
||||
* @param checkConstraint the constraint text string
|
||||
* @return true if violation
|
||||
*/
|
||||
bool checkConstraintViolation(uint32_t sessionID,
|
||||
DDLResult& result,
|
||||
ddlpackage::QualifiedName& qualifiedName,
|
||||
std::string& checkConstraint);
|
||||
|
||||
bool checkConstraintViolation(uint32_t sessionID, DDLResult& result,
|
||||
ddlpackage::QualifiedName& qualifiedName, std::string& checkConstraint);
|
||||
|
||||
/** @brief remove the supplied rows from the supplied system catalog table
|
||||
*
|
||||
@ -796,11 +815,10 @@ protected:
|
||||
* @param sysCatalogTableName the qualified name of the system catalog table
|
||||
* @param colRidList the list of row ids to remove
|
||||
*/
|
||||
void removeRowsFromSysCatalog(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID, const DDLResult& result,
|
||||
ddlpackage::QualifiedName& sysCatalogTableName,
|
||||
void removeRowsFromSysCatalog(uint32_t sessionID, execplan::CalpontSystemCatalog::SCN txnID,
|
||||
const DDLResult& result, ddlpackage::QualifiedName& sysCatalogTableName,
|
||||
execplan::CalpontSystemCatalog::RIDList& colRidList);
|
||||
|
||||
|
||||
WriteEngine::WriteEngineWrapper fWriteEngine;
|
||||
|
||||
BRM::DBRM* fDbrm;
|
||||
@ -809,7 +827,6 @@ protected:
|
||||
uint32_t fPMCount;
|
||||
WriteEngine::WEClients* fWEClient;
|
||||
|
||||
|
||||
DictionaryOIDList fDictionaryOIDList;
|
||||
|
||||
// store oids used during table and index creation
|
||||
@ -840,16 +857,16 @@ protected:
|
||||
* @param startDBRoot the dbroot this table starts
|
||||
* @param dbrootCnt the number of dbroot in db
|
||||
*/
|
||||
void convertRidToColumn(uint64_t& rid, unsigned& dbRoot, unsigned& partition,
|
||||
unsigned& segment, unsigned filesPerColumnPartition,
|
||||
unsigned extentsPerSegmentFile, unsigned extentRows,
|
||||
unsigned startDBRoot, unsigned dbrootCnt);
|
||||
void convertRidToColumn(uint64_t& rid, unsigned& dbRoot, unsigned& partition, unsigned& segment,
|
||||
unsigned filesPerColumnPartition, unsigned extentsPerSegmentFile,
|
||||
unsigned extentRows, unsigned startDBRoot, unsigned dbrootCnt);
|
||||
|
||||
int rollBackTransaction(uint64_t uniqueId, BRM::TxnID txnID, uint32_t sessionID);
|
||||
int commitTransaction(uint64_t uniqueId, BRM::TxnID txnID);
|
||||
|
||||
// MCOL-66 The DBRM can't handle concurrent DDL
|
||||
static boost::mutex dbrmMutex;
|
||||
|
||||
private:
|
||||
/** @brief clean beginning and ending glitches and spaces from string
|
||||
*
|
||||
@ -858,25 +875,19 @@ private:
|
||||
void cleanString(std::string& s);
|
||||
// std::string fDDLLogFileName;
|
||||
DebugLevel fDebugLevel; // internal use debug level
|
||||
|
||||
|
||||
|
||||
};
|
||||
/** @brief helper template function to do safe from string to type conversions
|
||||
*
|
||||
*/
|
||||
template <class T>
|
||||
bool from_string(T& t,
|
||||
const std::string& s,
|
||||
std::ios_base & (*f)(std::ios_base&))
|
||||
bool from_string(T& t, const std::string& s, std::ios_base& (*f)(std::ios_base&))
|
||||
{
|
||||
std::istringstream iss(s);
|
||||
return !(iss >> f >> t).fail();
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace ddlpackageprocessor
|
||||
|
||||
#undef EXPORT
|
||||
|
||||
// vim:ts=4 sw=4:
|
||||
|
||||
|
@ -30,26 +30,18 @@ using namespace ddlpackage;
|
||||
|
||||
namespace ddlpackageprocessor
|
||||
{
|
||||
|
||||
DDLPackageProcessor* DDLPackageProcessorFactory::
|
||||
makePackageProcessor(int packageType, ddlpackage::CalpontDDLPackage& cpackage)
|
||||
DDLPackageProcessor* DDLPackageProcessorFactory::makePackageProcessor(int packageType,
|
||||
ddlpackage::CalpontDDLPackage& cpackage)
|
||||
{
|
||||
DDLPackageProcessor* ddlProcPtr = 0;
|
||||
|
||||
switch (packageType)
|
||||
{
|
||||
case DDL_CREATE:
|
||||
ddlProcPtr = new CreatePackageProcessor();
|
||||
break;
|
||||
case DDL_CREATE: ddlProcPtr = new CreatePackageProcessor(); break;
|
||||
|
||||
case DDL_ALTER:
|
||||
ddlProcPtr = new AlterPackageProcessor();
|
||||
break;
|
||||
|
||||
case DDL_DROP:
|
||||
ddlProcPtr = new DropPackageProcessor();
|
||||
break;
|
||||
case DDL_ALTER: ddlProcPtr = new AlterPackageProcessor(); break;
|
||||
|
||||
case DDL_DROP: ddlProcPtr = new DropPackageProcessor(); break;
|
||||
}
|
||||
|
||||
return ddlProcPtr;
|
||||
|
@ -26,30 +26,23 @@
|
||||
#include "ddlpkg.h"
|
||||
#include "ddlpackageprocessor.h"
|
||||
|
||||
|
||||
namespace ddlpackageprocessor
|
||||
{
|
||||
|
||||
/** @brief create a ddlPackageProcessor object from a CalpontddlPackage object
|
||||
*
|
||||
*/
|
||||
class DDLPackageProcessorFactory
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
/** @brief static ddlPackageProcessor constructor method
|
||||
*
|
||||
* @param packageType the ddl Package type
|
||||
* @param cpackage the CalpontddlPackage from which the ddlPackageProcessor is constructed
|
||||
*/
|
||||
static DDLPackageProcessor*
|
||||
makePackageProcessor( int packageType, ddlpackage::CalpontDDLPackage& cpackage );
|
||||
static DDLPackageProcessor* makePackageProcessor(int packageType, ddlpackage::CalpontDDLPackage& cpackage);
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
} // namespace ddlpackageprocessor
|
||||
|
@ -30,11 +30,13 @@ using namespace logging;
|
||||
|
||||
namespace ddlpackageprocessor
|
||||
{
|
||||
DropIndexProcessor::DDLResult DropIndexProcessor::processPackage(ddlpackage::DropIndexStatement& dropIndexStmt)
|
||||
DropIndexProcessor::DDLResult DropIndexProcessor::processPackage(
|
||||
ddlpackage::DropIndexStatement& dropIndexStmt)
|
||||
{
|
||||
SUMMARY_INFO("DropIndexProcessor::processPackage");
|
||||
|
||||
boost::shared_ptr<CalpontSystemCatalog> sysCatalogPtr = CalpontSystemCatalog::makeCalpontSystemCatalog( dropIndexStmt.fSessionID );
|
||||
boost::shared_ptr<CalpontSystemCatalog> sysCatalogPtr =
|
||||
CalpontSystemCatalog::makeCalpontSystemCatalog(dropIndexStmt.fSessionID);
|
||||
CalpontSystemCatalog::IndexName indexName;
|
||||
CalpontSystemCatalog::IndexOID indexOID;
|
||||
|
||||
@ -54,7 +56,8 @@ DropIndexProcessor::DDLResult DropIndexProcessor::processPackage(ddlpackage::Dro
|
||||
indexName.schema = dropIndexStmt.fIndexName->fSchema;
|
||||
indexName.index = dropIndexStmt.fIndexName->fName;
|
||||
// Look up table name from indexname. Oracle will error out if same constraintname or indexname exists.
|
||||
CalpontSystemCatalog::TableName tableName = sysCatalogPtr->lookupTableForIndex (dropIndexStmt.fIndexName->fName, dropIndexStmt.fIndexName->fSchema );
|
||||
CalpontSystemCatalog::TableName tableName =
|
||||
sysCatalogPtr->lookupTableForIndex(dropIndexStmt.fIndexName->fName, dropIndexStmt.fIndexName->fSchema);
|
||||
indexName.table = tableName.table;
|
||||
indexOID = sysCatalogPtr->lookupIndexNbr(indexName);
|
||||
|
||||
@ -76,7 +79,6 @@ DropIndexProcessor::DDLResult DropIndexProcessor::processPackage(ddlpackage::Dro
|
||||
goto rollback;
|
||||
}
|
||||
|
||||
|
||||
VERBOSE_INFO("Removing the index files");
|
||||
err = fWriteEngine.dropIndex(txnID.id, indexOID.objnum, indexOID.listOID);
|
||||
|
||||
@ -109,6 +111,4 @@ rollback:
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace ddlpackageprocessor
|
||||
|
@ -41,9 +41,7 @@ public:
|
||||
DDLResult processPackage(ddlpackage::DropIndexStatement& dropIndexStmt);
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
} // namespace ddlpackageprocessor
|
||||
|
@ -37,8 +37,8 @@ using namespace oam;
|
||||
|
||||
namespace ddlpackageprocessor
|
||||
{
|
||||
|
||||
DropPartitionProcessor::DDLResult DropPartitionProcessor::processPackage(ddlpackage::DropPartitionStatement& dropPartitionStmt)
|
||||
DropPartitionProcessor::DDLResult DropPartitionProcessor::processPackage(
|
||||
ddlpackage::DropPartitionStatement& dropPartitionStmt)
|
||||
{
|
||||
SUMMARY_INFO("DropPartitionProcessor::processPackage");
|
||||
|
||||
@ -69,7 +69,6 @@ DropPartitionProcessor::DDLResult DropPartitionProcessor::processPackage(ddlpack
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
std::vector<CalpontSystemCatalog::OID> oidList;
|
||||
CalpontSystemCatalog::RIDList tableColRidList;
|
||||
CalpontSystemCatalog::DictOIDList dictOIDList;
|
||||
@ -114,7 +113,8 @@ DropPartitionProcessor::DDLResult DropPartitionProcessor::processPackage(ddlpack
|
||||
try
|
||||
{
|
||||
// check table lock
|
||||
boost::shared_ptr<CalpontSystemCatalog> systemCatalogPtr = CalpontSystemCatalog::makeCalpontSystemCatalog(dropPartitionStmt.fSessionID);
|
||||
boost::shared_ptr<CalpontSystemCatalog> systemCatalogPtr =
|
||||
CalpontSystemCatalog::makeCalpontSystemCatalog(dropPartitionStmt.fSessionID);
|
||||
systemCatalogPtr->identity(CalpontSystemCatalog::EC);
|
||||
systemCatalogPtr->sessionID(dropPartitionStmt.fSessionID);
|
||||
CalpontSystemCatalog::TableName tableName;
|
||||
@ -141,7 +141,8 @@ DropPartitionProcessor::DDLResult DropPartitionProcessor::processPackage(ddlpack
|
||||
|
||||
try
|
||||
{
|
||||
uniqueID = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, (int32_t*)&sessionID, (int32_t*)&txnID.id, BRM::LOADING );
|
||||
uniqueID = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, (int32_t*)&sessionID,
|
||||
(int32_t*)&txnID.id, BRM::LOADING);
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
@ -175,8 +176,7 @@ DropPartitionProcessor::DDLResult DropPartitionProcessor::processPackage(ddlpack
|
||||
{
|
||||
abs_ts.tv_sec = rm_ts.tv_sec;
|
||||
abs_ts.tv_nsec = rm_ts.tv_nsec;
|
||||
}
|
||||
while (nanosleep(&abs_ts, &rm_ts) < 0);
|
||||
} while (nanosleep(&abs_ts, &rm_ts) < 0);
|
||||
|
||||
#endif
|
||||
// reset
|
||||
@ -188,7 +188,8 @@ DropPartitionProcessor::DDLResult DropPartitionProcessor::processPackage(ddlpack
|
||||
|
||||
try
|
||||
{
|
||||
uniqueID = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, (int32_t*)&sessionID, (int32_t*)&txnID.id, BRM::LOADING );
|
||||
uniqueID = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, (int32_t*)&sessionID,
|
||||
(int32_t*)&txnID.id, BRM::LOADING);
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
@ -250,8 +251,7 @@ DropPartitionProcessor::DDLResult DropPartitionProcessor::processPackage(ddlpack
|
||||
string emsg;
|
||||
rc = fDbrm->markPartitionForDeletion(oidList, dropPartitionStmt.fPartitions, emsg);
|
||||
|
||||
if (rc != 0 && rc != BRM::ERR_PARTITION_DISABLED &&
|
||||
rc != BRM::ERR_INVALID_OP_LAST_PARTITION &&
|
||||
if (rc != 0 && rc != BRM::ERR_PARTITION_DISABLED && rc != BRM::ERR_INVALID_OP_LAST_PARTITION &&
|
||||
rc != BRM::ERR_NOT_EXIST_PARTITION)
|
||||
{
|
||||
throw std::runtime_error(emsg);
|
||||
@ -377,4 +377,4 @@ DropPartitionProcessor::DDLResult DropPartitionProcessor::processPackage(ddlpack
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace ddlpackageprocessor
|
||||
|
@ -40,7 +40,9 @@ namespace ddlpackageprocessor
|
||||
class DropPartitionProcessor : public DDLPackageProcessor
|
||||
{
|
||||
public:
|
||||
DropPartitionProcessor(BRM::DBRM* aDbrm) : DDLPackageProcessor(aDbrm) {}
|
||||
DropPartitionProcessor(BRM::DBRM* aDbrm) : DDLPackageProcessor(aDbrm)
|
||||
{
|
||||
}
|
||||
/** @brief process a drop table statement
|
||||
*
|
||||
* @param dropTableStmt the drop table statement
|
||||
@ -48,11 +50,8 @@ public:
|
||||
EXPORT DDLResult processPackage(ddlpackage::DropPartitionStatement& dropPartitionStmt);
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
} // namespace ddlpackageprocessor
|
||||
|
||||
#undef EXPORT
|
||||
|
||||
|
@ -50,8 +50,8 @@ using namespace oam;
|
||||
|
||||
namespace ddlpackageprocessor
|
||||
{
|
||||
|
||||
DropTableProcessor::DDLResult DropTableProcessor::processPackage(ddlpackage::DropTableStatement& dropTableStmt)
|
||||
DropTableProcessor::DDLResult DropTableProcessor::processPackage(
|
||||
ddlpackage::DropTableStatement& dropTableStmt)
|
||||
{
|
||||
SUMMARY_INFO("DropTableProcessor::processPackage");
|
||||
|
||||
@ -134,7 +134,8 @@ DropTableProcessor::DDLResult DropTableProcessor::processPackage(ddlpackage::Dro
|
||||
try
|
||||
{
|
||||
// check table lock
|
||||
boost::shared_ptr<CalpontSystemCatalog> systemCatalogPtr = CalpontSystemCatalog::makeCalpontSystemCatalog(dropTableStmt.fSessionID);
|
||||
boost::shared_ptr<CalpontSystemCatalog> systemCatalogPtr =
|
||||
CalpontSystemCatalog::makeCalpontSystemCatalog(dropTableStmt.fSessionID);
|
||||
systemCatalogPtr->identity(CalpontSystemCatalog::EC);
|
||||
systemCatalogPtr->sessionID(dropTableStmt.fSessionID);
|
||||
CalpontSystemCatalog::TableName tableName;
|
||||
@ -187,7 +188,8 @@ DropTableProcessor::DDLResult DropTableProcessor::processPackage(ddlpackage::Dro
|
||||
|
||||
try
|
||||
{
|
||||
tableLockId = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, &sessionId, &txnid, BRM::LOADING );
|
||||
tableLockId =
|
||||
fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, &sessionId, &txnid, BRM::LOADING);
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
@ -217,8 +219,7 @@ DropTableProcessor::DDLResult DropTableProcessor::processPackage(ddlpackage::Dro
|
||||
{
|
||||
abs_ts.tv_sec = rm_ts.tv_sec;
|
||||
abs_ts.tv_nsec = rm_ts.tv_nsec;
|
||||
}
|
||||
while (nanosleep(&abs_ts, &rm_ts) < 0);
|
||||
} while (nanosleep(&abs_ts, &rm_ts) < 0);
|
||||
|
||||
#endif
|
||||
|
||||
@ -226,9 +227,11 @@ DropTableProcessor::DDLResult DropTableProcessor::processPackage(ddlpackage::Dro
|
||||
{
|
||||
processID = ::getpid();
|
||||
txnid = txnID.id;
|
||||
sessionId = dropTableStmt.fSessionID;;
|
||||
sessionId = dropTableStmt.fSessionID;
|
||||
;
|
||||
processName = "DDLProc";
|
||||
tableLockId = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, &sessionId, &txnid, BRM::LOADING );
|
||||
tableLockId = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, &sessionId, &txnid,
|
||||
BRM::LOADING);
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
@ -369,7 +372,8 @@ DropTableProcessor::DDLResult DropTableProcessor::processPackage(ddlpackage::Dro
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
cout << fTxnid.id << " Error in dropping table from systables(" << (int)rc << ") " << errorMsg.c_str() << endl;
|
||||
cout << fTxnid.id << " Error in dropping table from systables(" << (int)rc << ") " << errorMsg.c_str()
|
||||
<< endl;
|
||||
Message::Args args;
|
||||
Message message(9);
|
||||
args.add("Error in dropping table from systables.");
|
||||
@ -461,7 +465,8 @@ DropTableProcessor::DDLResult DropTableProcessor::processPackage(ddlpackage::Dro
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
cout << fTxnid.id << " Error in dropping column from systables(" << (int)rc << ") " << errorMsg.c_str() << endl;
|
||||
cout << fTxnid.id << " Error in dropping column from systables(" << (int)rc << ") " << errorMsg.c_str()
|
||||
<< endl;
|
||||
Message::Args args;
|
||||
Message message(9);
|
||||
args.add("Error in dropping column from systables.");
|
||||
@ -480,7 +485,8 @@ DropTableProcessor::DDLResult DropTableProcessor::processPackage(ddlpackage::Dro
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
cout << txnID.id << " rolledback transaction " << " and valid is " << txnID.valid << endl;
|
||||
cout << txnID.id << " rolledback transaction "
|
||||
<< " and valid is " << txnID.valid << endl;
|
||||
fSessionManager.rolledback(txnID);
|
||||
}
|
||||
else
|
||||
@ -712,10 +718,10 @@ DropTableProcessor::DDLResult DropTableProcessor::processPackage(ddlpackage::Dro
|
||||
// fSessionManager.committed(txnID);
|
||||
returnOIDs(tableColRidList, dictOIDList);
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
TruncTableProcessor::DDLResult TruncTableProcessor::processPackage(ddlpackage::TruncTableStatement& truncTableStmt)
|
||||
TruncTableProcessor::DDLResult TruncTableProcessor::processPackage(
|
||||
ddlpackage::TruncTableStatement& truncTableStmt)
|
||||
{
|
||||
SUMMARY_INFO("TruncTableProcessor::processPackage");
|
||||
// 1. lock the table
|
||||
@ -763,9 +769,11 @@ TruncTableProcessor::DDLResult TruncTableProcessor::processPackage(ddlpackage::T
|
||||
CalpontSystemCatalog::DictOIDList dictOIDList;
|
||||
execplan::CalpontSystemCatalog::ROPair roPair;
|
||||
std::string processName("DDLProc");
|
||||
uint32_t processID = ::getpid();;
|
||||
uint32_t processID = ::getpid();
|
||||
;
|
||||
int32_t txnid = txnID.id;
|
||||
boost::shared_ptr<CalpontSystemCatalog> systemCatalogPtr = CalpontSystemCatalog::makeCalpontSystemCatalog(truncTableStmt.fSessionID);
|
||||
boost::shared_ptr<CalpontSystemCatalog> systemCatalogPtr =
|
||||
CalpontSystemCatalog::makeCalpontSystemCatalog(truncTableStmt.fSessionID);
|
||||
systemCatalogPtr->identity(CalpontSystemCatalog::EC);
|
||||
systemCatalogPtr->sessionID(truncTableStmt.fSessionID);
|
||||
CalpontSystemCatalog::TableInfo tableInfo;
|
||||
@ -829,7 +837,8 @@ TruncTableProcessor::DDLResult TruncTableProcessor::processPackage(ddlpackage::T
|
||||
|
||||
try
|
||||
{
|
||||
tableLockId = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, &sessionId, &txnid, BRM::LOADING );
|
||||
tableLockId =
|
||||
fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, &sessionId, &txnid, BRM::LOADING);
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
@ -859,8 +868,7 @@ TruncTableProcessor::DDLResult TruncTableProcessor::processPackage(ddlpackage::T
|
||||
{
|
||||
abs_ts.tv_sec = rm_ts.tv_sec;
|
||||
abs_ts.tv_nsec = rm_ts.tv_nsec;
|
||||
}
|
||||
while (nanosleep(&abs_ts, &rm_ts) < 0);
|
||||
} while (nanosleep(&abs_ts, &rm_ts) < 0);
|
||||
|
||||
#endif
|
||||
|
||||
@ -870,7 +878,8 @@ TruncTableProcessor::DDLResult TruncTableProcessor::processPackage(ddlpackage::T
|
||||
txnid = txnID.id;
|
||||
sessionId = truncTableStmt.fSessionID;
|
||||
processName = "DDLProc";
|
||||
tableLockId = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, &sessionId, &txnid, BRM::LOADING );
|
||||
tableLockId = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, &sessionId, &txnid,
|
||||
BRM::LOADING);
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
@ -991,7 +1000,9 @@ TruncTableProcessor::DDLResult TruncTableProcessor::processPackage(ddlpackage::T
|
||||
{
|
||||
(void)fDbrm->releaseTableLock(tableLockId);
|
||||
}
|
||||
catch (std::exception&) {}
|
||||
catch (std::exception&)
|
||||
{
|
||||
}
|
||||
|
||||
result.result = TRUNC_ERROR;
|
||||
result.message = message;
|
||||
@ -1245,7 +1256,8 @@ TruncTableProcessor::DDLResult TruncTableProcessor::processPackage(ddlpackage::T
|
||||
|
||||
result.result = TRUNC_ERROR;
|
||||
result.message = message;
|
||||
//rc = fSessionManager.setTableLock( roPair.objnum, truncTableStmt.fSessionID, processID, processName, false );
|
||||
// rc = fSessionManager.setTableLock( roPair.objnum, truncTableStmt.fSessionID, processID,
|
||||
// processName, false );
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
@ -1275,7 +1287,8 @@ TruncTableProcessor::DDLResult TruncTableProcessor::processPackage(ddlpackage::T
|
||||
|
||||
result.result = TRUNC_ERROR;
|
||||
result.message = message;
|
||||
//rc = fSessionManager.setTableLock( roPair.objnum, truncTableStmt.fSessionID, processID, processName, false );
|
||||
// rc = fSessionManager.setTableLock( roPair.objnum, truncTableStmt.fSessionID, processID, processName,
|
||||
// false );
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
@ -1293,7 +1306,8 @@ TruncTableProcessor::DDLResult TruncTableProcessor::processPackage(ddlpackage::T
|
||||
|
||||
result.result = TRUNC_ERROR;
|
||||
result.message = message;
|
||||
//rc = fSessionManager.setTableLock( roPair.objnum, truncTableStmt.fSessionID, processID, processName, false );
|
||||
// rc = fSessionManager.setTableLock( roPair.objnum, truncTableStmt.fSessionID, processID, processName,
|
||||
// false );
|
||||
fSessionManager.rolledback(txnID);
|
||||
return result;
|
||||
}
|
||||
@ -1354,4 +1368,3 @@ TruncTableProcessor::DDLResult TruncTableProcessor::processPackage(ddlpackage::T
|
||||
} // namespace ddlpackageprocessor
|
||||
|
||||
// vim:ts=4 sw=4:
|
||||
|
||||
|
@ -40,7 +40,9 @@ namespace ddlpackageprocessor
|
||||
class DropTableProcessor : public DDLPackageProcessor
|
||||
{
|
||||
public:
|
||||
DropTableProcessor(BRM::DBRM* aDbrm) : DDLPackageProcessor(aDbrm) {}
|
||||
DropTableProcessor(BRM::DBRM* aDbrm) : DDLPackageProcessor(aDbrm)
|
||||
{
|
||||
}
|
||||
/** @brief process a drop table statement
|
||||
*
|
||||
* @param dropTableStmt the drop table statement
|
||||
@ -48,9 +50,7 @@ public:
|
||||
EXPORT DDLResult processPackage(ddlpackage::DropTableStatement& dropTableStmt);
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
/** @brief specialization of a DDLPacakageProcessor
|
||||
@ -60,7 +60,9 @@ private:
|
||||
class TruncTableProcessor : public DDLPackageProcessor
|
||||
{
|
||||
public:
|
||||
TruncTableProcessor(BRM::DBRM* aDbrm) : DDLPackageProcessor(aDbrm) {}
|
||||
TruncTableProcessor(BRM::DBRM* aDbrm) : DDLPackageProcessor(aDbrm)
|
||||
{
|
||||
}
|
||||
/** @brief process a truncate table statement
|
||||
*
|
||||
* @param truncTableStmt the truncate table statement
|
||||
@ -68,12 +70,9 @@ public:
|
||||
EXPORT DDLResult processPackage(ddlpackage::TruncTableStatement& truncTableStmt);
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
} // namespace ddlpackageprocessor
|
||||
|
||||
#undef EXPORT
|
||||
|
||||
|
@ -34,8 +34,8 @@ using namespace oam;
|
||||
|
||||
namespace ddlpackageprocessor
|
||||
{
|
||||
|
||||
MarkPartitionProcessor::DDLResult MarkPartitionProcessor::processPackage(ddlpackage::MarkPartitionStatement& markPartitionStmt)
|
||||
MarkPartitionProcessor::DDLResult MarkPartitionProcessor::processPackage(
|
||||
ddlpackage::MarkPartitionStatement& markPartitionStmt)
|
||||
{
|
||||
SUMMARY_INFO("RestorePartitionProcessor::processPackage");
|
||||
|
||||
@ -79,7 +79,8 @@ MarkPartitionProcessor::DDLResult MarkPartitionProcessor::processPackage(ddlpack
|
||||
try
|
||||
{
|
||||
// check table lock
|
||||
boost::shared_ptr<CalpontSystemCatalog> systemCatalogPtr = CalpontSystemCatalog::makeCalpontSystemCatalog(markPartitionStmt.fSessionID);
|
||||
boost::shared_ptr<CalpontSystemCatalog> systemCatalogPtr =
|
||||
CalpontSystemCatalog::makeCalpontSystemCatalog(markPartitionStmt.fSessionID);
|
||||
systemCatalogPtr->identity(CalpontSystemCatalog::EC);
|
||||
systemCatalogPtr->sessionID(markPartitionStmt.fSessionID);
|
||||
CalpontSystemCatalog::TableName tableName;
|
||||
@ -106,7 +107,8 @@ MarkPartitionProcessor::DDLResult MarkPartitionProcessor::processPackage(ddlpack
|
||||
|
||||
try
|
||||
{
|
||||
uniqueID = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, (int32_t*)&sessionID, (int32_t*)&txnID.id, BRM::LOADING );
|
||||
uniqueID = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, (int32_t*)&sessionID,
|
||||
(int32_t*)&txnID.id, BRM::LOADING);
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
@ -139,8 +141,7 @@ MarkPartitionProcessor::DDLResult MarkPartitionProcessor::processPackage(ddlpack
|
||||
{
|
||||
abs_ts.tv_sec = rm_ts.tv_sec;
|
||||
abs_ts.tv_nsec = rm_ts.tv_nsec;
|
||||
}
|
||||
while (nanosleep(&abs_ts, &rm_ts) < 0);
|
||||
} while (nanosleep(&abs_ts, &rm_ts) < 0);
|
||||
|
||||
#endif
|
||||
// reset
|
||||
@ -152,7 +153,8 @@ MarkPartitionProcessor::DDLResult MarkPartitionProcessor::processPackage(ddlpack
|
||||
|
||||
try
|
||||
{
|
||||
uniqueID = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, (int32_t*)&sessionID, (int32_t*)&txnID.id, BRM::LOADING );
|
||||
uniqueID = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, (int32_t*)&sessionID,
|
||||
(int32_t*)&txnID.id, BRM::LOADING);
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
@ -294,4 +296,4 @@ MarkPartitionProcessor::DDLResult MarkPartitionProcessor::processPackage(ddlpack
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace ddlpackageprocessor
|
||||
|
@ -33,7 +33,6 @@
|
||||
|
||||
namespace ddlpackageprocessor
|
||||
{
|
||||
|
||||
/** @brief specialization of a DDLPackageProcessor
|
||||
* for interacting with the Write Engine
|
||||
* to process create table ddl statements.
|
||||
@ -41,7 +40,9 @@ namespace ddlpackageprocessor
|
||||
class MarkPartitionProcessor : public DDLPackageProcessor
|
||||
{
|
||||
public:
|
||||
MarkPartitionProcessor(BRM::DBRM* aDbrm) : DDLPackageProcessor(aDbrm) {}
|
||||
MarkPartitionProcessor(BRM::DBRM* aDbrm) : DDLPackageProcessor(aDbrm)
|
||||
{
|
||||
}
|
||||
/** @brief process a create table statement
|
||||
*
|
||||
* @param createTableStmt the CreateTableStatement
|
||||
@ -49,13 +50,9 @@ public:
|
||||
EXPORT DDLResult processPackage(ddlpackage::MarkPartitionStatement& MarkPartitionStmt);
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
} // namespace ddlpackageprocessor
|
||||
|
||||
#undef EXPORT
|
||||
|
||||
|
@ -61,8 +61,9 @@ using namespace joblist;
|
||||
class PopulateIndexTest
|
||||
{
|
||||
public:
|
||||
|
||||
PopulateIndexTest(DistributedEngineComm* ec) : fEC(ec) { }
|
||||
PopulateIndexTest(DistributedEngineComm* ec) : fEC(ec)
|
||||
{
|
||||
}
|
||||
DistributedEngineComm* fEC;
|
||||
|
||||
void test_createindex()
|
||||
@ -79,7 +80,8 @@ public:
|
||||
const ParseTree& ptree = parser.GetParseTree();
|
||||
|
||||
cout << "Parser succeeded." << endl;
|
||||
cout << ptree.fList.size() << " " << "SQL statements" << endl;
|
||||
cout << ptree.fList.size() << " "
|
||||
<< "SQL statements" << endl;
|
||||
cout << ptree.fSqlText << endl;
|
||||
|
||||
try
|
||||
@ -152,7 +154,8 @@ public:
|
||||
processor.setDebugLevel(CreateIndexProcessor::VERBOSE);
|
||||
|
||||
SqlStatement& stmt = *ptree.fList[0];
|
||||
CreateIndexProcessor::DDLResult result = processor.processPackage(dynamic_cast<CreateIndexStatement&>(stmt));
|
||||
CreateIndexProcessor::DDLResult result =
|
||||
processor.processPackage(dynamic_cast<CreateIndexStatement&>(stmt));
|
||||
std::cout << "return: " << result.result << std::endl;
|
||||
}
|
||||
catch (...)
|
||||
@ -162,7 +165,6 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void test_createtabletest(const string& sqlbuf)
|
||||
{
|
||||
cout << "Begining create table test: " << sqlbuf << endl;
|
||||
@ -255,11 +257,8 @@ public:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
int DoAll = 0;
|
||||
@ -309,45 +308,80 @@ int main( int argc, char** argv)
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
if (strcmp(argv[1], "All") == 0) DoAll = 1;
|
||||
else if (strcmp(argv[1], "t1") == 0) Do1 = 1;
|
||||
else if (strcmp(argv[1], "t2") == 0) Do2 = 1;
|
||||
else if (strcmp(argv[1], "t3") == 0) Do3 = 1;
|
||||
else if (strcmp(argv[1], "t4") == 0) Do4 = 1;
|
||||
else if (strcmp(argv[1], "t5") == 0) Do5 = 1;
|
||||
else if (strcmp(argv[1], "t6") == 0) Do6 = 1;
|
||||
else if (strcmp(argv[1], "t7") == 0) Do7 = 1;
|
||||
else if (strcmp(argv[1], "t8") == 0) Do8 = 1;
|
||||
else if (strcmp(argv[1], "t9") == 0) Do9 = 1;
|
||||
else if (strcmp(argv[1], "t10") == 0) Do10 = 1;
|
||||
else if (strcmp(argv[1], "t11") == 0) Do11 = 1;
|
||||
else if (strcmp(argv[1], "t12") == 0) Do12 = 1;
|
||||
else if (strcmp(argv[1], "t13") == 0) Do13 = 1;
|
||||
else if (strcmp(argv[1], "t14") == 0) Do14 = 1;
|
||||
else if (strcmp(argv[1], "t15") == 0) Do15 = 1;
|
||||
else if (strcmp(argv[1], "t16") == 0) Do16 = 1;
|
||||
else if (strcmp(argv[1], "t17") == 0) Do17 = 1;
|
||||
else if (strcmp(argv[1], "t18") == 0) Do18 = 1;
|
||||
else if (strcmp(argv[1], "t19") == 0) Do19 = 1;
|
||||
else if (strcmp(argv[1], "t20") == 0) Do20 = 1;
|
||||
else if (strcmp(argv[1], "t21") == 0) Do21 = 1;
|
||||
else if (strcmp(argv[1], "t22") == 0) Do22 = 1;
|
||||
else if (strcmp(argv[1], "t23") == 0) Do23 = 1;
|
||||
else if (strcmp(argv[1], "t24") == 0) Do24 = 1;
|
||||
else if (strcmp(argv[1], "t25") == 0) Do25 = 1;
|
||||
else if (strcmp(argv[1], "t26") == 0) Do26 = 1;
|
||||
else if (strcmp(argv[1], "t27") == 0) Do27 = 1;
|
||||
else if (strcmp(argv[1], "t28") == 0) Do28 = 1;
|
||||
else if (strcmp(argv[1], "t29") == 0) Do29 = 1;
|
||||
else if (strcmp(argv[1], "t30") == 0) Do30 = 1;
|
||||
else if (strcmp(argv[1], "t31") == 0) Do31 = 1;
|
||||
else if (strcmp(argv[1], "t32") == 0) Do32 = 1;
|
||||
else if (strcmp(argv[1], "t33") == 0) Do33 = 1;
|
||||
else if (strcmp(argv[1], "t34") == 0) Do34 = 1;
|
||||
else if (strcmp(argv[1], "t35") == 0) Do35 = 1;
|
||||
else if (strcmp(argv[1], "t36") == 0) Do35 = 1;
|
||||
|
||||
|
||||
if (strcmp(argv[1], "All") == 0)
|
||||
DoAll = 1;
|
||||
else if (strcmp(argv[1], "t1") == 0)
|
||||
Do1 = 1;
|
||||
else if (strcmp(argv[1], "t2") == 0)
|
||||
Do2 = 1;
|
||||
else if (strcmp(argv[1], "t3") == 0)
|
||||
Do3 = 1;
|
||||
else if (strcmp(argv[1], "t4") == 0)
|
||||
Do4 = 1;
|
||||
else if (strcmp(argv[1], "t5") == 0)
|
||||
Do5 = 1;
|
||||
else if (strcmp(argv[1], "t6") == 0)
|
||||
Do6 = 1;
|
||||
else if (strcmp(argv[1], "t7") == 0)
|
||||
Do7 = 1;
|
||||
else if (strcmp(argv[1], "t8") == 0)
|
||||
Do8 = 1;
|
||||
else if (strcmp(argv[1], "t9") == 0)
|
||||
Do9 = 1;
|
||||
else if (strcmp(argv[1], "t10") == 0)
|
||||
Do10 = 1;
|
||||
else if (strcmp(argv[1], "t11") == 0)
|
||||
Do11 = 1;
|
||||
else if (strcmp(argv[1], "t12") == 0)
|
||||
Do12 = 1;
|
||||
else if (strcmp(argv[1], "t13") == 0)
|
||||
Do13 = 1;
|
||||
else if (strcmp(argv[1], "t14") == 0)
|
||||
Do14 = 1;
|
||||
else if (strcmp(argv[1], "t15") == 0)
|
||||
Do15 = 1;
|
||||
else if (strcmp(argv[1], "t16") == 0)
|
||||
Do16 = 1;
|
||||
else if (strcmp(argv[1], "t17") == 0)
|
||||
Do17 = 1;
|
||||
else if (strcmp(argv[1], "t18") == 0)
|
||||
Do18 = 1;
|
||||
else if (strcmp(argv[1], "t19") == 0)
|
||||
Do19 = 1;
|
||||
else if (strcmp(argv[1], "t20") == 0)
|
||||
Do20 = 1;
|
||||
else if (strcmp(argv[1], "t21") == 0)
|
||||
Do21 = 1;
|
||||
else if (strcmp(argv[1], "t22") == 0)
|
||||
Do22 = 1;
|
||||
else if (strcmp(argv[1], "t23") == 0)
|
||||
Do23 = 1;
|
||||
else if (strcmp(argv[1], "t24") == 0)
|
||||
Do24 = 1;
|
||||
else if (strcmp(argv[1], "t25") == 0)
|
||||
Do25 = 1;
|
||||
else if (strcmp(argv[1], "t26") == 0)
|
||||
Do26 = 1;
|
||||
else if (strcmp(argv[1], "t27") == 0)
|
||||
Do27 = 1;
|
||||
else if (strcmp(argv[1], "t28") == 0)
|
||||
Do28 = 1;
|
||||
else if (strcmp(argv[1], "t29") == 0)
|
||||
Do29 = 1;
|
||||
else if (strcmp(argv[1], "t30") == 0)
|
||||
Do30 = 1;
|
||||
else if (strcmp(argv[1], "t31") == 0)
|
||||
Do31 = 1;
|
||||
else if (strcmp(argv[1], "t32") == 0)
|
||||
Do32 = 1;
|
||||
else if (strcmp(argv[1], "t33") == 0)
|
||||
Do33 = 1;
|
||||
else if (strcmp(argv[1], "t34") == 0)
|
||||
Do34 = 1;
|
||||
else if (strcmp(argv[1], "t35") == 0)
|
||||
Do35 = 1;
|
||||
else if (strcmp(argv[1], "t36") == 0)
|
||||
Do35 = 1;
|
||||
}
|
||||
|
||||
PopulateIndexTest pit(DistributedEngineComm::instance());
|
||||
@ -508,13 +542,15 @@ int main( int argc, char** argv)
|
||||
}
|
||||
else if (Do24)
|
||||
{
|
||||
std::string sql("CREATE INDEX multi_cust_idx ON tpch.customer (c_name, c_address, c_phone, c_mktsegment)");
|
||||
std::string sql(
|
||||
"CREATE INDEX multi_cust_idx ON tpch.customer (c_name, c_address, c_phone, c_mktsegment)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test: " << sql << endl;
|
||||
}
|
||||
else if (Do25)
|
||||
{
|
||||
std::string sql("CREATE INDEX multi_part_no_idx ON tpch.part (p_name, p_mfgr, p_brand, p_container, p_size)");
|
||||
std::string sql(
|
||||
"CREATE INDEX multi_part_no_idx ON tpch.part (p_name, p_mfgr, p_brand, p_container, p_size)");
|
||||
pit.test_createindextest(sql);
|
||||
cout << "Finished add table index test: " << sql << endl;
|
||||
}
|
||||
@ -537,7 +573,6 @@ int main( int argc, char** argv)
|
||||
std::string sqlbuf = "ALTER TABLE tpch.tablea add CONSTRAINT tablea_cstr1 unique(c2);";
|
||||
pit.test_altertable_addtableconstraint(sqlbuf);
|
||||
cout << "Finished add table constraint test" << endl;
|
||||
|
||||
}
|
||||
else if (Do29)
|
||||
{
|
||||
@ -600,7 +635,4 @@ int main( int argc, char** argv)
|
||||
}
|
||||
|
||||
cout << "Create index test took :" << theTimer.elapsed() << " seconds to complete." << endl;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -34,8 +34,8 @@ using namespace WriteEngine;
|
||||
|
||||
namespace ddlpackageprocessor
|
||||
{
|
||||
|
||||
RestorePartitionProcessor::DDLResult RestorePartitionProcessor::processPackage(ddlpackage::RestorePartitionStatement& restorePartitionStmt)
|
||||
RestorePartitionProcessor::DDLResult RestorePartitionProcessor::processPackage(
|
||||
ddlpackage::RestorePartitionStatement& restorePartitionStmt)
|
||||
{
|
||||
SUMMARY_INFO("RestorePartitionProcessor::processPackage");
|
||||
|
||||
@ -79,7 +79,8 @@ RestorePartitionProcessor::DDLResult RestorePartitionProcessor::processPackage(d
|
||||
try
|
||||
{
|
||||
// check table lock
|
||||
boost::shared_ptr<CalpontSystemCatalog> systemCatalogPtr = CalpontSystemCatalog::makeCalpontSystemCatalog(restorePartitionStmt.fSessionID);
|
||||
boost::shared_ptr<CalpontSystemCatalog> systemCatalogPtr =
|
||||
CalpontSystemCatalog::makeCalpontSystemCatalog(restorePartitionStmt.fSessionID);
|
||||
systemCatalogPtr->identity(CalpontSystemCatalog::EC);
|
||||
systemCatalogPtr->sessionID(restorePartitionStmt.fSessionID);
|
||||
CalpontSystemCatalog::TableName tableName;
|
||||
@ -106,7 +107,8 @@ RestorePartitionProcessor::DDLResult RestorePartitionProcessor::processPackage(d
|
||||
|
||||
try
|
||||
{
|
||||
uniqueID = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, (int32_t*)&sessionID, (int32_t*)&txnID.id, BRM::LOADING );
|
||||
uniqueID = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, (int32_t*)&sessionID,
|
||||
(int32_t*)&txnID.id, BRM::LOADING);
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
@ -139,8 +141,7 @@ RestorePartitionProcessor::DDLResult RestorePartitionProcessor::processPackage(d
|
||||
{
|
||||
abs_ts.tv_sec = rm_ts.tv_sec;
|
||||
abs_ts.tv_nsec = rm_ts.tv_nsec;
|
||||
}
|
||||
while (nanosleep(&abs_ts, &rm_ts) < 0);
|
||||
} while (nanosleep(&abs_ts, &rm_ts) < 0);
|
||||
|
||||
#endif
|
||||
// reset
|
||||
@ -152,7 +153,8 @@ RestorePartitionProcessor::DDLResult RestorePartitionProcessor::processPackage(d
|
||||
|
||||
try
|
||||
{
|
||||
uniqueID = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, (int32_t*)&sessionID, (int32_t*)&txnID.id, BRM::LOADING );
|
||||
uniqueID = fDbrm->getTableLock(pms, roPair.objnum, &processName, &processID, (int32_t*)&sessionID,
|
||||
(int32_t*)&txnID.id, BRM::LOADING);
|
||||
}
|
||||
catch (std::exception&)
|
||||
{
|
||||
@ -276,7 +278,8 @@ RestorePartitionProcessor::DDLResult RestorePartitionProcessor::processPackage(d
|
||||
}
|
||||
|
||||
// Log the DDL statement
|
||||
logging::logDDL(restorePartitionStmt.fSessionID, txnID.id, restorePartitionStmt.fSql, restorePartitionStmt.fOwner);
|
||||
logging::logDDL(restorePartitionStmt.fSessionID, txnID.id, restorePartitionStmt.fSql,
|
||||
restorePartitionStmt.fOwner);
|
||||
|
||||
try
|
||||
{
|
||||
@ -293,4 +296,4 @@ RestorePartitionProcessor::DDLResult RestorePartitionProcessor::processPackage(d
|
||||
fSessionManager.committed(txnID);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
} // namespace ddlpackageprocessor
|
||||
|
@ -40,7 +40,9 @@ namespace ddlpackageprocessor
|
||||
class RestorePartitionProcessor : public DDLPackageProcessor
|
||||
{
|
||||
public:
|
||||
RestorePartitionProcessor(BRM::DBRM* aDbrm) : DDLPackageProcessor(aDbrm) {}
|
||||
RestorePartitionProcessor(BRM::DBRM* aDbrm) : DDLPackageProcessor(aDbrm)
|
||||
{
|
||||
}
|
||||
/** @brief process a drop table statement
|
||||
*
|
||||
* @param dropTableStmt the drop table statement
|
||||
@ -48,11 +50,8 @@ public:
|
||||
EXPORT DDLResult processPackage(ddlpackage::RestorePartitionStatement& RestorePartitionStmt);
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
} // namespace ddlpackageprocessor
|
||||
|
||||
#undef EXPORT
|
||||
|
||||
|
@ -401,7 +401,6 @@ public:
|
||||
for (int i = 1001; i <= 1057; i++)
|
||||
colOp.deleteFile(i);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
void destroySemaphores()
|
||||
@ -421,8 +420,6 @@ void destroySemaphores()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void destroyShmseg()
|
||||
{
|
||||
key_t shmkey;
|
||||
@ -486,10 +483,9 @@ class DDLPackageProcessorTest : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST( test_droptable ); */
|
||||
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
private:
|
||||
|
||||
public:
|
||||
|
||||
/*
|
||||
* destroySemaphores() and destroyShmseg() will print error messages
|
||||
* if there are no objects to destroy. That's OK.
|
||||
@ -497,7 +493,8 @@ public:
|
||||
void test_createtable_region()
|
||||
{
|
||||
cout << "Begining create region table testing..." << endl;
|
||||
std::string sqlbuf = "create table region( r_regionkey integer NOT NULL, r_name char(25) ,r_comment varchar(152));";
|
||||
std::string sqlbuf =
|
||||
"create table region( r_regionkey integer NOT NULL, r_name char(25) ,r_comment varchar(152));";
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
@ -532,7 +529,11 @@ public:
|
||||
// removeSystemCatalog();
|
||||
// createSystemCatalog();
|
||||
cout << "Begining create table testing..." << endl;
|
||||
std::string sqlbuf = "create table tpch.part( p_partkey integer NOT NULL ,p_name varchar(55) default 'helloworld', p_mfgr char(6), p_brand char(10) , p_type varchar(25) default 'foobar' , p_size integer , p_container char(10) ,p_retailprice integer , p_comment varchar(23), CONSTRAINT PK_PART PRIMARY KEY(p_partkey) )";
|
||||
std::string sqlbuf =
|
||||
"create table tpch.part( p_partkey integer NOT NULL ,p_name varchar(55) default 'helloworld', p_mfgr "
|
||||
"char(6), p_brand char(10) , p_type varchar(25) default 'foobar' , p_size integer , p_container "
|
||||
"char(10) ,p_retailprice integer , p_comment varchar(23), CONSTRAINT PK_PART PRIMARY KEY(p_partkey) "
|
||||
")";
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
|
||||
@ -797,7 +798,8 @@ public:
|
||||
void test_altertable_addcolumns()
|
||||
{
|
||||
cout << "Begining Alter Table add columns test ..." << endl;
|
||||
std::string sqlbuf = "ALTER TABLE test ADD COLUMN c3 char(50), ADD COLUMN c4 char(10), ADD COLUMN C5 int;";
|
||||
std::string sqlbuf =
|
||||
"ALTER TABLE test ADD COLUMN c3 char(50), ADD COLUMN c4 char(10), ADD COLUMN C5 int;";
|
||||
|
||||
SqlParser parser;
|
||||
parser.Parse(sqlbuf.c_str());
|
||||
@ -891,7 +893,6 @@ public:
|
||||
tearDown();
|
||||
}
|
||||
|
||||
|
||||
void test_altertable_renamecolumnwithcons()
|
||||
{
|
||||
cout << "Begining Alter Table rename a column with constraints ..." << endl;
|
||||
@ -1120,7 +1121,6 @@ public:
|
||||
|
||||
tearDown();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(DDLPackageProcessorTest);
|
||||
|
@ -46,8 +46,8 @@ namespace dmlpackage
|
||||
{
|
||||
boost::mutex CalpontDMLFactory::fParserLock;
|
||||
|
||||
dmlpackage::CalpontDMLPackage* CalpontDMLFactory::makeCalpontDMLPackage(dmlpackage::VendorDMLStatement& vpackage,
|
||||
std::string defaultSchema /*= ""*/)
|
||||
dmlpackage::CalpontDMLPackage* CalpontDMLFactory::makeCalpontDMLPackage(
|
||||
dmlpackage::VendorDMLStatement& vpackage, std::string defaultSchema /*= ""*/)
|
||||
{
|
||||
CalpontDMLPackage* packagePtr = 0;
|
||||
|
||||
@ -67,7 +67,6 @@ dmlpackage::CalpontDMLPackage* CalpontDMLFactory::makeCalpontDMLPackage(dmlpacka
|
||||
|
||||
if (parser.good())
|
||||
{
|
||||
|
||||
const ParseTree& ptree = parser.getParseTree();
|
||||
SqlStatement* statementPtr = ptree[0];
|
||||
|
||||
@ -101,12 +100,8 @@ dmlpackage::CalpontDMLPackage* CalpontDMLFactory::makeCalpontDMLPackage(dmlpacka
|
||||
(void)packagePtr->buildFromSqlStatement(*statementPtr);
|
||||
break;
|
||||
|
||||
default:
|
||||
cerr << "makeCalpontDMLPackage: invalid statement type" << endl;
|
||||
break;
|
||||
|
||||
default: cerr << "makeCalpontDMLPackage: invalid statement type" << endl; break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
catch (std::exception& ex)
|
||||
@ -119,10 +114,10 @@ dmlpackage::CalpontDMLPackage* CalpontDMLFactory::makeCalpontDMLPackage(dmlpacka
|
||||
}
|
||||
|
||||
return packagePtr;
|
||||
|
||||
}
|
||||
|
||||
dmlpackage::CalpontDMLPackage* CalpontDMLFactory::makeCalpontDMLPackageFromBuffer(dmlpackage::VendorDMLStatement& vpackage)
|
||||
dmlpackage::CalpontDMLPackage* CalpontDMLFactory::makeCalpontDMLPackageFromBuffer(
|
||||
dmlpackage::VendorDMLStatement& vpackage)
|
||||
{
|
||||
CalpontDMLPackage* packagePtr = 0;
|
||||
|
||||
@ -133,23 +128,24 @@ dmlpackage::CalpontDMLPackage* CalpontDMLFactory::makeCalpontDMLPackageFromBuffe
|
||||
switch (dmlStatementType)
|
||||
{
|
||||
case DML_INSERT:
|
||||
packagePtr = new InsertDMLPackage(vpackage.get_SchemaName(), vpackage.get_TableName(), vpackage.get_DMLStatement(), vpackage.get_SessionID());
|
||||
(void)packagePtr->buildFromBuffer(vpackage.get_DataBuffer
|
||||
(), vpackage.get_Columns(), vpackage.get_Rows());
|
||||
packagePtr = new InsertDMLPackage(vpackage.get_SchemaName(), vpackage.get_TableName(),
|
||||
vpackage.get_DMLStatement(), vpackage.get_SessionID());
|
||||
(void)packagePtr->buildFromBuffer(vpackage.get_DataBuffer(), vpackage.get_Columns(),
|
||||
vpackage.get_Rows());
|
||||
break;
|
||||
|
||||
case DML_UPDATE:
|
||||
packagePtr = new UpdateDMLPackage(vpackage.get_SchemaName(),
|
||||
vpackage.get_TableName(), vpackage.get_DMLStatement(), vpackage.get_SessionID());
|
||||
(void)packagePtr->buildFromBuffer(vpackage.get_DataBuffer
|
||||
(), vpackage.get_Columns(), vpackage.get_Rows());
|
||||
packagePtr = new UpdateDMLPackage(vpackage.get_SchemaName(), vpackage.get_TableName(),
|
||||
vpackage.get_DMLStatement(), vpackage.get_SessionID());
|
||||
(void)packagePtr->buildFromBuffer(vpackage.get_DataBuffer(), vpackage.get_Columns(),
|
||||
vpackage.get_Rows());
|
||||
break;
|
||||
|
||||
case DML_DELETE:
|
||||
packagePtr = new DeleteDMLPackage(vpackage.get_SchemaName(),
|
||||
vpackage.get_TableName(), vpackage.get_DMLStatement(), vpackage.get_SessionID());
|
||||
(void)packagePtr->buildFromBuffer(vpackage.get_DataBuffer
|
||||
(), vpackage.get_Columns(), vpackage.get_Rows());
|
||||
packagePtr = new DeleteDMLPackage(vpackage.get_SchemaName(), vpackage.get_TableName(),
|
||||
vpackage.get_DMLStatement(), vpackage.get_SessionID());
|
||||
(void)packagePtr->buildFromBuffer(vpackage.get_DataBuffer(), vpackage.get_Columns(),
|
||||
vpackage.get_Rows());
|
||||
break;
|
||||
|
||||
case DML_COMMAND:
|
||||
@ -157,9 +153,7 @@ dmlpackage::CalpontDMLPackage* CalpontDMLFactory::makeCalpontDMLPackageFromBuffe
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
cerr << "makeCalpontDMLPackage: invalid statement type" << endl;
|
||||
break;
|
||||
default: cerr << "makeCalpontDMLPackage: invalid statement type" << endl; break;
|
||||
}
|
||||
}
|
||||
catch (std::exception& ex)
|
||||
@ -174,7 +168,8 @@ dmlpackage::CalpontDMLPackage* CalpontDMLFactory::makeCalpontDMLPackageFromBuffe
|
||||
return packagePtr;
|
||||
}
|
||||
|
||||
dmlpackage::CalpontDMLPackage* CalpontDMLFactory::makeCalpontDMLPackageFromMysqlBuffer(dmlpackage::VendorDMLStatement& vpackage)
|
||||
dmlpackage::CalpontDMLPackage* CalpontDMLFactory::makeCalpontDMLPackageFromMysqlBuffer(
|
||||
dmlpackage::VendorDMLStatement& vpackage)
|
||||
{
|
||||
CalpontDMLPackage* packagePtr = 0;
|
||||
|
||||
@ -185,8 +180,11 @@ dmlpackage::CalpontDMLPackage* CalpontDMLFactory::makeCalpontDMLPackageFromMysql
|
||||
switch (dmlStatementType)
|
||||
{
|
||||
case DML_INSERT:
|
||||
packagePtr = new InsertDMLPackage(vpackage.get_SchemaName(), vpackage.get_TableName(), vpackage.get_DMLStatement(), vpackage.get_SessionID());
|
||||
(void)packagePtr->buildFromMysqlBuffer(vpackage.get_ColNames(), vpackage.get_values(), vpackage.get_Columns(), vpackage.get_Rows(), vpackage.get_nullValues());
|
||||
packagePtr = new InsertDMLPackage(vpackage.get_SchemaName(), vpackage.get_TableName(),
|
||||
vpackage.get_DMLStatement(), vpackage.get_SessionID());
|
||||
(void)packagePtr->buildFromMysqlBuffer(vpackage.get_ColNames(), vpackage.get_values(),
|
||||
vpackage.get_Columns(), vpackage.get_Rows(),
|
||||
vpackage.get_nullValues());
|
||||
break;
|
||||
|
||||
case DML_COMMAND:
|
||||
@ -196,12 +194,12 @@ dmlpackage::CalpontDMLPackage* CalpontDMLFactory::makeCalpontDMLPackageFromMysql
|
||||
case DML_DELETE:
|
||||
packagePtr = new DeleteDMLPackage(vpackage.get_SchemaName(), vpackage.get_TableName(),
|
||||
vpackage.get_DMLStatement(), vpackage.get_SessionID());
|
||||
(void)packagePtr->buildFromMysqlBuffer(vpackage.get_ColNames(), vpackage.get_values(), vpackage.get_Columns(), vpackage.get_Rows(), vpackage.get_nullValues());
|
||||
(void)packagePtr->buildFromMysqlBuffer(vpackage.get_ColNames(), vpackage.get_values(),
|
||||
vpackage.get_Columns(), vpackage.get_Rows(),
|
||||
vpackage.get_nullValues());
|
||||
break;
|
||||
|
||||
default:
|
||||
cerr << "makeCalpontDMLPackage: invalid statement type" << endl;
|
||||
break;
|
||||
default: cerr << "makeCalpontDMLPackage: invalid statement type" << endl; break;
|
||||
}
|
||||
}
|
||||
catch (std::exception& ex)
|
||||
@ -216,9 +214,11 @@ dmlpackage::CalpontDMLPackage* CalpontDMLFactory::makeCalpontDMLPackageFromMysql
|
||||
return packagePtr;
|
||||
}
|
||||
|
||||
dmlpackage::CalpontDMLPackage* CalpontDMLFactory::makeCalpontUpdatePackageFromMysqlBuffer(dmlpackage::VendorDMLStatement& vpackage, dmlpackage::UpdateSqlStatement& updateStmt)
|
||||
dmlpackage::CalpontDMLPackage* CalpontDMLFactory::makeCalpontUpdatePackageFromMysqlBuffer(
|
||||
dmlpackage::VendorDMLStatement& vpackage, dmlpackage::UpdateSqlStatement& updateStmt)
|
||||
{
|
||||
CalpontDMLPackage* packagePtr = new UpdateDMLPackage((updateStmt.fNamePtr)->fSchema, (updateStmt.fNamePtr)->fName,
|
||||
CalpontDMLPackage* packagePtr =
|
||||
new UpdateDMLPackage((updateStmt.fNamePtr)->fSchema, (updateStmt.fNamePtr)->fName,
|
||||
vpackage.get_DMLStatement(), vpackage.get_SessionID());
|
||||
UpdateDMLPackage* updatePkgPtr = dynamic_cast<UpdateDMLPackage*>(packagePtr);
|
||||
updatePkgPtr->buildUpdateFromMysqlBuffer(updateStmt);
|
||||
|
@ -35,7 +35,6 @@
|
||||
#endif
|
||||
namespace dmlpackage
|
||||
{
|
||||
|
||||
class CalpontDMLFactory
|
||||
{
|
||||
/** @brief a concrete implementation responsible for creating
|
||||
@ -43,7 +42,6 @@ class CalpontDMLFactory
|
||||
* given a VendorDMLStatement.
|
||||
*/
|
||||
public:
|
||||
|
||||
/** @brief factory method
|
||||
*
|
||||
* @param vpackage the VendorDMLStatement
|
||||
@ -56,18 +54,19 @@ public:
|
||||
*
|
||||
* @param vpackage the VendorDMLStatement
|
||||
*/
|
||||
EXPORT static dmlpackage::CalpontDMLPackage* makeCalpontDMLPackageFromBuffer(dmlpackage::VendorDMLStatement& vpackage);
|
||||
EXPORT static dmlpackage::CalpontDMLPackage* makeCalpontDMLPackageFromBuffer(
|
||||
dmlpackage::VendorDMLStatement& vpackage);
|
||||
|
||||
EXPORT static dmlpackage::CalpontDMLPackage* makeCalpontDMLPackageFromMysqlBuffer(dmlpackage::VendorDMLStatement& vpackage);
|
||||
static dmlpackage::CalpontDMLPackage* makeCalpontUpdatePackageFromMysqlBuffer(dmlpackage::VendorDMLStatement& vpackage, dmlpackage::UpdateSqlStatement& updateStmt);
|
||||
EXPORT static dmlpackage::CalpontDMLPackage* makeCalpontDMLPackageFromMysqlBuffer(
|
||||
dmlpackage::VendorDMLStatement& vpackage);
|
||||
static dmlpackage::CalpontDMLPackage* makeCalpontUpdatePackageFromMysqlBuffer(
|
||||
dmlpackage::VendorDMLStatement& vpackage, dmlpackage::UpdateSqlStatement& updateStmt);
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
static boost::mutex fParserLock;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace dmlpackage
|
||||
|
||||
#undef EXPORT
|
||||
|
||||
|
@ -31,20 +31,36 @@ namespace dmlpackage
|
||||
*/
|
||||
|
||||
CalpontDMLPackage::CalpontDMLPackage()
|
||||
: fPlan(new messageqcpp::ByteStream()),
|
||||
fTable(0), fHasFilter(0), fLogging(true), fIsInsertSelect(false),
|
||||
fIsBatchInsert(false), fIsCacheInsert(false), fIsAutocommitOn(false), fIsWarnToError(false), fTableOid(0)
|
||||
: fPlan(new messageqcpp::ByteStream())
|
||||
, fTable(0)
|
||||
, fHasFilter(0)
|
||||
, fLogging(true)
|
||||
, fIsInsertSelect(false)
|
||||
, fIsBatchInsert(false)
|
||||
, fIsCacheInsert(false)
|
||||
, fIsAutocommitOn(false)
|
||||
, fIsWarnToError(false)
|
||||
, fTableOid(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CalpontDMLPackage::CalpontDMLPackage( std::string schemaName, std::string tableName,
|
||||
std::string dmlStatement, int sessionID )
|
||||
: fSchemaName(schemaName), fTableName( tableName ), fDMLStatement( dmlStatement ),
|
||||
fSessionID(sessionID), fPlan(new messageqcpp::ByteStream()), fTable(0), fHasFilter(false), fLogging(true), fIsInsertSelect(false),
|
||||
fIsBatchInsert(false), fIsCacheInsert(false), fIsAutocommitOn(false), fIsWarnToError(false), fTableOid(0)
|
||||
CalpontDMLPackage::CalpontDMLPackage(std::string schemaName, std::string tableName, std::string dmlStatement,
|
||||
int sessionID)
|
||||
: fSchemaName(schemaName)
|
||||
, fTableName(tableName)
|
||||
, fDMLStatement(dmlStatement)
|
||||
, fSessionID(sessionID)
|
||||
, fPlan(new messageqcpp::ByteStream())
|
||||
, fTable(0)
|
||||
, fHasFilter(false)
|
||||
, fLogging(true)
|
||||
, fIsInsertSelect(false)
|
||||
, fIsBatchInsert(false)
|
||||
, fIsCacheInsert(false)
|
||||
, fIsAutocommitOn(false)
|
||||
, fIsWarnToError(false)
|
||||
, fTableOid(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CalpontDMLPackage::~CalpontDMLPackage()
|
||||
|
@ -40,7 +40,6 @@ namespace dmlpackage
|
||||
*/
|
||||
class CalpontDMLPackage
|
||||
{
|
||||
|
||||
public:
|
||||
/** @brief ctor
|
||||
*/
|
||||
@ -53,8 +52,7 @@ public:
|
||||
* @param dmlStatement the dml statement
|
||||
* @param sessionID the session id
|
||||
*/
|
||||
CalpontDMLPackage( std::string schemaName, std::string tableName,
|
||||
std::string dmlStatement, int sessionID );
|
||||
CalpontDMLPackage(std::string schemaName, std::string tableName, std::string dmlStatement, int sessionID);
|
||||
|
||||
/** @brief dtor
|
||||
*/
|
||||
@ -93,7 +91,8 @@ public:
|
||||
* @param columns number of columns in the table
|
||||
* @param rows number of rows to be touched
|
||||
*/
|
||||
virtual int buildFromMysqlBuffer(ColNameList& colNameList, TableValuesMap& tableValuesMap, int columns, int rows, NullValuesBitset& nullValues) = 0;
|
||||
virtual int buildFromMysqlBuffer(ColNameList& colNameList, TableValuesMap& tableValuesMap, int columns,
|
||||
int rows, NullValuesBitset& nullValues) = 0;
|
||||
|
||||
/** @brief get the table object
|
||||
*/
|
||||
@ -365,7 +364,6 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
void initializeTable();
|
||||
|
||||
std::string fSchemaName;
|
||||
@ -392,4 +390,4 @@ protected:
|
||||
uint32_t fTableOid;
|
||||
WriteEngine::ChunkManager* fCM;
|
||||
};
|
||||
}
|
||||
} // namespace dmlpackage
|
||||
|
@ -31,16 +31,18 @@ using namespace std;
|
||||
#undef COMMANDDMLPKG_DLLEXPORT
|
||||
namespace dmlpackage
|
||||
{
|
||||
|
||||
CommandDMLPackage::CommandDMLPackage()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
CommandDMLPackage::CommandDMLPackage(std::string dmlStatement, int sessionID)
|
||||
: CalpontDMLPackage("", "", dmlStatement, sessionID)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
CommandDMLPackage::~CommandDMLPackage()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
int CommandDMLPackage::write(messageqcpp::ByteStream& bytestream)
|
||||
{
|
||||
|
@ -40,7 +40,6 @@ namespace dmlpackage
|
||||
*/
|
||||
class CommandDMLPackage : public CalpontDMLPackage
|
||||
{
|
||||
|
||||
public:
|
||||
/** @brief ctor
|
||||
*/
|
||||
@ -85,18 +84,16 @@ public:
|
||||
* @param colNameList, tableValuesMap
|
||||
* @param rows the number of rows in the buffer
|
||||
*/
|
||||
int buildFromMysqlBuffer(ColNameList& colNameList, TableValuesMap& tableValuesMap, int columns, int rows, NullValuesBitset& nullValues)
|
||||
int buildFromMysqlBuffer(ColNameList& colNameList, TableValuesMap& tableValuesMap, int columns, int rows,
|
||||
NullValuesBitset& nullValues)
|
||||
{
|
||||
return 1;
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace dmlpackage
|
||||
|
||||
#undef EXPORT
|
||||
|
||||
|
@ -32,17 +32,19 @@ using namespace std;
|
||||
|
||||
namespace dmlpackage
|
||||
{
|
||||
|
||||
DeleteDMLPackage::DeleteDMLPackage()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
DeleteDMLPackage::DeleteDMLPackage(std::string schemaName, std::string tableName,
|
||||
std::string dmlStatement, int sessionID)
|
||||
DeleteDMLPackage::DeleteDMLPackage(std::string schemaName, std::string tableName, std::string dmlStatement,
|
||||
int sessionID)
|
||||
: CalpontDMLPackage(schemaName, tableName, dmlStatement, sessionID)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
DeleteDMLPackage::~DeleteDMLPackage()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
int DeleteDMLPackage::write(messageqcpp::ByteStream& bytestream)
|
||||
{
|
||||
@ -156,7 +158,6 @@ int DeleteDMLPackage::buildFromBuffer(std::string& buffer, int columns, int rows
|
||||
for (tokenizer::iterator tok_iter = tokens.begin(); tok_iter != tokens.end(); ++tok_iter)
|
||||
{
|
||||
dataList.push_back(StripLeadingWhitespace(*tok_iter));
|
||||
|
||||
}
|
||||
|
||||
int n = 0;
|
||||
@ -194,10 +195,10 @@ int DeleteDMLPackage::buildFromBuffer(std::string& buffer, int columns, int rows
|
||||
}
|
||||
|
||||
return retval;
|
||||
|
||||
}
|
||||
|
||||
int DeleteDMLPackage::buildFromMysqlBuffer(ColNameList& colNameList, TableValuesMap& tableValuesMap, int columns, int rows, NullValuesBitset& nullValues )
|
||||
int DeleteDMLPackage::buildFromMysqlBuffer(ColNameList& colNameList, TableValuesMap& tableValuesMap,
|
||||
int columns, int rows, NullValuesBitset& nullValues)
|
||||
{
|
||||
int retval = 1;
|
||||
|
||||
|
@ -40,9 +40,7 @@ namespace dmlpackage
|
||||
*/
|
||||
class DeleteDMLPackage : public CalpontDMLPackage
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
/** @brief ctor
|
||||
*/
|
||||
EXPORT DeleteDMLPackage();
|
||||
@ -54,8 +52,8 @@ public:
|
||||
* @param dmlStatement the dml statement
|
||||
* @param sessionID the session ID
|
||||
*/
|
||||
EXPORT DeleteDMLPackage( std::string schemaName, std::string tableName,
|
||||
std::string dmlStatement, int sessionID );
|
||||
EXPORT DeleteDMLPackage(std::string schemaName, std::string tableName, std::string dmlStatement,
|
||||
int sessionID);
|
||||
|
||||
/** @brief dtor
|
||||
*/
|
||||
@ -91,14 +89,12 @@ public:
|
||||
* @param colNameList, tableValuesMap
|
||||
* @param rows the number of rows in the buffer
|
||||
*/
|
||||
EXPORT int buildFromMysqlBuffer(ColNameList& colNameList, TableValuesMap& tableValuesMap, int columns, int rows, NullValuesBitset& nullValues);
|
||||
EXPORT int buildFromMysqlBuffer(ColNameList& colNameList, TableValuesMap& tableValuesMap, int columns,
|
||||
int rows, NullValuesBitset& nullValues);
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
}
|
||||
} // namespace dmlpackage
|
||||
|
||||
#undef EXPORT
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -32,7 +32,6 @@
|
||||
This special exception was added by the Free Software Foundation in
|
||||
version 2.2 of Bison. */
|
||||
|
||||
|
||||
/* Tokens. */
|
||||
#pragma once
|
||||
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
||||
@ -130,13 +129,9 @@ enum yytokentype
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if !defined YYSTYPE && !defined YYSTYPE_IS_DECLARED
|
||||
typedef union YYSTYPE
|
||||
{
|
||||
|
||||
|
||||
int intval;
|
||||
double floatval;
|
||||
char* strval;
|
||||
@ -169,13 +164,9 @@ typedef union YYSTYPE
|
||||
dmlpackage::ColumnAssignment* colAssignment;
|
||||
dmlpackage::ColumnAssignmentList* colAssignmentList;
|
||||
|
||||
|
||||
|
||||
} YYSTYPE;
|
||||
#define YYSTYPE_IS_TRIVIAL 1
|
||||
#define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||
#define YYSTYPE_IS_DECLARED 1
|
||||
|
||||
extern YYSTYPE dmllval;
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -31,10 +31,9 @@
|
||||
|
||||
namespace dmlpackage
|
||||
{
|
||||
|
||||
|
||||
DMLColumn::DMLColumn()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
DMLColumn::DMLColumn(std::string name, std::string value, bool isFromCol, uint32_t funcScale, bool isNULL)
|
||||
{
|
||||
@ -49,10 +48,10 @@ DMLColumn::DMLColumn(std::string name, std::string value, bool isFromCol, uint32
|
||||
fisNULL = isNULL;
|
||||
fIsFromCol = isFromCol;
|
||||
fFuncScale = funcScale;
|
||||
|
||||
}
|
||||
|
||||
DMLColumn::DMLColumn(std::string name, std::vector<std::string>& valueList, bool isFromCol, uint32_t funcScale, bool isNULL)
|
||||
DMLColumn::DMLColumn(std::string name, std::vector<std::string>& valueList, bool isFromCol,
|
||||
uint32_t funcScale, bool isNULL)
|
||||
{
|
||||
fName = name;
|
||||
fColValuesList = valueList;
|
||||
@ -62,7 +61,8 @@ DMLColumn::DMLColumn(std::string name, std::vector<std::string>& valueList, bool
|
||||
}
|
||||
|
||||
DMLColumn::~DMLColumn()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
int DMLColumn::read(messageqcpp::ByteStream& bytestream)
|
||||
{
|
||||
@ -83,7 +83,6 @@ int DMLColumn::read(messageqcpp::ByteStream& bytestream)
|
||||
|
||||
fColValuesList.push_back(dataStr);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
bytestream >> fData; // deprecated.
|
||||
@ -111,7 +110,6 @@ int DMLColumn::write(messageqcpp::ByteStream& bytestream)
|
||||
{
|
||||
bytestream << fColValuesList[i];
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
bytestream << fData; // deprecated.
|
||||
|
@ -42,7 +42,6 @@ namespace dmlpackage
|
||||
*/
|
||||
class DMLColumn : public DMLObject
|
||||
{
|
||||
|
||||
public:
|
||||
/** @brief ctor
|
||||
*/
|
||||
@ -51,12 +50,14 @@ public:
|
||||
/** @brief ctor
|
||||
*/
|
||||
|
||||
EXPORT DMLColumn(std::string name, std::string value, bool isFromCol = false, uint32_t funcScale = 0, bool isNULL = false);
|
||||
EXPORT DMLColumn(std::string name, std::string value, bool isFromCol = false, uint32_t funcScale = 0,
|
||||
bool isNULL = false);
|
||||
/** @brief new ctor
|
||||
* isNUll is currently not in use. It supposed to indicate whether each value is null or not.
|
||||
*/
|
||||
|
||||
EXPORT DMLColumn(std::string name, std::vector<std::string>& valueList, bool isFromCol = false, uint32_t funcScale = 0, bool isNULL = false );
|
||||
EXPORT DMLColumn(std::string name, std::vector<std::string>& valueList, bool isFromCol = false,
|
||||
uint32_t funcScale = 0, bool isNULL = false);
|
||||
|
||||
/** @brief dtor
|
||||
*/
|
||||
@ -81,7 +82,6 @@ public:
|
||||
return fData;
|
||||
}
|
||||
|
||||
|
||||
const std::vector<std::string>& get_DataVector() const
|
||||
{
|
||||
return fColValuesList;
|
||||
@ -147,7 +147,6 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
std::string fName;
|
||||
std::string fData;
|
||||
@ -155,15 +154,12 @@ private:
|
||||
bool fisNULL;
|
||||
bool fIsFromCol;
|
||||
uint32_t fFuncScale;
|
||||
|
||||
};
|
||||
|
||||
/** @brief a vector of DMLColumns
|
||||
*/
|
||||
typedef std::vector<DMLColumn*> ColumnList;
|
||||
|
||||
}
|
||||
} // namespace dmlpackage
|
||||
|
||||
#undef EXPORT
|
||||
|
||||
|
||||
|
@ -25,15 +25,11 @@
|
||||
|
||||
namespace dmlpackage
|
||||
{
|
||||
|
||||
DMLObject::DMLObject()
|
||||
{
|
||||
|
||||
}
|
||||
DMLObject::~DMLObject()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
} // namespace dmlpackage
|
||||
|
||||
|
@ -22,12 +22,10 @@
|
||||
***********************************************************************/
|
||||
/** @file */
|
||||
|
||||
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include "bytestream.h"
|
||||
|
||||
|
||||
namespace dmlpackage
|
||||
{
|
||||
/** @brief an abstract class that represents
|
||||
@ -36,9 +34,7 @@ namespace dmlpackage
|
||||
*/
|
||||
class DMLObject
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
/** @brief ctor
|
||||
*/
|
||||
DMLObject();
|
||||
@ -60,11 +56,7 @@ public:
|
||||
virtual int write(messageqcpp::ByteStream& bytestream) = 0;
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
} // namespace dmlpackage
|
||||
|
@ -27,7 +27,6 @@
|
||||
|
||||
namespace dmlpackage
|
||||
{
|
||||
|
||||
#define DML_DEBUG 0 // debug flag 0 for off, 1 for on
|
||||
|
||||
const std::string nullValue = "nvl";
|
||||
|
@ -54,9 +54,9 @@ valbuf_t get_valbuffer(void);
|
||||
void free_copybuffer();
|
||||
void set_defaultSchema(std::string schema);
|
||||
|
||||
DMLParser::DMLParser() :
|
||||
fStatus(-1), fDebug(false)
|
||||
{}
|
||||
DMLParser::DMLParser() : fStatus(-1), fDebug(false)
|
||||
{
|
||||
}
|
||||
|
||||
DMLParser::~DMLParser()
|
||||
{
|
||||
@ -107,7 +107,6 @@ const ParseTree& DMLParser::getParseTree()
|
||||
}
|
||||
|
||||
return fParseTree;
|
||||
|
||||
}
|
||||
|
||||
bool DMLParser::good()
|
||||
@ -120,9 +119,9 @@ void DMLParser::setDefaultSchema(std::string schema)
|
||||
set_defaultSchema(schema);
|
||||
}
|
||||
|
||||
DMLFileParser::DMLFileParser()
|
||||
: DMLParser()
|
||||
{}
|
||||
DMLFileParser::DMLFileParser() : DMLParser()
|
||||
{
|
||||
}
|
||||
|
||||
int DMLFileParser::parse(const string& fileName)
|
||||
{
|
||||
@ -165,7 +164,6 @@ int DMLFileParser::parse(const string& fileName)
|
||||
|
||||
void end_sql(void)
|
||||
{
|
||||
|
||||
} /* end_sql */
|
||||
|
||||
} // dmlpackage
|
||||
} // namespace dmlpackage
|
||||
|
@ -32,7 +32,6 @@ namespace dmlpackage
|
||||
{
|
||||
typedef std::vector<char*> valbuf_t;
|
||||
|
||||
|
||||
typedef SqlStatementList ParseTree;
|
||||
|
||||
// instance data for the parser
|
||||
@ -88,7 +87,6 @@ protected:
|
||||
scan_data scanData;
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
/** @brief specialization of the DMLParser class
|
||||
@ -111,8 +109,7 @@ public:
|
||||
int parse(const std::string& fileName);
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace dmlpackage
|
||||
|
@ -58,10 +58,8 @@ SqlStatementList::~SqlStatementList()
|
||||
|
||||
/** SqlStatement
|
||||
*/
|
||||
SqlStatement::SqlStatement()
|
||||
: fNamePtr(0)
|
||||
SqlStatement::SqlStatement() : fNamePtr(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
SqlStatement::~SqlStatement()
|
||||
@ -97,10 +95,8 @@ std::string SqlStatement::getTableName() const
|
||||
|
||||
/** InsertSqlStatement
|
||||
*/
|
||||
InsertSqlStatement::InsertSqlStatement()
|
||||
: fValuesOrQueryPtr(0)
|
||||
InsertSqlStatement::InsertSqlStatement() : fValuesOrQueryPtr(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
InsertSqlStatement::InsertSqlStatement(TableName* tableNamePtr, ValuesOrQuery* valsOrQueryPtr)
|
||||
@ -143,7 +139,6 @@ ostream& InsertSqlStatement::put(ostream& os) const
|
||||
if (0 != fValuesOrQueryPtr)
|
||||
{
|
||||
fValuesOrQueryPtr->put(os);
|
||||
|
||||
}
|
||||
|
||||
return os;
|
||||
@ -163,16 +158,13 @@ string InsertSqlStatement::getQueryString() const
|
||||
|
||||
/** UpdateSqlStatement
|
||||
*/
|
||||
UpdateSqlStatement::UpdateSqlStatement()
|
||||
: fColAssignmentListPtr(0), fWhereClausePtr(0)
|
||||
UpdateSqlStatement::UpdateSqlStatement() : fColAssignmentListPtr(0), fWhereClausePtr(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
UpdateSqlStatement::UpdateSqlStatement(TableName* tableNamePtr,
|
||||
ColumnAssignmentList* colAssignmentListPtr, WhereClause* whereClausePtr /*=0*/)
|
||||
: fColAssignmentListPtr(colAssignmentListPtr),
|
||||
fWhereClausePtr(whereClausePtr)
|
||||
UpdateSqlStatement::UpdateSqlStatement(TableName* tableNamePtr, ColumnAssignmentList* colAssignmentListPtr,
|
||||
WhereClause* whereClausePtr /*=0*/)
|
||||
: fColAssignmentListPtr(colAssignmentListPtr), fWhereClausePtr(whereClausePtr)
|
||||
{
|
||||
fNamePtr = tableNamePtr;
|
||||
}
|
||||
@ -261,17 +253,14 @@ string UpdateSqlStatement::getQueryString() const
|
||||
|
||||
/** DeleteSqlStatement
|
||||
*/
|
||||
DeleteSqlStatement::DeleteSqlStatement()
|
||||
: fWhereClausePtr(0)
|
||||
DeleteSqlStatement::DeleteSqlStatement() : fWhereClausePtr(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
DeleteSqlStatement::DeleteSqlStatement(TableName* tableNamePtr, WhereClause* whereClausePtr /*=0*/)
|
||||
: fWhereClausePtr(whereClausePtr)
|
||||
{
|
||||
fNamePtr = tableNamePtr;
|
||||
|
||||
}
|
||||
|
||||
DeleteSqlStatement::~DeleteSqlStatement()
|
||||
@ -280,7 +269,6 @@ DeleteSqlStatement::~DeleteSqlStatement()
|
||||
{
|
||||
delete fWhereClausePtr;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ostream& DeleteSqlStatement::put(ostream& os) const
|
||||
@ -314,10 +302,8 @@ string DeleteSqlStatement::getQueryString() const
|
||||
|
||||
/** CommandSqlStatement
|
||||
*/
|
||||
CommandSqlStatement::CommandSqlStatement(std::string command)
|
||||
: fCommandText(command)
|
||||
CommandSqlStatement::CommandSqlStatement(std::string command) : fCommandText(command)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ostream& CommandSqlStatement::put(ostream& os) const
|
||||
@ -336,13 +322,11 @@ string CommandSqlStatement::getQueryString() const
|
||||
*/
|
||||
TableName::TableName()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
TableName::TableName(char* name)
|
||||
{
|
||||
fName = name;
|
||||
|
||||
}
|
||||
|
||||
TableName::TableName(char* schema, char* name)
|
||||
@ -383,13 +367,11 @@ string ColumnAssignment::getColumnAssignmentString() const
|
||||
|
||||
/** ValuesOrQuery
|
||||
*/
|
||||
ValuesOrQuery::ValuesOrQuery()
|
||||
: fQuerySpecPtr(0)
|
||||
ValuesOrQuery::ValuesOrQuery() : fQuerySpecPtr(0)
|
||||
{
|
||||
}
|
||||
|
||||
ValuesOrQuery::ValuesOrQuery(ValuesList* valuesPtr)
|
||||
: fQuerySpecPtr(0)
|
||||
ValuesOrQuery::ValuesOrQuery(ValuesList* valuesPtr) : fQuerySpecPtr(0)
|
||||
{
|
||||
fValuesList = *valuesPtr;
|
||||
delete valuesPtr;
|
||||
@ -438,19 +420,16 @@ string ValuesOrQuery::getQueryString() const
|
||||
|
||||
/** QuerySpec
|
||||
*/
|
||||
QuerySpec::QuerySpec()
|
||||
: fSelectFilterPtr(0), fTableExpressionPtr(0)
|
||||
QuerySpec::QuerySpec() : fSelectFilterPtr(0), fTableExpressionPtr(0)
|
||||
{
|
||||
}
|
||||
|
||||
QuerySpec::QuerySpec(SelectFilter* selectFilter, TableExpression* tableExpression)
|
||||
: fSelectFilterPtr(selectFilter), fTableExpressionPtr(tableExpression)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QuerySpec::QuerySpec(SelectFilter* selectFilter, TableExpression* tableExpression,
|
||||
char* allOrDistinct)
|
||||
QuerySpec::QuerySpec(SelectFilter* selectFilter, TableExpression* tableExpression, char* allOrDistinct)
|
||||
: fSelectFilterPtr(selectFilter), fTableExpressionPtr(tableExpression)
|
||||
{
|
||||
fOptionAllOrDistinct = allOrDistinct;
|
||||
@ -511,8 +490,7 @@ string QuerySpec::getQueryString() const
|
||||
|
||||
/** SelectFilter
|
||||
*/
|
||||
SelectFilter::SelectFilter()
|
||||
: fColumnList(0)
|
||||
SelectFilter::SelectFilter() : fColumnList(0)
|
||||
{
|
||||
}
|
||||
|
||||
@ -525,7 +503,6 @@ SelectFilter::SelectFilter(ColumnNameList* columnListPtr)
|
||||
|
||||
SelectFilter::~SelectFilter()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ostream& SelectFilter::put(ostream& os) const
|
||||
@ -567,19 +544,17 @@ string SelectFilter::getSelectString() const
|
||||
|
||||
/** TableExpression
|
||||
*/
|
||||
TableExpression::TableExpression()
|
||||
: fFromClausePtr(0), fWhereClausePtr(0),
|
||||
fGroupByPtr(0), fHavingPtr(0)
|
||||
TableExpression::TableExpression() : fFromClausePtr(0), fWhereClausePtr(0), fGroupByPtr(0), fHavingPtr(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
TableExpression::TableExpression(FromClause* fromClausePtr, WhereClause* whereClausePtr,
|
||||
GroupByClause* groupByPtr, HavingClause* havingPtr)
|
||||
: fFromClausePtr(fromClausePtr), fWhereClausePtr(whereClausePtr),
|
||||
fGroupByPtr(groupByPtr), fHavingPtr(havingPtr)
|
||||
: fFromClausePtr(fromClausePtr)
|
||||
, fWhereClausePtr(whereClausePtr)
|
||||
, fGroupByPtr(groupByPtr)
|
||||
, fHavingPtr(havingPtr)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
TableExpression::~TableExpression()
|
||||
@ -595,7 +570,6 @@ TableExpression::~TableExpression()
|
||||
|
||||
if (0 != fHavingPtr)
|
||||
delete fHavingPtr;
|
||||
|
||||
}
|
||||
|
||||
ostream& TableExpression::put(ostream& os) const
|
||||
@ -655,8 +629,7 @@ string TableExpression::getTableExpressionString() const
|
||||
|
||||
/** FromClause
|
||||
*/
|
||||
FromClause::FromClause()
|
||||
: fTableListPtr(0)
|
||||
FromClause::FromClause() : fTableListPtr(0)
|
||||
{
|
||||
}
|
||||
|
||||
@ -734,10 +707,8 @@ string FromClause::getFromClauseString() const
|
||||
|
||||
/** WhereClause
|
||||
*/
|
||||
WhereClause::WhereClause()
|
||||
: fSearchConditionPtr(0)
|
||||
WhereClause::WhereClause() : fSearchConditionPtr(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
WhereClause::~WhereClause()
|
||||
@ -775,8 +746,7 @@ string WhereClause::getWhereClauseString() const
|
||||
|
||||
/** HavingClause
|
||||
*/
|
||||
HavingClause::HavingClause()
|
||||
: fSearchConditionPtr(0)
|
||||
HavingClause::HavingClause() : fSearchConditionPtr(0)
|
||||
{
|
||||
}
|
||||
|
||||
@ -815,8 +785,7 @@ string HavingClause::getHavingClauseString() const
|
||||
|
||||
/** GroupByClause
|
||||
*/
|
||||
GroupByClause::GroupByClause()
|
||||
: fColumnNamesListPtr(0)
|
||||
GroupByClause::GroupByClause() : fColumnNamesListPtr(0)
|
||||
{
|
||||
}
|
||||
|
||||
@ -880,9 +849,7 @@ ostream& Escape::put(ostream& os) const
|
||||
|
||||
/** SearchCondition
|
||||
*/
|
||||
SearchCondition::SearchCondition()
|
||||
: fPredicatePtr(0), fLHSearchConditionPtr(0),
|
||||
fRHSearchConditionPtr(0)
|
||||
SearchCondition::SearchCondition() : fPredicatePtr(0), fLHSearchConditionPtr(0), fRHSearchConditionPtr(0)
|
||||
{
|
||||
}
|
||||
|
||||
@ -902,7 +869,6 @@ SearchCondition::~SearchCondition()
|
||||
{
|
||||
delete fRHSearchConditionPtr;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ostream& SearchCondition::put(ostream& os) const
|
||||
@ -953,8 +919,7 @@ string SearchCondition::getSearchConditionString() const
|
||||
|
||||
/** ExistanceTestPredicate
|
||||
*/
|
||||
ExistanceTestPredicate::ExistanceTestPredicate()
|
||||
: Predicate(EXIST_PREDICATE), fSubQuerySpecPtr(0)
|
||||
ExistanceTestPredicate::ExistanceTestPredicate() : Predicate(EXIST_PREDICATE), fSubQuerySpecPtr(0)
|
||||
{
|
||||
}
|
||||
|
||||
@ -996,10 +961,8 @@ string ExistanceTestPredicate::getPredicateString() const
|
||||
|
||||
/** AllOrAnyPredicate
|
||||
*/
|
||||
AllOrAnyPredicate::AllOrAnyPredicate()
|
||||
: Predicate(ALLORANY_PREDICATE), fSubQuerySpecPtr(0)
|
||||
AllOrAnyPredicate::AllOrAnyPredicate() : Predicate(ALLORANY_PREDICATE), fSubQuerySpecPtr(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
AllOrAnyPredicate::~AllOrAnyPredicate()
|
||||
@ -1042,10 +1005,8 @@ string AllOrAnyPredicate::getPredicateString() const
|
||||
|
||||
/** InPredicate
|
||||
*/
|
||||
InPredicate::InPredicate()
|
||||
: Predicate(IN_PREDICATE), fSubQuerySpecPtr(0)
|
||||
InPredicate::InPredicate() : Predicate(IN_PREDICATE), fSubQuerySpecPtr(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
InPredicate::~InPredicate()
|
||||
@ -1111,14 +1072,12 @@ string InPredicate::getPredicateString() const
|
||||
|
||||
/** NullTestPredicate
|
||||
*/
|
||||
NullTestPredicate::NullTestPredicate()
|
||||
: Predicate(NULLTEST_PREDICATE)
|
||||
NullTestPredicate::NullTestPredicate() : Predicate(NULLTEST_PREDICATE)
|
||||
{
|
||||
}
|
||||
|
||||
NullTestPredicate::~NullTestPredicate()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ostream& NullTestPredicate::put(ostream& os) const
|
||||
@ -1140,10 +1099,8 @@ string NullTestPredicate::getPredicateString() const
|
||||
|
||||
/** LikePredicate
|
||||
*/
|
||||
LikePredicate::LikePredicate()
|
||||
: Predicate(LIKE_PREDICATE), fOptionalEscapePtr(0)
|
||||
LikePredicate::LikePredicate() : Predicate(LIKE_PREDICATE), fOptionalEscapePtr(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
LikePredicate::~LikePredicate()
|
||||
@ -1180,19 +1137,16 @@ string LikePredicate::getPredicateString() const
|
||||
|
||||
/** BetweenPredicate
|
||||
*/
|
||||
BetweenPredicate::BetweenPredicate()
|
||||
: Predicate(BETWEEN_PREDICATE)
|
||||
BetweenPredicate::BetweenPredicate() : Predicate(BETWEEN_PREDICATE)
|
||||
{
|
||||
}
|
||||
|
||||
BetweenPredicate::~BetweenPredicate()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ostream& BetweenPredicate::put(ostream& os) const
|
||||
{
|
||||
|
||||
os << fLHScalarExpression << endl;
|
||||
os << fOperator1 << endl;
|
||||
os << fRH1ScalarExpression << endl;
|
||||
@ -1219,8 +1173,7 @@ string BetweenPredicate::getPredicateString() const
|
||||
|
||||
/** ComparisonPredicate
|
||||
*/
|
||||
ComparisonPredicate::ComparisonPredicate()
|
||||
: Predicate(COMPARE_PREDICATE), fSubQuerySpec(0)
|
||||
ComparisonPredicate::ComparisonPredicate() : Predicate(COMPARE_PREDICATE), fSubQuerySpec(0)
|
||||
{
|
||||
}
|
||||
|
||||
@ -1261,20 +1214,16 @@ string ComparisonPredicate::getPredicateString() const
|
||||
|
||||
/** Predicate
|
||||
*/
|
||||
Predicate::Predicate()
|
||||
: fPredicateType(INVALID_PREDICATE)
|
||||
Predicate::Predicate() : fPredicateType(INVALID_PREDICATE)
|
||||
{
|
||||
}
|
||||
|
||||
Predicate::Predicate(PREDICATE_TYPE predicateType)
|
||||
: fPredicateType(predicateType)
|
||||
Predicate::Predicate(PREDICATE_TYPE predicateType) : fPredicateType(predicateType)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Predicate::~Predicate()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ostream& Predicate::put(ostream& os) const
|
||||
|
@ -33,7 +33,6 @@
|
||||
|
||||
namespace dmlpackage
|
||||
{
|
||||
|
||||
class DeleteSqlStatement;
|
||||
class UpdateSqlStatement;
|
||||
class InsertSqlStatement;
|
||||
@ -144,7 +143,6 @@ public:
|
||||
virtual std::string getTableName() const;
|
||||
|
||||
TableName* fNamePtr;
|
||||
|
||||
};
|
||||
|
||||
/** @brief Collects SqlStatements so that we can support the
|
||||
@ -160,7 +158,8 @@ public:
|
||||
/** @brief ctor
|
||||
*/
|
||||
SqlStatementList()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
/** @brief dtor
|
||||
*/
|
||||
@ -186,7 +185,6 @@ public:
|
||||
|
||||
private:
|
||||
SqlStatementList(const SqlStatementList& x);
|
||||
|
||||
};
|
||||
|
||||
/** @brief The representation of a parsed
|
||||
@ -215,8 +213,7 @@ public:
|
||||
* @param columnNamesPtr pointer to ColumnNamesList object
|
||||
* @param valsOrQueryPtr pointer to ValuesOrQueryObject
|
||||
*/
|
||||
InsertSqlStatement(TableName* tableNamePtr, ColumnNameList* columnNamesPtr,
|
||||
ValuesOrQuery* valsOrQueryPtr);
|
||||
InsertSqlStatement(TableName* tableNamePtr, ColumnNameList* columnNamesPtr, ValuesOrQuery* valsOrQueryPtr);
|
||||
|
||||
/** @brief dtor
|
||||
*/
|
||||
@ -408,13 +405,14 @@ public:
|
||||
class ColumnAssignment
|
||||
{
|
||||
public:
|
||||
explicit ColumnAssignment(
|
||||
std::string const& column,
|
||||
std::string const& op = "=",
|
||||
std::string const& expr = "") :
|
||||
fColumn(column), fOperator(op), fScalarExpression(expr),
|
||||
fFromCol(false), fFuncScale(0), fIsNull(false)
|
||||
{};
|
||||
explicit ColumnAssignment(std::string const& column, std::string const& op = "=",
|
||||
std::string const& expr = "")
|
||||
: fColumn(column)
|
||||
, fOperator(op)
|
||||
, fScalarExpression(expr)
|
||||
, fFromCol(false)
|
||||
, fFuncScale(0)
|
||||
, fIsNull(false){};
|
||||
|
||||
/** @brief dump to stdout
|
||||
*/
|
||||
@ -567,7 +565,6 @@ public:
|
||||
std::string getWhereClauseString() const;
|
||||
|
||||
SearchCondition* fSearchConditionPtr;
|
||||
|
||||
};
|
||||
|
||||
/** @brief Stores a GROUP BY clause
|
||||
@ -976,8 +973,8 @@ public:
|
||||
* @param groupByPtr pointer to a GroupByClause object
|
||||
* @param havingPtr pointer to a HavingClause object
|
||||
*/
|
||||
TableExpression(FromClause* fromClausePtr, WhereClause* whereClausePtr,
|
||||
GroupByClause* groupByPtr, HavingClause* havingPtr);
|
||||
TableExpression(FromClause* fromClausePtr, WhereClause* whereClausePtr, GroupByClause* groupByPtr,
|
||||
HavingClause* havingPtr);
|
||||
|
||||
/** @brief dtor
|
||||
*/
|
||||
@ -1024,8 +1021,7 @@ public:
|
||||
* @param tableExpression pointer to a TableExpression object
|
||||
* @param allOrDistinct pointer to a ALL or DISTINCT string
|
||||
*/
|
||||
QuerySpec(SelectFilter* selectFilter, TableExpression* tableExpression,
|
||||
char* allOrDistinct);
|
||||
QuerySpec(SelectFilter* selectFilter, TableExpression* tableExpression, char* allOrDistinct);
|
||||
|
||||
/** @brief dtor
|
||||
*/
|
||||
|
@ -27,11 +27,11 @@ using namespace std;
|
||||
namespace dmlpackage
|
||||
{
|
||||
DMLTable::DMLTable()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
DMLTable::~DMLTable()
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
RowList::iterator it = fRows.begin();
|
||||
@ -46,7 +46,6 @@ DMLTable::~DMLTable()
|
||||
{
|
||||
cout << "failed to delete the table rows" << endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int DMLTable::read(messageqcpp::ByteStream& bytestream)
|
||||
@ -116,4 +115,3 @@ int DMLTable::write(messageqcpp::ByteStream& bytestream)
|
||||
}
|
||||
|
||||
} // namespace dmlpackage
|
||||
|
||||
|
@ -37,9 +37,7 @@ namespace dmlpackage
|
||||
*/
|
||||
class DMLTable : public DMLObject
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
/** @brief ctor
|
||||
*/
|
||||
DMLTable();
|
||||
@ -89,30 +87,25 @@ public:
|
||||
*/
|
||||
int read(messageqcpp::ByteStream& bytestream);
|
||||
|
||||
|
||||
/** @brief read a DMLTable metadata from a ByteStream
|
||||
*
|
||||
* @param bytestream the ByteStream to read from
|
||||
*/
|
||||
void readMetaData(messageqcpp::ByteStream& bytestream);
|
||||
|
||||
|
||||
/** @brief read a DMLTable row data from a ByteStream
|
||||
*
|
||||
* @param bytestream the ByteStream to read from
|
||||
*/
|
||||
void readRowData(messageqcpp::ByteStream& bytestream);
|
||||
|
||||
|
||||
/** @brief write a DMLTable to a ByteStream
|
||||
*
|
||||
* @param bytestream the ByteStream to write to
|
||||
*/
|
||||
int write(messageqcpp::ByteStream& bytestream);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
std::string fName;
|
||||
RowList fRows;
|
||||
@ -123,5 +116,3 @@ private:
|
||||
};
|
||||
|
||||
} // namespace dmlpackage
|
||||
|
||||
|
||||
|
@ -36,11 +36,12 @@ int main(int argc, char* argv[])
|
||||
int count;
|
||||
|
||||
po::options_description desc("Allowed options");
|
||||
desc.add_options ()
|
||||
("help", "produce help message")
|
||||
("bisond", /* po::value <string>(),*/ "Have bison produce debug output")
|
||||
("count", po::value <int>(), "number of runs")
|
||||
("sql", po::value < string > (), "sql file");
|
||||
desc.add_options()("help", "produce help message")(
|
||||
"bisond",
|
||||
/* po::value <string>(),*/ "Have bison produce debug output")("count", po::value<int>(),
|
||||
"number of runs")("sql",
|
||||
po::value<string>(),
|
||||
"sql file");
|
||||
po::variables_map vm;
|
||||
po::store(po::parse_command_line(argc, argv, desc), vm);
|
||||
po::notify(vm);
|
||||
@ -63,7 +64,8 @@ int main(int argc, char* argv[])
|
||||
const ParseTree& ptree = parser.getParseTree();
|
||||
|
||||
cout << "Parser succeeded." << endl;
|
||||
cout << ptree.fList.size() << " " << "SQL statements" << endl;
|
||||
cout << ptree.fList.size() << " "
|
||||
<< "SQL statements" << endl;
|
||||
cout << ptree.fSqlText << endl;
|
||||
cout << ptree;
|
||||
|
||||
|
@ -35,17 +35,19 @@ using namespace std;
|
||||
|
||||
namespace dmlpackage
|
||||
{
|
||||
|
||||
InsertDMLPackage::InsertDMLPackage()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
InsertDMLPackage::InsertDMLPackage( std::string schemaName, std::string tableName,
|
||||
std::string dmlStatement, int sessionID )
|
||||
InsertDMLPackage::InsertDMLPackage(std::string schemaName, std::string tableName, std::string dmlStatement,
|
||||
int sessionID)
|
||||
: CalpontDMLPackage(schemaName, tableName, dmlStatement, sessionID)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
InsertDMLPackage::~InsertDMLPackage()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
int InsertDMLPackage::write(messageqcpp::ByteStream& bytestream)
|
||||
{
|
||||
@ -164,7 +166,6 @@ int InsertDMLPackage::buildFromBuffer(std::string& buffer, int columns, int rows
|
||||
for (tokenizer::iterator tok_iter = tokens.begin(); tok_iter != tokens.end(); ++tok_iter)
|
||||
{
|
||||
dataList.push_back(StripLeadingWhitespace(*tok_iter));
|
||||
|
||||
}
|
||||
|
||||
int n = 0;
|
||||
@ -197,7 +198,8 @@ int InsertDMLPackage::buildFromBuffer(std::string& buffer, int columns, int rows
|
||||
return retval;
|
||||
}
|
||||
|
||||
int InsertDMLPackage::buildFromMysqlBuffer(ColNameList& colNameList, TableValuesMap& tableValuesMap, int columns, int rows, NullValuesBitset& nullValues )
|
||||
int InsertDMLPackage::buildFromMysqlBuffer(ColNameList& colNameList, TableValuesMap& tableValuesMap,
|
||||
int columns, int rows, NullValuesBitset& nullValues)
|
||||
{
|
||||
int retval = 1;
|
||||
|
||||
@ -226,7 +228,6 @@ int InsertDMLPackage::buildFromMysqlBuffer(ColNameList& colNameList, TableValues
|
||||
|
||||
int InsertDMLPackage::buildFromSqlStatement(SqlStatement& sqlStatement)
|
||||
{
|
||||
|
||||
int retval = 1;
|
||||
|
||||
InsertSqlStatement& insertStmt = dynamic_cast<InsertSqlStatement&>(sqlStatement);
|
||||
@ -240,12 +241,10 @@ int InsertDMLPackage::buildFromSqlStatement(SqlStatement& sqlStatement)
|
||||
// only if we don't have a select statement
|
||||
if (0 == insertStmt.fValuesOrQueryPtr->fQuerySpecPtr)
|
||||
{
|
||||
|
||||
ColumnNameList columnNameList = insertStmt.fColumnList;
|
||||
|
||||
if (columnNameList.size())
|
||||
{
|
||||
|
||||
ValuesList valuesList = insertStmt.fValuesOrQueryPtr->fValuesList;
|
||||
|
||||
if (columnNameList.size() != valuesList.size())
|
||||
@ -262,7 +261,6 @@ int InsertDMLPackage::buildFromSqlStatement(SqlStatement& sqlStatement)
|
||||
}
|
||||
|
||||
fTable->get_RowList().push_back(aRow);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -293,7 +291,6 @@ int InsertDMLPackage::buildFromSqlStatement(SqlStatement& sqlStatement)
|
||||
|
||||
fTable->get_RowList().push_back(aRow);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -40,7 +40,6 @@ namespace dmlpackage
|
||||
*/
|
||||
class InsertDMLPackage : public CalpontDMLPackage
|
||||
{
|
||||
|
||||
public:
|
||||
/** @brief ctor
|
||||
*/
|
||||
@ -53,8 +52,8 @@ public:
|
||||
* @param dmlStatement the dml statement
|
||||
* @param sessionID the session id
|
||||
*/
|
||||
EXPORT InsertDMLPackage(std::string schemaName, std::string tableName,
|
||||
std::string dmlStatement, int sessionID );
|
||||
EXPORT InsertDMLPackage(std::string schemaName, std::string tableName, std::string dmlStatement,
|
||||
int sessionID);
|
||||
|
||||
/** @brief dtor
|
||||
*/
|
||||
@ -99,7 +98,8 @@ public:
|
||||
* @param columns number of columns in the table
|
||||
* @param rows number of rows to be touched
|
||||
*/
|
||||
EXPORT int buildFromMysqlBuffer(ColNameList& colNameList, TableValuesMap& tableValuesMap, int columns, int rows, NullValuesBitset& nullValues);
|
||||
EXPORT int buildFromMysqlBuffer(ColNameList& colNameList, TableValuesMap& tableValuesMap, int columns,
|
||||
int rows, NullValuesBitset& nullValues);
|
||||
|
||||
/** @brief build a InsertDMLPackage from a InsertSqlStatement
|
||||
*
|
||||
@ -112,12 +112,9 @@ public:
|
||||
EXPORT void Dump();
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace dmlpackage
|
||||
|
||||
#undef EXPORT
|
||||
|
||||
|
@ -28,4 +28,3 @@
|
||||
/**
|
||||
* Methods
|
||||
*/
|
||||
|
||||
|
@ -32,14 +32,12 @@ namespace dmlpackage
|
||||
*/
|
||||
class MySQLDMLStatement : public VendorDMLStatement
|
||||
{
|
||||
|
||||
public:
|
||||
MySQLDMLStatement() : VendorDMLStatement("", 0) {}
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
MySQLDMLStatement() : VendorDMLStatement("", 0)
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
private:
|
||||
};
|
||||
} // namespace dmlpackage
|
||||
|
@ -28,5 +28,3 @@
|
||||
/**
|
||||
* Methods
|
||||
*/
|
||||
|
||||
|
||||
|
@ -33,14 +33,12 @@ namespace dmlpackage
|
||||
*/
|
||||
class OracleDMLStatement : public VendorDMLStatement
|
||||
{
|
||||
|
||||
public:
|
||||
OracleDMLStatement() : VendorDMLStatement("", 0) {}
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
OracleDMLStatement() : VendorDMLStatement("", 0)
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
private:
|
||||
};
|
||||
} // namespace dmlpackage
|
||||
|
@ -28,10 +28,9 @@
|
||||
|
||||
namespace dmlpackage
|
||||
{
|
||||
|
||||
Row::Row()
|
||||
: fRowID(std::numeric_limits<WriteEngine::RID>::max())
|
||||
{}
|
||||
Row::Row() : fRowID(std::numeric_limits<WriteEngine::RID>::max())
|
||||
{
|
||||
}
|
||||
|
||||
Row::~Row()
|
||||
{
|
||||
@ -73,7 +72,6 @@ int Row::read(messageqcpp::ByteStream& bytestream)
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
int Row::write(messageqcpp::ByteStream& bytestream)
|
||||
{
|
||||
int retval = 1;
|
||||
@ -105,6 +103,3 @@ const DMLColumn* Row::get_ColumnAt( unsigned int index ) const
|
||||
}
|
||||
|
||||
} // namespace dmlpackage
|
||||
|
||||
|
||||
|
||||
|
@ -43,7 +43,6 @@ namespace dmlpackage
|
||||
class Row : public DMLObject
|
||||
{
|
||||
public:
|
||||
|
||||
/** @brief ctor
|
||||
*/
|
||||
EXPORT Row();
|
||||
@ -103,19 +102,15 @@ public:
|
||||
EXPORT const DMLColumn* get_ColumnAt(unsigned int index) const;
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
WriteEngine::RID fRowID;
|
||||
ColumnList fColumnList;
|
||||
Row& operator=(const Row&);
|
||||
|
||||
};
|
||||
|
||||
/** @brief a vector of Rows
|
||||
*/
|
||||
typedef std::vector<Row*> RowList;
|
||||
}
|
||||
} // namespace dmlpackage
|
||||
|
||||
#undef EXPORT
|
||||
|
||||
|
||||
|
@ -52,7 +52,8 @@ bool parse_file(char* fileName)
|
||||
const ParseTree& ptree = parser.getParseTree();
|
||||
|
||||
cout << "Parser succeeded." << endl;
|
||||
cout << ptree.fList.size() << " " << "SQL statements" << endl;
|
||||
cout << ptree.fList.size() << " "
|
||||
<< "SQL statements" << endl;
|
||||
cout << ptree.fSqlText << endl;
|
||||
cout << ptree;
|
||||
|
||||
@ -64,7 +65,6 @@ bool parse_file(char* fileName)
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
|
||||
return good;
|
||||
}
|
||||
|
||||
@ -84,11 +84,14 @@ class DMLParserTest : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
private:
|
||||
|
||||
public:
|
||||
void setUp() {}
|
||||
void setUp()
|
||||
{
|
||||
}
|
||||
|
||||
void tearDown() {}
|
||||
void tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
void test_i01()
|
||||
{
|
||||
@ -143,7 +146,6 @@ public:
|
||||
|
||||
class DMLTest : public CppUnit::TestFixture
|
||||
{
|
||||
|
||||
CPPUNIT_TEST_SUITE(DMLTest);
|
||||
// CPPUNIT_TEST( test_direct_insert );
|
||||
// CPPUNIT_TEST( test_query_insert );
|
||||
@ -157,13 +159,16 @@ class DMLTest : public CppUnit::TestFixture
|
||||
|
||||
private:
|
||||
public:
|
||||
void setUp() {}
|
||||
void setUp()
|
||||
{
|
||||
}
|
||||
|
||||
void tearDown() {}
|
||||
void tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
void test_direct_insert()
|
||||
{
|
||||
|
||||
ByteStream bytestream;
|
||||
std::string dmlStatement = "INSERT INTO tpch.supplier (supplier_id, supplier_name) VALUES(24553, 'IBM');";
|
||||
cout << dmlStatement << endl;
|
||||
@ -175,13 +180,14 @@ public:
|
||||
write_DML_object(bytestream, pDMLPackage);
|
||||
delete pDMLPackage;
|
||||
read_insert_object(bytestream);
|
||||
|
||||
}
|
||||
|
||||
void test_query_insert()
|
||||
{
|
||||
ByteStream bytestream;
|
||||
std::string dmlStatement = "INSERT INTO supplier (supplier_id, supplier_name) SELECT account_no, name FROM customers WHERE city = 'Newark';";
|
||||
std::string dmlStatement =
|
||||
"INSERT INTO supplier (supplier_id, supplier_name) SELECT account_no, name FROM customers WHERE city "
|
||||
"= 'Newark';";
|
||||
cout << dmlStatement << endl;
|
||||
|
||||
VendorDMLStatement dmlStmt(dmlStatement, 1);
|
||||
@ -197,18 +203,15 @@ public:
|
||||
write_DML_object(bytestream, pDMLPackage);
|
||||
delete pDMLPackage;
|
||||
read_insert_object(bytestream);
|
||||
|
||||
}
|
||||
|
||||
void write_DML_object(ByteStream& bs, CalpontDMLPackage* pDMLPackage)
|
||||
{
|
||||
|
||||
pDMLPackage->write(bs);
|
||||
}
|
||||
|
||||
void read_insert_object(ByteStream& bs)
|
||||
{
|
||||
|
||||
ByteStream::byte package_type;
|
||||
bs >> package_type;
|
||||
|
||||
@ -219,12 +222,10 @@ public:
|
||||
pObject->read(bs);
|
||||
|
||||
delete pObject;
|
||||
|
||||
}
|
||||
|
||||
void test_delete_all()
|
||||
{
|
||||
|
||||
ByteStream bytestream;
|
||||
std::string dmlStatement = "DELETE FROM tpch.part;";
|
||||
|
||||
@ -260,12 +261,10 @@ public:
|
||||
write_DML_object(bytestream, pDMLPackage);
|
||||
delete pDMLPackage;
|
||||
read_delete_object(bytestream);
|
||||
|
||||
}
|
||||
|
||||
void read_delete_object(ByteStream& bs)
|
||||
{
|
||||
|
||||
ByteStream::byte package_type;
|
||||
bs >> package_type;
|
||||
|
||||
@ -276,7 +275,6 @@ public:
|
||||
pObject->read(bs);
|
||||
|
||||
delete pObject;
|
||||
|
||||
}
|
||||
|
||||
void test_direct_update()
|
||||
@ -295,9 +293,10 @@ public:
|
||||
|
||||
void test_query_update()
|
||||
{
|
||||
|
||||
ByteStream bytestream;
|
||||
std::string dmlStatement = "UPDATE tpch.supplier SET supplier_name='joe',supplier_state='ca' WHERE EXISTS ( SELECT customer.name FROM customers WHERE customers.customer_id = supplier.supplier_id);";
|
||||
std::string dmlStatement =
|
||||
"UPDATE tpch.supplier SET supplier_name='joe',supplier_state='ca' WHERE EXISTS ( SELECT "
|
||||
"customer.name FROM customers WHERE customers.customer_id = supplier.supplier_id);";
|
||||
cout << dmlStatement << endl;
|
||||
|
||||
VendorDMLStatement dmlStmt(dmlStatement, 1);
|
||||
@ -317,7 +316,6 @@ public:
|
||||
|
||||
void read_update_object(ByteStream& bs)
|
||||
{
|
||||
|
||||
ByteStream::byte package_type;
|
||||
bs >> package_type;
|
||||
|
||||
@ -328,7 +326,6 @@ public:
|
||||
pObject->read(bs);
|
||||
|
||||
delete pObject;
|
||||
|
||||
}
|
||||
|
||||
void test_commit()
|
||||
@ -343,7 +340,6 @@ public:
|
||||
write_DML_object(bytestream, pDMLPackage);
|
||||
delete pDMLPackage;
|
||||
read_command_object(bytestream);
|
||||
|
||||
}
|
||||
|
||||
void test_rollback()
|
||||
@ -362,7 +358,6 @@ public:
|
||||
|
||||
void read_command_object(ByteStream& bs)
|
||||
{
|
||||
|
||||
ByteStream::byte package_type;
|
||||
bs >> package_type;
|
||||
|
||||
@ -373,7 +368,6 @@ public:
|
||||
pObject->read(bs);
|
||||
|
||||
delete pObject;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -32,17 +32,19 @@ using namespace std;
|
||||
|
||||
namespace dmlpackage
|
||||
{
|
||||
|
||||
UpdateDMLPackage::UpdateDMLPackage()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
UpdateDMLPackage::UpdateDMLPackage(std::string schemaName, std::string tableName,
|
||||
std::string dmlStatement, int sessionID)
|
||||
UpdateDMLPackage::UpdateDMLPackage(std::string schemaName, std::string tableName, std::string dmlStatement,
|
||||
int sessionID)
|
||||
: CalpontDMLPackage(schemaName, tableName, dmlStatement, sessionID)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
UpdateDMLPackage::~UpdateDMLPackage()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
int UpdateDMLPackage::write(messageqcpp::ByteStream& bytestream)
|
||||
{
|
||||
@ -120,7 +122,6 @@ int UpdateDMLPackage::read(messageqcpp::ByteStream& bytestream)
|
||||
|
||||
int UpdateDMLPackage::buildFromSqlStatement(SqlStatement& sqlStatement)
|
||||
{
|
||||
|
||||
int retval = 1;
|
||||
|
||||
UpdateSqlStatement& updateStmt = dynamic_cast<UpdateSqlStatement&>(sqlStatement);
|
||||
@ -178,7 +179,6 @@ int UpdateDMLPackage::buildFromBuffer(std::string& buffer, int columns, int rows
|
||||
for (tokenizer::iterator tok_iter = tokens.begin(); tok_iter != tokens.end(); ++tok_iter)
|
||||
{
|
||||
dataList.push_back(StripLeadingWhitespace(*tok_iter));
|
||||
|
||||
}
|
||||
|
||||
int n = 0;
|
||||
@ -217,7 +217,8 @@ int UpdateDMLPackage::buildFromBuffer(std::string& buffer, int columns, int rows
|
||||
|
||||
return retval;
|
||||
}
|
||||
int UpdateDMLPackage::buildFromMysqlBuffer(ColNameList& colNameList, TableValuesMap& tableValuesMap, int columns, int rows, NullValuesBitset& nullValues )
|
||||
int UpdateDMLPackage::buildFromMysqlBuffer(ColNameList& colNameList, TableValuesMap& tableValuesMap,
|
||||
int columns, int rows, NullValuesBitset& nullValues)
|
||||
{
|
||||
int retval = 1;
|
||||
|
||||
@ -244,7 +245,6 @@ int UpdateDMLPackage::buildFromMysqlBuffer(ColNameList& colNameList, TableValues
|
||||
|
||||
void UpdateDMLPackage::buildUpdateFromMysqlBuffer(UpdateSqlStatement& updateStmt)
|
||||
{
|
||||
|
||||
if (!updateStmt.fColAssignmentListPtr)
|
||||
throw runtime_error("updateStmt.fColAssignmentPtr == NULL");
|
||||
|
||||
@ -259,8 +259,8 @@ void UpdateDMLPackage::buildUpdateFromMysqlBuffer(UpdateSqlStatement& updateStm
|
||||
while (iter != updateStmt.fColAssignmentListPtr->end())
|
||||
{
|
||||
ColumnAssignment* colaPtr = *iter;
|
||||
DMLColumn* colPtr = new DMLColumn(colaPtr->fColumn, colaPtr->fScalarExpression, colaPtr->fFromCol, colaPtr->fFuncScale,
|
||||
colaPtr->fIsNull);
|
||||
DMLColumn* colPtr = new DMLColumn(colaPtr->fColumn, colaPtr->fScalarExpression, colaPtr->fFromCol,
|
||||
colaPtr->fFuncScale, colaPtr->fIsNull);
|
||||
rowPtr->get_ColumnList().push_back(colPtr);
|
||||
|
||||
++iter;
|
||||
|
@ -40,7 +40,6 @@ namespace dmlpackage
|
||||
*/
|
||||
class UpdateDMLPackage : public CalpontDMLPackage
|
||||
{
|
||||
|
||||
public:
|
||||
/** @brief ctor
|
||||
*/
|
||||
@ -53,8 +52,8 @@ public:
|
||||
* @param dmlStatement the dml statement
|
||||
* @param sessionID the session ID
|
||||
*/
|
||||
EXPORT UpdateDMLPackage( std::string schemaName, std::string tableName,
|
||||
std::string dmlStatement, int sessionID );
|
||||
EXPORT UpdateDMLPackage(std::string schemaName, std::string tableName, std::string dmlStatement,
|
||||
int sessionID);
|
||||
|
||||
/** @brief dtor
|
||||
*/
|
||||
@ -91,16 +90,13 @@ public:
|
||||
* @param colNameList, tableValuesMap
|
||||
* @param rows the number of rows in the buffer
|
||||
*/
|
||||
EXPORT int buildFromMysqlBuffer(ColNameList& colNameList, TableValuesMap& tableValuesMap, int columns, int rows, NullValuesBitset& nullValues);
|
||||
EXPORT int buildFromMysqlBuffer(ColNameList& colNameList, TableValuesMap& tableValuesMap, int columns,
|
||||
int rows, NullValuesBitset& nullValues);
|
||||
void buildUpdateFromMysqlBuffer(UpdateSqlStatement& updateStmt);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
}
|
||||
} // namespace dmlpackage
|
||||
|
||||
#undef EXPORT
|
||||
|
||||
|
@ -29,31 +29,56 @@ using namespace std;
|
||||
|
||||
namespace dmlpackage
|
||||
{
|
||||
|
||||
VendorDMLStatement::VendorDMLStatement(std::string dmlstatement, int sessionID)
|
||||
: fDMLStatement(dmlstatement), fSessionID(sessionID), fLogging(true), fLogending(true)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
VendorDMLStatement::VendorDMLStatement(std::string dmlstatement, int stmttype, int sessionID)
|
||||
: fDMLStatement(dmlstatement), fDMLStatementType(stmttype), fSessionID(sessionID), fLogging(true), fLogending(true)
|
||||
{}
|
||||
: fDMLStatement(dmlstatement)
|
||||
, fDMLStatementType(stmttype)
|
||||
, fSessionID(sessionID)
|
||||
, fLogging(true)
|
||||
, fLogending(true)
|
||||
{
|
||||
}
|
||||
|
||||
VendorDMLStatement::VendorDMLStatement(std::string dmlstatement, int stmttype,
|
||||
std::string tName, std::string schema,
|
||||
int rows, int columns, std::string buf,
|
||||
VendorDMLStatement::VendorDMLStatement(std::string dmlstatement, int stmttype, std::string tName,
|
||||
std::string schema, int rows, int columns, std::string buf,
|
||||
int sessionID)
|
||||
: fDMLStatement(dmlstatement), fDMLStatementType(stmttype),
|
||||
fTableName(tName), fSchema(schema), fRows(rows), fColumns(columns),
|
||||
fDataBuffer(buf), fSessionID(sessionID), fLogging(true), fLogending(true)
|
||||
{}
|
||||
: fDMLStatement(dmlstatement)
|
||||
, fDMLStatementType(stmttype)
|
||||
, fTableName(tName)
|
||||
, fSchema(schema)
|
||||
, fRows(rows)
|
||||
, fColumns(columns)
|
||||
, fDataBuffer(buf)
|
||||
, fSessionID(sessionID)
|
||||
, fLogging(true)
|
||||
, fLogending(true)
|
||||
{
|
||||
}
|
||||
|
||||
VendorDMLStatement::VendorDMLStatement(std::string dmlstatement, int stmttype, std::string tName, std::string schema, int rows, int columns,
|
||||
ColNameList& colNameList, TableValuesMap& tableValuesMap, NullValuesBitset& nullValues, int sessionID)
|
||||
: fDMLStatement(dmlstatement), fDMLStatementType(stmttype),
|
||||
fTableName(tName), fSchema(schema), fRows(rows), fColumns(columns),
|
||||
fColNameList(colNameList), fTableValuesMap(tableValuesMap), fNullValues(nullValues), fSessionID(sessionID), fLogging(true), fLogending(true)
|
||||
{}
|
||||
VendorDMLStatement::VendorDMLStatement(std::string dmlstatement, int stmttype, std::string tName,
|
||||
std::string schema, int rows, int columns, ColNameList& colNameList,
|
||||
TableValuesMap& tableValuesMap, NullValuesBitset& nullValues,
|
||||
int sessionID)
|
||||
: fDMLStatement(dmlstatement)
|
||||
, fDMLStatementType(stmttype)
|
||||
, fTableName(tName)
|
||||
, fSchema(schema)
|
||||
, fRows(rows)
|
||||
, fColumns(columns)
|
||||
, fColNameList(colNameList)
|
||||
, fTableValuesMap(tableValuesMap)
|
||||
, fNullValues(nullValues)
|
||||
, fSessionID(sessionID)
|
||||
, fLogging(true)
|
||||
, fLogending(true)
|
||||
{
|
||||
}
|
||||
|
||||
VendorDMLStatement::~VendorDMLStatement()
|
||||
{}
|
||||
{
|
||||
}
|
||||
} // namespace dmlpackage
|
||||
|
@ -45,7 +45,6 @@ typedef std::bitset<4096> NullValuesBitset;
|
||||
*/
|
||||
class VendorDMLStatement
|
||||
{
|
||||
|
||||
public:
|
||||
/** @brief ctor
|
||||
*/
|
||||
@ -57,14 +56,14 @@ public:
|
||||
|
||||
/** @brief old ctor!
|
||||
*/
|
||||
EXPORT VendorDMLStatement(std::string dmlstatement, int stmttype, std::string tName,
|
||||
std::string schema, int rows, int columns, std::string buf,
|
||||
int sessionID);
|
||||
EXPORT VendorDMLStatement(std::string dmlstatement, int stmttype, std::string tName, std::string schema,
|
||||
int rows, int columns, std::string buf, int sessionID);
|
||||
|
||||
/** @brief ctor for mysql
|
||||
*/
|
||||
EXPORT VendorDMLStatement(std::string dmlstatement, int stmttype, std::string tName, std::string schema, int rows, int columns,
|
||||
ColNameList& colNameList, TableValuesMap& tableValuesMap, NullValuesBitset& nullValues, int sessionID);
|
||||
EXPORT VendorDMLStatement(std::string dmlstatement, int stmttype, std::string tName, std::string schema,
|
||||
int rows, int columns, ColNameList& colNameList, TableValuesMap& tableValuesMap,
|
||||
NullValuesBitset& nullValues, int sessionID);
|
||||
|
||||
/** @brief destructor
|
||||
*/
|
||||
@ -227,7 +226,6 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
std::string fDMLStatement;
|
||||
int fDMLStatementType;
|
||||
@ -242,10 +240,8 @@ private:
|
||||
int fSessionID;
|
||||
bool fLogging;
|
||||
bool fLogending;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace dmlpackage
|
||||
|
||||
#undef EXPORT
|
||||
|
||||
|
@ -26,7 +26,6 @@
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include <boost/thread/condition.hpp>
|
||||
|
||||
|
||||
class AutoincrementData
|
||||
{
|
||||
public:
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user