fix the truncation of COMMENT sql
This commit is contained in:
parent
2050d2a882
commit
674e87b495
28
deps/oblib/src/lib/utility/ob_print_utils.h
vendored
28
deps/oblib/src/lib/utility/ob_print_utils.h
vendored
@ -147,11 +147,11 @@ public:
|
||||
class CStringBufMgr
|
||||
{
|
||||
public:
|
||||
static const int BUF_SIZE = 8 * 1024;
|
||||
static const int MIN_REST_SIZE = 1024;
|
||||
static const int BUF_SIZE = 32 * 1024;
|
||||
static const int MIN_SIZE = 12 * 1024;
|
||||
struct BufNode
|
||||
{
|
||||
char buf_[BUF_SIZE];
|
||||
char buf_[MIN_SIZE];
|
||||
int64_t level_;
|
||||
struct BufNode *next_;
|
||||
};
|
||||
@ -169,17 +169,19 @@ public:
|
||||
}
|
||||
void inc_level() { level_++; }
|
||||
void dec_level() { level_--; }
|
||||
int64_t get_pos() { return pos_; }
|
||||
void set_pos(int64_t pos)
|
||||
void update_position(int64_t pos)
|
||||
{
|
||||
if (0 == level_) {
|
||||
if (MIN_REST_SIZE > BUF_SIZE - pos) {
|
||||
pos_ += pos;
|
||||
if (MIN_SIZE > BUF_SIZE - pos_) {
|
||||
pos_ = 0;
|
||||
} else {
|
||||
pos_ = pos;
|
||||
}
|
||||
}
|
||||
}
|
||||
int64_t get_buffer_len()
|
||||
{
|
||||
return 0 == level_ ? (BUF_SIZE - pos_) : MIN_SIZE;
|
||||
}
|
||||
char *acquire()
|
||||
{
|
||||
char *buffer = NULL;
|
||||
@ -235,15 +237,14 @@ const char *to_cstring(const T &obj, const bool verbose)
|
||||
if (OB_ISNULL(buffer)) {
|
||||
LIB_LOG_RET(ERROR, OB_ALLOCATE_MEMORY_FAILED, "buffer is NULL");
|
||||
} else {
|
||||
int64_t pos = mgr.get_pos();
|
||||
const int64_t buf_len = CStringBufMgr::BUF_SIZE - pos;
|
||||
const int64_t buf_len = mgr.get_buffer_len();
|
||||
str_len = obj.to_string(buffer, buf_len -1, verbose);
|
||||
if (str_len >= 0 && str_len < buf_len) {
|
||||
buffer[str_len] = '\0';
|
||||
} else {
|
||||
buffer[0] = '\0';
|
||||
}
|
||||
mgr.set_pos(pos + str_len + 1);
|
||||
mgr.update_position(str_len + 1);
|
||||
}
|
||||
mgr.try_clear_list();
|
||||
mgr.dec_level();
|
||||
@ -261,15 +262,14 @@ const char *to_cstring(const T &obj, FalseType)
|
||||
if (OB_ISNULL(buffer)) {
|
||||
LIB_LOG_RET(ERROR, OB_ALLOCATE_MEMORY_FAILED, "buffer is NULL");
|
||||
} else {
|
||||
int64_t pos = mgr.get_pos();
|
||||
const int64_t buf_len = CStringBufMgr::BUF_SIZE - pos;
|
||||
const int64_t buf_len = mgr.get_buffer_len();
|
||||
str_len = to_string(obj, buffer, buf_len -1);
|
||||
if (str_len >= 0 && str_len < buf_len) {
|
||||
buffer[str_len] = '\0';
|
||||
} else {
|
||||
buffer[0] = '\0';
|
||||
}
|
||||
mgr.set_pos(pos + str_len + 1);
|
||||
mgr.update_position(str_len + 1);
|
||||
}
|
||||
mgr.try_clear_list();
|
||||
mgr.dec_level();
|
||||
|
@ -108,18 +108,12 @@ TEST(print_utility, to_cstring)
|
||||
to_cstring(*tuples[0]), to_cstring(*tuples[1]), to_cstring(*tuples[2]));
|
||||
_OB_LOG(INFO, "print tuple string, {%s}, {%s}, {%s}, {%s}, {%s}, {%s}, {%s}", to_cstring(*tuples[3]), to_cstring(*tuples[4]),
|
||||
to_cstring(*tuples[5]), to_cstring(*tuples[6]), to_cstring(*tuples[7]), to_cstring(*tuples[8]), to_cstring(*tuples[9]));
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
int64_t pos = CStringBufMgr::get_thread_local_instance().get_pos();
|
||||
_OB_LOG(INFO, "print tuple string, pos = %ld\n", pos);
|
||||
to_cstring(*tuples[0]);
|
||||
}
|
||||
// the performance of to_cstring when observer reach memory limit
|
||||
EventItem item;
|
||||
item.trigger_freq_ = 1;
|
||||
item.error_code_ = OB_ALLOCATE_MEMORY_FAILED;
|
||||
::oceanbase::common::EventTable::instance().set_event(EventTable::EN_4, item);
|
||||
int64_t pos = CStringBufMgr::get_thread_local_instance().get_pos();
|
||||
_OB_LOG(INFO, "print tuple string, {%s}, pos = %ld\n", to_cstring(*tuples[0]), pos);
|
||||
_OB_LOG(INFO, "print tuple string, {%s}\n", to_cstring(*tuples[0]));
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
|
@ -1120,8 +1120,7 @@ inline const char *get_vectorized_row_str(ObEvalCtx &eval_ctx,
|
||||
if (OB_ISNULL(buffer)) {
|
||||
LIB_LOG_RET(ERROR, OB_ALLOCATE_MEMORY_FAILED, "buffer is NULL");
|
||||
} else {
|
||||
int64_t pos = mgr.get_pos();
|
||||
const int64_t buf_len = CStringBufMgr::BUF_SIZE - pos;
|
||||
const int64_t buf_len = mgr.get_buffer_len();
|
||||
databuff_printf(buffer, buf_len, str_len, "vectorized_rows(%ld)=", index);
|
||||
str_len += to_string(ROWEXPR2STR(eval_ctx, exprs), buffer + str_len, buf_len - str_len - 1);
|
||||
if (str_len >= 0 && str_len < buf_len) {
|
||||
@ -1129,6 +1128,7 @@ inline const char *get_vectorized_row_str(ObEvalCtx &eval_ctx,
|
||||
} else {
|
||||
buffer[0] = '\0';
|
||||
}
|
||||
mgr.update_position(str_len + 1);
|
||||
}
|
||||
mgr.try_clear_list();
|
||||
mgr.dec_level();
|
||||
|
Loading…
x
Reference in New Issue
Block a user