Skip to content

Commit

Permalink
Merge pull request #180 from chdb-io/fix/test_gc_fail
Browse files Browse the repository at this point in the history
fix: core dump
  • Loading branch information
auxten authored Jan 9, 2024
2 parents 4f9c9e1 + dcaac61 commit dc29e0a
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 117 deletions.
2 changes: 1 addition & 1 deletion chdb/dbapi/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def _execute_command(self, sql):
if DEBUG:
print("DEBUG: query:", sql)
try:
res = self._session.query(sql, output_format="JSON")
res = self._session.query(sql, fmt="JSON")
if res.has_error():
raise err.DatabaseError(res.error_message())
self._resp = res.data()
Expand Down
1 change: 0 additions & 1 deletion programs/local/LocalChdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class local_result_wrapper
~local_result_wrapper()
{
free_result_v2(result);
delete result;
}
char * data()
{
Expand Down
20 changes: 13 additions & 7 deletions programs/local/LocalServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ std::unique_ptr<query_result_> pyEntryClickHouseLocal(int argc, char ** argv)
local_result * query_stable(int argc, char ** argv)
{
auto result = pyEntryClickHouseLocal(argc, argv);
if (result->error_msg_.empty())
if (result->error_msg_.empty() || result->buf_ == nullptr)
{
return nullptr;
}
Expand All @@ -1104,26 +1104,31 @@ void free_result(local_result * result)
delete vec;
result->_vec = nullptr;
}
delete result;
}

local_result_v2 * query_stable_v2(int argc, char ** argv)
{
auto result = pyEntryClickHouseLocal(argc, argv);
if (result->buf_ == nullptr) {
return nullptr;
}

local_result_v2 * res = new local_result_v2;
if (!result->error_msg_.empty())
if (result->error_msg_.empty())
{
res->error_message = new char[result->error_msg_.size() + 1];
memcpy(res->error_message, result->error_msg_.c_str(), result->error_msg_.size() + 1);
res->_vec = nullptr;
res->buf = nullptr;
} else {
res->len = result->buf_->size();
res->buf = result->buf_->data();
res->_vec = result->buf_;
res->rows_read = result->rows_;
res->bytes_read = result->bytes_;
res->elapsed = result->elapsed_;
res->error_message = nullptr;
} else {
res->error_message = new char[result->error_msg_.size() + 1];
memcpy(res->error_message, result->error_msg_.c_str(), result->error_msg_.size() + 1);
res->_vec = nullptr;
res->buf = nullptr;
}
return res;
}
Expand All @@ -1145,6 +1150,7 @@ void free_result_v2(local_result_v2 * result)
delete[] result->error_message;
result->error_message = nullptr;
}
delete result;
}

/**
Expand Down
Loading

0 comments on commit dc29e0a

Please sign in to comment.