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

Error handling #6

Merged
merged 3 commits into from Apr 17, 2023
Merged

Error handling #6

merged 3 commits into from Apr 17, 2023

Conversation

olirice
Copy link
Collaborator

@olirice olirice commented Apr 17, 2023

What kind of change does this PR introduce?

Return errors as text[] rather than raising exception to enable the index_advisor function to be applied against multiple queries in a single statement without a single failure causing the whole query to crash

resolves #2

@olirice olirice requested a review from burggraf April 17, 2023 17:18
Comment on lines 1 to +17
begin;
create extension index_advisor version '0.1.1' cascade;
create extension index_advisor version '0.2.0' cascade;
NOTICE: installing required extension "hypopg"
select index_advisor($$ select 1; $$);
ERROR: query must not contain a semicolon
CONTEXT: PL/pgSQL function index_advisor(text) line 15 at RAISE
-- This is okay because semicolon gets stripped from the end of the statement
select * from index_advisor($$ select 1; $$);
startup_cost_before | startup_cost_after | total_cost_before | total_cost_after | index_statements | errors
---------------------+--------------------+-------------------+------------------+------------------+--------
0.00 | 0.00 | 0.01 | 0.01 | {} | {}
(1 row)

-- This is not okay because it contains multiple statements
select * from index_advisor($$ select 1; select 1 $$);
startup_cost_before | startup_cost_after | total_cost_before | total_cost_after | index_statements | errors
---------------------+--------------------+-------------------+------------------+------------------+----------------------------------------
| | | | {} | {"Query must not contain a semicolon"}
(1 row)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can see the difference here

@olirice olirice merged commit d377235 into main Apr 17, 2023
2 checks passed
@olirice olirice deleted the or/issue_2 branch April 17, 2023 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error handling for invalid queries is not implemented
2 participants