Re: Inline non-SQL SRFs using SupportRequestSimplify

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: Paul Jungwirth <pj(at)illuminatedcomputing(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Inline non-SQL SRFs using SupportRequestSimplify
Date: 2024-07-02 12:59:45
Message-ID: ffd7937d-190c-4f09-9418-5345728b45c4@iki.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 28/06/2024 01:01, Paul Jungwirth wrote:
> If it seems good to let people use SupportRequestSimplify to make their SRFs be inlineable, I'm
> happy to add tests and docs. We should really document the idea of inlined functions in general, so
> I'll do that too.
>
> Another approach I considered is using a separate support request, e.g. SupportRequestInlineSRF, and
> just calling it from inline_set_returning_function. I didn't like having two support requests that
> did almost exactly the same thing. OTOH my current approach means you'll get an error if you do this:
>
> ```
> postgres=# select temporal_semijoin('employees', 'id', 'valid_at', 'positions', 'employee_id',
> 'valid_at');
> ERROR: unrecognized node type: 66
> ```
>
> I'll look into ways to fix that.

If the support function returns a Query, we end up having a FuncExpr
with a Query in the tree. A Query isnt an Expr, which is why you get
that error, and it seems like a recipe for confusion in general. Perhaps
returning a SubLink would be better.

I think we should actually add an assertion after the call to the
SupportRequestSimplify support function, to check that it returned an
Expr node.

+1 to the general feature of letting SRFs be simplified by the support
function.

> I think SupportRequestSimplify is a really cool feature. It is nearly like having macros.
> I'm dreaming about other ways I can (ab)use it.

:-D

--
Heikki Linnakangas
Neon (https://neon.tech)

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Melih Mutlu 2024-07-02 13:08:22 Re: Parent/child context relation in pg_get_backend_memory_contexts()
Previous Message Dagfinn Ilmari Mannsåker 2024-07-02 12:55:25 Re: Cleaning up perl code