CURRENT_TIMESTAMP not work correctly insinde a transaction. - Mailing list pgsql-bugs

From Nicolas Paymal
Subject CURRENT_TIMESTAMP not work correctly insinde a transaction.
Date
Msg-id LJEIJOMPNLMBFJLMFLKAMELJCAAA.npaymal@instranet.com
Whole thread Raw
List pgsql-bugs
Hello
  I am using pgsql 7.1 and 7.2 and I found a bug When I use
CURRENT_TIMESTAMP in a sql query.
In a transaction until you commit your transaction through a jdbc
connection, each time you use the Current_timestamp (or 'now'), the
timestamps is always the same, and when your transaction is very long you
have undesirable effect.


I also would like to submit enhancement request, who can I contact or where
can I send e-mail ?

Thanks for you Help.

example of code :


import java.sql.*;

class test  {

   static private String driver = "org.postgresql.Driver";
   static private String url    =
"jdbc:postgresql://bela:5432/idb?compatible=7.1";

   static void main(String argv[]) {
      Connection con        = null;
      Statement  statement  = null;
      ResultSet  rset       = null;

      try {
         Class.forName(driver);
         con = DriverManager.getConnection(url, "iuser", "qa");
         statement = con.createStatement();
         con.setAutoCommit(false);
         int cpt;
         for (int i=0;i<5;i++) {
            rset = statement.executeQuery("SELECT CURRENT_TIMESTAMP AS
VAR");
            if (rset!=null && rset.next()) {
               java.sql.Timestamp ts = rset.getTimestamp("VAR");
               System.out.println(i + "  -> timestamp = "+ts);
            }
            Thread.sleep(1000);
         }

         con.commit();

         for (int i=0;i<5;i++) {
            rset = statement.executeQuery("SELECT CURRENT_TIMESTAMP AS
VAR");
            if (rset!=null && rset.next()) {
               java.sql.Timestamp ts = rset.getTimestamp("VAR");
               System.out.println((i+5) + "  -> timestamp = "+ts);
            }
            Thread.sleep(1000);
         }

         statement.close();
         con.close();
      } catch (Exception e) {
         System.out.println("# Problem: "+e);
         e.printStackTrace();
      }
   }
}

--
Nicolas Paymal
Developer R&D.
Instranet Inc.

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: Patch pgsql-7.2 AuthBlockSig
Next
From: Thomas Lockhart
Date:
Subject: Re: CURRENT_TIMESTAMP not work correctly insinde a transaction.