aws / aws/pg_tle

Debugging failed extension creation

Open
#247 0 comments 0 reactions 0 assignees View on GitHub
general
Dominant language
C
Stars
410
Forks
41
Avg merge
18h 17m
Merged PRs (30d)
2

Description

## 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)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.