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

Debugging failed extension creation #247

Open
ajrajkumar opened this issue Nov 28, 2023 · 0 comments
Open

Debugging failed extension creation #247

ajrajkumar opened this issue Nov 28, 2023 · 0 comments
Labels
general General question or request for help

Comments

@ajrajkumar
Copy link

ajrajkumar commented Nov 28, 2023

Describe the problem

Currently we use pgtle.install_extension to create the extension code which is part of the code block. The block could contain multiple statements to create multiple objects. If the extension creation failed due to any syntax error, it would be difficult to debug since the error does not have any reference or line number

  • What are you trying to solve?
    To make it easy to debug the failed extension creation.

Here the sample code to reproduce it

pg_tle | 1.1.1 | pgtle | Trusted Language Extensions for PostgreSQL

SELECT pgtle.install_extension( 'get_count', '1.0.0', 'Sample count function',
$pgtle$
Create or replace function get_count(len_from int, len_to int)
returns int
language plpgsql
as
$$
declare
film_count integer;
begin
film_count = len_from + len_to;
return film_count;
end;
$$

grant execute on function get_count(int, int) to public;

$pgtle$
);

postgres=> \i get_count.sql
install_extension

t
(1 row)

postgres=> create extension get_count;
ERROR: syntax error at or near "grant"

I intentionally did not add ; after the $$ of the function and it failed to create the extension. But the error message is not easy to debug as some extension may have may grant statements ( or similar)

@ajrajkumar ajrajkumar added the general General question or request for help label Nov 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
general General question or request for help
Projects
None yet
Development

No branches or pull requests

1 participant