Re: psql: add \create_function command

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Steve Chavez <steve(at)supabase(dot)io>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, walther(at)technowledgy(dot)de, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: psql: add \create_function command
Date: 2024-01-29 17:05:42
Message-ID: CAFj8pRBZaAT0c=jyKNZpMdjBTJ7iL+U6p0_-gqw6dQR2zvwcaA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

po 29. 1. 2024 v 17:54 odesílatel Steve Chavez <steve(at)supabase(dot)io> napsal:

> > I like your ideas upthread about \file_read and :{filename}
>
> Great ideas! :{filename} looks more convenient to use than \file_read just
> because it's one less command to execute.
>
> However, :{?variable_name} is already taken by psql to test whether a
> variable is defined or not. It might be confusing to use the same syntax.
>
> How about using the convention of interpreting an identifier as a file
> path if it has an slash on it?
>
> This is used in the Nix language and from experience it works very well:
> https://nix.dev/manual/nix/2.18/language/values#type-path
> It also makes it very clear that you're using a file path, e.g.
> :{filename} vs :./filename. Examples:
>
> select jsonb_to_recordset(:./contents.json);
> create function foo() returns text AS :/absolute/path/contents.py language
> plpython3u;
>
> Any thoughts?
>

has sense

Pavel

>
> Best regards,
> Steve Chavez
>
> On Mon, 29 Jan 2024 at 08:42, Andrew Dunstan <andrew(at)dunslane(dot)net> wrote:
>
>>
>> On 2024-01-26 Fr 15:17, Tom Lane wrote:
>> > Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> writes:
>> >> I don't know, maybe I have a problem with the described use case. I
>> cannot
>> >> imagine holding the body and head of PL routines in different places
>> and I
>> >> don't understand the necessity to join it.
>> > It seems a little weird to me too, and I would vote against accepting
>> > \create_function as described because I think too few people would
>> > want to use it. However, the idea of an easy way to pull in a file
>> > and convert it to a SQL literal seems like it has many applications.
>> >
>> >
>>
>>
>> Yes, this proposal is far too narrow and would not cater for many use
>> cases I have had in the past.
>>
>> I like your ideas upthread about \file_read and :{filename}
>>
>>
>> cheers
>>
>>
>> andrew
>>
>> --
>> Andrew Dunstan
>> EDB: https://www.enterprisedb.com
>>
>>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2024-01-29 17:07:35 Re: Should we remove -Wdeclaration-after-statement?
Previous Message Alvaro Herrera 2024-01-29 16:55:27 pgsql: Add EXPLAIN (MEMORY) to report planner memory consumption