pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Soumya Prasad Ukil <soumyo_ju@yahoo.co.in>
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Postgresql post_parse_analyze_hook not getting triggered for COMMIT command
Date: Wed, 5 May 2021 14:04:23 +0000 (UTC)
Message-ID: <569458024.606881.1620223463206@mail.yahoo.com> (raw)
References: <569458024.606881.1620223463206.ref@mail.yahoo.com>

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?

Message-ID: <569458024.606881.1620223463206@mail.yahoo.com>
Permalink:  ../569458024.606881.1620223463206@mail.yahoo.com/
Also on:    postgresql.org/message-id/569458024.606881.1620223463206@mail.yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: soumyo_ju@yahoo.co.in
  Subject: Re: Postgresql post_parse_analyze_hook not getting triggered for COMMIT command
  In-Reply-To: <569458024.606881.1620223463206@mail.yahoo.com>
  References: <569458024.606881.1620223463206.ref@mail.yahoo.com> <569458024.606881.1620223463206@mail.yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox