oceanbase / miniob

MiniOB is a compact database that assists developers in understanding the fundamental workings of a database.
https://oceanbase.github.io/miniob/
Mulan Permissive Software License, Version 2
3.47k stars 1.24k forks source link

实现date功能后语法可以解析但是插入数据为0 #447

Closed Little-Villain closed 1 month ago

Little-Villain commented 1 month ago

以下是实现改动

include

include "common/lang/comparator.h"

include "common/lang/sstream.h"

include "common/log/log.h"

include "common/type/date_type.h"

include "common/value.h"

int DateType::compare(const Value &left, const Value &right) const { return common::compareint((void*)&left.value.intvalue,(void*)&right.value_.intvalue); }

RC DateType::tostring(const Value &val, string &result) const { stringstream ss; ss << std::setw(4) << std::setfill('0') << val.value.intvalue / 10000 <<"-" << std::setw(2) << std::setfill('0') << (val.value_.intvalue%10000) / 100 <<"-" << std::setw(2) << std::setfill('0') << val.value_.intvalue % 100;

result=ss.str(); return RC::SUCCESS; }

`

nautaa commented 1 month ago

data_type.cpp make_unique(),

请问这一行 make_unique<FloatType>(), 的顺序与 src/observer/common/type/attr_type.h 中DATES 的声明顺序一致吗,这个可能会影响到你所说的 “出现的报错是调用了FloatType的比较函数”

Little-Villain commented 1 month ago

data_type.cpp make_unique(),

请问这一行 make_unique<FloatType>(), 的顺序与 src/observer/common/type/attr_type.h 中DATES 的声明顺序一致吗,这个可能会影响到你所说的 “出现的报错是调用了FloatType的比较函数”

感谢!就是这里出错了,修改完以后可以正确运行了