Postgresql post_parse_analyze_hook not getting triggered for COMMIT command - Mailing list pgsql-general

From Soumya Prasad Ukil
Subject Postgresql post_parse_analyze_hook not getting triggered for COMMIT command
Date
Msg-id 569458024.606881.1620223463206@mail.yahoo.com
Whole thread Raw
List pgsql-general
Hello All,

I am trying to build a postgres extension and I have installed the following hooks using this document https://wiki.postgresql.org/images/e/e3/Hooks_in_postgresql.pdf 

The hooks that I have installed in my extension are the followings:
  • shmem_startup_hook
  • post_parse_analyze_hook
  • ExecutorStart_hook
  • ExecutorRun_hook
  • ExecutorFinish_hook
  • ExecutorEnd_hook
  • ProcessUtility_hook
Post that I am using a java program like below to fire sql statements in a transaction:

Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
// insert an actor into the actor table
String SQLInsertActor = "INSERT INTO actor(first_name,last_name) VALUES(?,?)";
try {
// connect to the database
conn = connect();
conn.setAutoCommit(false);
int i=0;
while (i < 5) {
// add actor
pstmt = conn.prepareStatement(SQLInsertActor, Statement.RETURN_GENERATED_KEYS);
pstmt.setString(1, actor.getFirstName());
pstmt.setString(2, actor.getLastName());
pstmt.executeUpdate();
// commit the transaction if everything is fine
conn.commit();
i++;
}
}
Now what is happening I am receiving all the hook call backs for INSERT statement always. BEGIN and COMMIT being utility statement hooks come for parse, process utility hook, . However from second iteration onwards, while BEGIN throws parse callback, but COMMIT command does not throw parse callback. It directly throws process utility hook.
Can you please help why second iteration onwards, commit does not throw parse callback to extension?

pgsql-general by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: PostgreSQL upgrade from 10 to 12 fails with "ERROR: column r.relhasoids does not exist at character 1616"
Next
From: Tom Lane
Date:
Subject: Re: Strange behavior of function date_trunc