use of com.actiontech.dble.plan.common.time.MySQLTimestampType in project dble by actiontech.
the class GetDatetimeValue method get.
@Override
public long get(Item item, Item warnItem, BoolPtr isNull) {
long value = 0;
String str = null;
if (item.isTemporal()) {
value = item.valDateTemporal();
isNull.set(item.isNullValue());
} else {
str = item.valStr();
isNull.set(item.isNullValue());
}
if (isNull.get())
return 0;
if (str != null) {
BoolPtr error = new BoolPtr(false);
FieldTypes fType = warnItem.fieldType();
MySQLTimestampType tType = fType == FieldTypes.MYSQL_TYPE_DATE ? MySQLTimestampType.MYSQL_TIMESTAMP_DATE : MySQLTimestampType.MYSQL_TIMESTAMP_DATETIME;
value = MySQLcom.getDateFromStr(str, tType, error);
}
return value;
}
use of com.actiontech.dble.plan.common.time.MySQLTimestampType in project dble by actiontech.
the class ArgComparator method getDateFromConst.
/**
* Check if str_arg is a constant and convert it to datetime packed value.
* Note, const_value may stay untouched, so the caller is responsible to
* initialize it.
*
* @param dateArg date argument, it's name is used for error reporting.
* @param strArg string argument to get datetime value from.
* @return true on error, false on success, false if str_arg is not a const.
* @param[out] const_value the converted value is stored here, if not NULL.
*/
static boolean getDateFromConst(Item dateArg, Item strArg, LongPtr constValue) {
BoolPtr error = new BoolPtr(false);
long value = 0;
if (strArg.fieldType() == FieldTypes.MYSQL_TYPE_TIME) {
// Convert from TIME to DATETIME
value = strArg.valDateTemporal();
if (strArg.isNullValue())
return true;
} else {
// Convert from string to DATETIME
String strVal = strArg.valStr();
MySQLTimestampType ttype = (dateArg.fieldType() == FieldTypes.MYSQL_TYPE_DATE ? MySQLTimestampType.MYSQL_TIMESTAMP_DATE : MySQLTimestampType.MYSQL_TIMESTAMP_DATETIME);
if (strArg.isNullValue()) {
return true;
}
value = MySQLcom.getDateFromStr(strVal, ttype, error);
if (error.get())
return true;
}
if (constValue != null)
constValue.set(value);
return false;
}
Aggregations