Re: [PATCH] Allow queries in WHEN expression of FOR EACH STATEMENT triggers

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Joe Wildish <joe(at)lateraljoin(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Surafel Temesgen <surafel3000(at)gmail(dot)com>
Subject: Re: [PATCH] Allow queries in WHEN expression of FOR EACH STATEMENT triggers
Date: 2021-09-23 20:02:38
Message-ID: CA+TgmobuM2EMDmuL4Sv88OVFw8pKKuHPbHcXWhr4myPkMxYGSQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Sep 23, 2021 at 5:34 AM Joe Wildish <joe(at)lateraljoin(dot)com> wrote:
> Regarding the deparse-and-reparse --- if I understand correctly, the core problem is that we have no way of going from a node tree to a string, such that the string is guaranteed to have the same meaning as the node tree? (I did try just now to produce such a scenario with the patch but I couldn't get ruleutils to emit the wrong thing). Moreover, we couldn't store the string for use with SPI, as the string would be subject to trigger-time search path lookups. That pretty much rules out SPI for this then. Do you have a suggestion for an alternative? I guess it would be go to the planner/executor directly with the node tree?

I think hoping that you can ever make deparse and reparse reliably
produce the same result is a hopeless endeavor. Tom mentioned hazards
related to ambiguous constructs, but there's also often the risk of
concurrent DDL. Commit 5f173040e324f6c2eebb90d86cf1b0cdb5890f0a is a
cautionary tale, demonstrating that you can't even count on
schema_name.table_name to resolve to the same OID for the entire
duration of a single DDL command. The same hazard exists for
functions, operators, and anything else that gets looked up in a
system catalog.

I don't know what all of that means for your patch, but just wanted to
get my $0.02 in on the general topic.

--
Robert Haas
EDB: http://www.enterprisedb.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2021-09-23 20:31:09 Re: Gather performance analysis
Previous Message Tomas Vondra 2021-09-23 20:00:02 Re: Gather performance analysis