当前位置: 首页>>代码示例>>C++>>正文


C++ ObExprObj::set_precise_datetime方法代码示例

本文整理汇总了C++中ObExprObj::set_precise_datetime方法的典型用法代码示例。如果您正苦于以下问题:C++ ObExprObj::set_precise_datetime方法的具体用法?C++ ObExprObj::set_precise_datetime怎么用?C++ ObExprObj::set_precise_datetime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ObExprObj的用法示例。


在下文中一共展示了ObExprObj::set_precise_datetime方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: bool_pdatetime

 static int bool_pdatetime(const ObObjCastParams &params, const ObExprObj &in, ObExprObj &out)
 {
     UNUSED(params);
     OB_ASSERT(in.get_type() == ObBoolType);
     out.set_precise_datetime(static_cast<ObPreciseDateTime> (in.get_bool()));
     return OB_SUCCESS;
 }
开发者ID:b-xiang,项目名称:sql_parser-1,代码行数:7,代码来源:ob_obj_cast.cpp

示例2: memset

TEST_F(ObObjCastTest, precise_datetime_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_precise_datetime(v);

        MY_EXPECT(ObPreciseDateTimeType, in, ObNullType, v, varchar_expected[i]);
        MY_EXPECT(ObPreciseDateTimeType, in, ObIntType, v, varchar_expected[i]);
        MY_EXPECT(ObPreciseDateTimeType, in, ObFloatType, v, varchar_expected[i]);
        MY_EXPECT(ObPreciseDateTimeType, in, ObDoubleType, v, varchar_expected[i]);
        MY_EXPECT(ObPreciseDateTimeType, in, ObDateTimeType, pv, varchar_expected[i]);
        MY_EXPECT(ObPreciseDateTimeType, in, ObPreciseDateTimeType, v, varchar_expected[i]);
        MY_EXPECT(ObPreciseDateTimeType, in, ObVarcharType, v, varchar_expected[i]);
        MY_EXPECT(ObPreciseDateTimeType, in, ObSeqType, v, varchar_expected[i]);
        MY_EXPECT(ObPreciseDateTimeType, in, ObCreateTimeType, v, varchar_expected[i]);
        MY_EXPECT(ObPreciseDateTimeType, in, ObModifyTimeType, v, varchar_expected[i]);
        MY_EXPECT(ObPreciseDateTimeType, in, ObExtendType, v, varchar_expected[i]);
        MY_EXPECT(ObPreciseDateTimeType, in, ObBoolType, v, varchar_expected[i]);
        MY_EXPECT(ObPreciseDateTimeType, in, ObDecimalType, v, dec_expected[i]);
    }
}
开发者ID:sharpglasses,项目名称:oceanbase,代码行数:32,代码来源:ob_obj_cast_test.cpp

示例3: varchar_pdatetime

 static int varchar_pdatetime(const ObObjCastParams &params, 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_precise_datetime(static_cast<ObPreciseDateTime> (timestamp));
     }
     else
     {
         const string& varchar = in.get_varchar();
         jlog(WARNING, "failed to convert string `%.*s' to precise_datetime type",
                 varchar.length(), varchar.data());
         out.set_precise_datetime(static_cast<ObPreciseDateTime> (0));
         ret = OB_SUCCESS;
     }
     return ret;
 }
开发者ID:b-xiang,项目名称:sql_parser-1,代码行数:21,代码来源:ob_obj_cast.cpp

示例4: decimal_pdatetime

 static int decimal_pdatetime(const ObObjCastParams &params, 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_precise_datetime(static_cast<ObPreciseDateTime> (i64));
     }
     return ret;
 }
开发者ID:b-xiang,项目名称:sql_parser-1,代码行数:16,代码来源:ob_obj_cast.cpp


注:本文中的ObExprObj::set_precise_datetime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。