本文整理汇总了C++中ObExprObj::set_ctime方法的典型用法代码示例。如果您正苦于以下问题:C++ ObExprObj::set_ctime方法的具体用法?C++ ObExprObj::set_ctime怎么用?C++ ObExprObj::set_ctime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObExprObj
的用法示例。
在下文中一共展示了ObExprObj::set_ctime方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bool_ctime
static int bool_ctime(const ObObjCastParams ¶ms, const ObExprObj &in, ObExprObj &out)
{
UNUSED(params);
OB_ASSERT(in.get_type() == ObBoolType);
out.set_ctime(static_cast<ObCreateTime> (in.get_bool()));
return OB_SUCCESS;
}
示例2: mtime_ctime
static int mtime_ctime(const ObObjCastParams ¶ms, const ObExprObj &in, ObExprObj &out)
{
UNUSED(params);
OB_ASSERT(in.get_type() == ObModifyTimeType);
out.set_ctime(static_cast<ObModifyTime> (in.get_mtime()));
return OB_SUCCESS;
}
示例3: pdatetime_ctime
static int pdatetime_ctime(const ObObjCastParams ¶ms, const ObExprObj &in, ObExprObj &out)
{
UNUSED(params);
OB_ASSERT(in.get_type() == ObPreciseDateTimeType);
out.set_ctime(static_cast<ObCreateTime> (in.get_precise_datetime()));
return OB_SUCCESS;
}
示例4: memset
TEST_F(ObObjCastTest, ctime_to_xxx)
{
ObExprObj in;
const char* cases_str[] = {"1970-1-1 8:0:0", "1970-1-1 0:0:0", "2012-9-24 16:59:60"};
int64_t cases[ARRAYSIZEOF(cases_str)];
const char *varchar_expected[] = {"1970-01-01 08:00:00.000000", "1970-01-01 00:00:00.000000", "2012-09-24 17:00:00.000000"};
const char *dec_expected[] = {"0", "-28800000000", "1348477200000000"};
for (int64_t i = 0; i < static_cast<int64_t>(ARRAYSIZEOF(cases)); ++i)
{
struct tm tm;
memset(&tm, 0, sizeof(tm));
strptime(cases_str[i], "%Y-%m-%d %H:%M:%S", &tm);
cases[i] = mktime(&tm) * 1000000L;
int64_t v = cases[i];
int64_t pv = v / 1000000L;
in.set_ctime(v);
MY_EXPECT(ObCreateTimeType, in, ObNullType, v, varchar_expected[i]);
MY_EXPECT(ObCreateTimeType, in, ObIntType, v, varchar_expected[i]);
MY_EXPECT(ObCreateTimeType, in, ObFloatType, v, varchar_expected[i]);
MY_EXPECT(ObCreateTimeType, in, ObDoubleType, v, varchar_expected[i]);
MY_EXPECT(ObCreateTimeType, in, ObDateTimeType, pv, varchar_expected[i]);
MY_EXPECT(ObCreateTimeType, in, ObPreciseDateTimeType, v, varchar_expected[i]);
MY_EXPECT(ObCreateTimeType, in, ObVarcharType, v, varchar_expected[i]);
MY_EXPECT(ObCreateTimeType, in, ObSeqType, v, varchar_expected[i]);
MY_EXPECT(ObCreateTimeType, in, ObCreateTimeType, v, varchar_expected[i]);
MY_EXPECT(ObCreateTimeType, in, ObModifyTimeType, v, varchar_expected[i]);
MY_EXPECT(ObCreateTimeType, in, ObExtendType, v, varchar_expected[i]);
MY_EXPECT(ObCreateTimeType, in, ObBoolType, v, varchar_expected[i]);
MY_EXPECT(ObCreateTimeType, in, ObDecimalType, v, dec_expected[i]);
}
}
示例5: varchar_ctime
static int varchar_ctime(const ObObjCastParams ¶ms, const ObExprObj &in, ObExprObj &out)
{
int ret = OB_SUCCESS;
UNUSED(params);
OB_ASSERT(in.get_type() == ObVarcharType);
int64_t timestamp = 0;
ret = varchar_timestamp(in, timestamp);
if (OB_SUCCESS == ret)
{
out.set_ctime(static_cast<ObCreateTime> (timestamp));
}
else
{
const string& varchar = in.get_varchar();
jlog(WARNING, "failed to convert string `%.*s' to createtime type",
varchar.length(), varchar.data());
out.set_ctime(static_cast<ObCreateTime> (0));
ret = OB_SUCCESS;
}
return ret;
}
示例6: decimal_ctime
static int decimal_ctime(const ObObjCastParams ¶ms, const ObExprObj &in, ObExprObj &out)
{
int ret = OB_SUCCESS;
UNUSED(params);
OB_ASSERT(in.get_type() == ObDecimalType);
int64_t i64 = 0;
if (OB_SUCCESS != (ret = in.get_decimal().cast_to_int64(i64)))
{
jlog(WARNING, "failed to cast to int64, err=%d", ret);
}
else
{
out.set_ctime(static_cast<ObCreateTime> (i64));
}
return ret;
}