Skip to content

Debugging failed extension creation #247

@ajrajkumar

Description

@ajrajkumar

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    generalGeneral question or request for help

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions