How to inspect tuples during execution of a plan? - Mailing list pgsql-hackers

From Ernst-Georg Schmid
Subject How to inspect tuples during execution of a plan?
Date
Msg-id CAPnb6dkrUZS_Sha0Rv9gVO5usgZR1EDn0MH9YPLx35xQ=6J6RQ@mail.gmail.com
Whole thread Raw
Responses Re: How to inspect tuples during execution of a plan?  (Ashutosh Bapat <ashutosh.bapat@enterprisedb.com>)
List pgsql-hackers
Hello all,

I'd like to inspect the content of tuples as they are sent during the
execution of a query in order to react to their values.

I guess I could do it with a FDW, but that's a bit clumsy so I took a
look at the hooks but have two questions:

1.) Would ExecutorRun_hook be the correct place to implement such an
'tuple inspector'?
2.) If yes, how? As far as I understand the source code, I would have
to provide my own implementation based on standard_ExecutorRun and
replace the ExecutePlan function with my own one that takes a look at
each 'slot' like so

if (estate->es_junkFilter != NULL)1589             slot = ExecFilterJunk(estate->es_junkFilter, slot);1590

Tuple inspection here
1591         /*1592          * If we are supposed to send the tuple somewhere, do so. (In1593          * practice, this
isprobably always the case at this point.)1594          */1595         if (sendTuples)1596         {
 

If there is a better way, please advise. I'm really a newbie to this.

Best regards,

Ernst-Georg Schmid



pgsql-hackers by date:

Previous
From: Josh Berkus
Date:
Subject: Remove vacuum_defer_cleanup_age
Next
From: Tatsuo Ishii
Date:
Subject: another typo in parallel.sgml