Skip to content

Commit

Permalink
Merge pull request #38 from hydradatabase/propagate_execution_error
Browse files Browse the repository at this point in the history
Check for error and report the error on the result of `quackScanState->preparedStatement->Execute()`
  • Loading branch information
mkaruza authored May 29, 2024
2 parents 495e3d9 + 65a1fa1 commit 530f502
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/quack_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ Quack_ExecCustomScan(CustomScanState *node) {
quackScanState->is_executed = true;
}

if (quackScanState->queryResult->HasError()) {
elog(ERROR, "Quack execute returned an error: %s", quackScanState->queryResult->GetError().c_str());
}

if (quackScanState->fetch_next) {
quackScanState->currentDataChunk = quackScanState->queryResult->Fetch();
quackScanState->currentRow = 0;
Expand Down
9 changes: 9 additions & 0 deletions test/regression/expected/execution_error.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
create table int_as_varchar(a varchar);
insert into int_as_varchar SELECT * from (
VALUES
('abc')
) t(a);
select a::INTEGER from int_as_varchar;
ERROR: Quack execute returned an error: Conversion Error: Could not convert string 'abc' to INT32
LINE 1: select a::INTEGER from int_as_varchar;
^
1 change: 1 addition & 0 deletions test/regression/schedule
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
test: basic
test: search_path
test: execution_error
test: type_support
7 changes: 7 additions & 0 deletions test/regression/sql/execution_error.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
create table int_as_varchar(a varchar);
insert into int_as_varchar SELECT * from (
VALUES
('abc')
) t(a);

select a::INTEGER from int_as_varchar;

0 comments on commit 530f502

Please sign in to comment.