Accessing parameters of a prepared query inside an FDW

From: Adam Fletcher <adamfblahblah(at)gmail(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Accessing parameters of a prepared query inside an FDW
Date: 2024-02-15 02:50:42
Message-ID: CAMfJBeBsF2=Q0wdnixRJ4Rm35moJPc3Cbq=SU_wLJn9ifbV6Vw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi Folks,

Is it possible to get the parameterized prepared query inside an FDW such
that it can be prepared/bind'd/execute'd on the receiving end of the FDW?

For example, if I `PREPARE stmt(int) AS SELECT * from fdwrapped_tbl where
pk = $1;` then `execute stmt(1);` I want my FDW be aware that the query was
prepared.

Right now, if given the above, and I walk through the postgres_fdw code and
output the parse tree from root->parse->query (the PlannerInfo node), I see
no PARAM nodes - inside the OPEXPR is just the VAR & CONST (in this case,
the CONST is 1). Note that if I call ereport() I do see the correct
prepared statement (eg, with the $1) in the output (as debug_query_string
has that statement in it).

I cannot find an example of an FDW that supports passing on prepared
statements. Any help appreciated!

-Adam

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2024-02-15 03:43:48 Re: Accessing parameters of a prepared query inside an FDW
Previous Message Hannes Erven 2024-02-14 22:52:03 RowLock and multiple transactions