How to tell which statement is being executed

From: Garfield Lewis <garfield(dot)lewis(at)lzlabs(dot)com>
To: pgsql-generallists(dot)postgresql(dot)org <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: How to tell which statement is being executed
Date: 2023-11-03 14:58:18
Message-ID: AM8PR05MB825745F8A78FDB189A3F4AC7E3A5A@AM8PR05MB8257.eurprd05.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi All,

If I create a C function, is there a way from within that function for me to:

1. know whether it is being triggered by an INSERT or UPDATE statement
* I’ve done some digging and it seems you can get this information if you provide a Planner hook, however, I need to know this much later in my function not in the Planner
* Is there some way for me to get to the PlannedStmt (or anything else that may have the command type) from within my function?
2. column attribute (specifically the TYPMOD) for the affected column

BTW, is there a more appropriate Postgres list/group/blog that is specifically dedicated to these types of programming questions or is it ok to post this here?

Regards,
Garfield

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2023-11-03 16:08:29 Re: How to tell which statement is being executed
Previous Message Philip Semanchuk 2023-11-03 14:06:59 Re: Local postgres manual