Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(c/driver/postgresql): Check if statement was released in stream reader #823

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions c/driver/postgresql/statement.cc
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,11 @@ struct BindStream {
} // namespace

int TupleReader::GetSchema(struct ArrowSchema* out) {
if (!copy_reader_) {
StringBuilderAppend(&error_builder_,
"[libpq] Statement was already freed");
return EINVAL;
}
int na_res = copy_reader_->GetSchema(out);
if (out->release == nullptr) {
StringBuilderAppend(&error_builder_,
Expand All @@ -375,6 +380,12 @@ int TupleReader::GetSchema(struct ArrowSchema* out) {
}

int TupleReader::GetNext(struct ArrowArray* out) {
if (!copy_reader_) {
StringBuilderAppend(&error_builder_,
"[libpq] Statement was already freed");
return EINVAL;
}

if (!result_) {
out->release = nullptr;
return 0;
Expand Down Expand Up @@ -473,6 +484,7 @@ void TupleReader::Release() {
PQfreemem(pgbuf_);
pgbuf_ = nullptr;
}
copy_reader_ = nullptr;
}

void TupleReader::ExportTo(struct ArrowArrayStream* stream) {
Expand Down