Re: Help Needed with Including External SQL Script in Extension Script

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Ayush Vatsa <ayushvatsa1810(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Help Needed with Including External SQL Script in Extension Script
Date: 2024-07-27 06:39:23
Message-ID: CAKFQuwZTs3ntzetDoGiRSLqTwS_1xDeqZB4TY7VrhQLJ22EuQg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Friday, July 26, 2024, Ayush Vatsa <ayushvatsa1810(at)gmail(dot)com> wrote:
>
> I wanted to modify the SQL script of an extension by creating multiple
> objects within it.
> My aim is to make minimal changes to the existing script. To achieve this,
> I have created an
> external script and am attempting to run it within the extension script
> using the \i command.
>
> However, when I try to create the extension, I encounter the following
> error:
> ERROR: syntax error at or near "\"
>
> Could anyone advise on how I might resolve this issue? Alternatively, is
> there another way to create SQL objects outside of the main extension
> script, such that these objects are created when the extension script is
> executed?
>

Extension scripts are executed directly by the server as SQL, not via psql,
so using psql features will not work. In short, your extension script for
a given version must be singular as the concept of “include files” is not
understood by the execution environment.

David J.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Kirill Reshke 2024-07-27 08:26:46 Re: Incremental View Maintenance, take 2
Previous Message Ayush Vatsa 2024-07-27 06:24:54 Help Needed with Including External SQL Script in Extension Script