[Schmitzm-commits] r1932 - trunk/schmitzm-db/src/main/java/de/schmitzm/postgres
scm-commit at wald.intevation.org
scm-commit at wald.intevation.org
Mon Apr 2 12:13:48 CEST 2012
Author: alfonx
Date: 2012-04-02 12:13:48 +0200 (Mon, 02 Apr 2012)
New Revision: 1932
Modified:
trunk/schmitzm-db/src/main/java/de/schmitzm/postgres/PGUtil.java
Log:
Modified: trunk/schmitzm-db/src/main/java/de/schmitzm/postgres/PGUtil.java
===================================================================
--- trunk/schmitzm-db/src/main/java/de/schmitzm/postgres/PGUtil.java 2012-04-02 09:24:58 UTC (rev 1931)
+++ trunk/schmitzm-db/src/main/java/de/schmitzm/postgres/PGUtil.java 2012-04-02 10:13:48 UTC (rev 1932)
@@ -866,11 +866,11 @@
* @return blockingPid oder <code>null</code>
*/
static public Long getBlockingPid(Connection c, Long blockedPid) throws SQLException {
- final String sql = "select kl.pid as blocking_pid from pg_catalog.pg_locks bl "
- + "join pg_catalog.pg_stat_activity a on bl.pid = a.procpid "
- + "join pg_catalog.pg_locks kl "
- + "join pg_catalog.pg_stat_activity ka on kl.pid = ka.procpid on bl.transactionid = kl.transactionid and bl.pid != kl.pid "
- + "where not bl.granted and bl.pid = " + blockedPid;
+ final String sql = "SELECT kl.pid as blocking_pid FROM pg_catalog.pg_locks bl "
+ + "JOIN pg_catalog.pg_stat_activity a on bl.pid = a.procpid "
+ + "JOIN pg_catalog.pg_locks kl "
+ + "JOIN pg_catalog.pg_stat_activity ka on kl.pid = ka.procpid on bl.transactionid = kl.transactionid and bl.pid != kl.pid "
+ + "WHERE not bl.granted AND bl.pid = " + blockedPid;
ResultSet rs = c.createStatement().executeQuery(sql);
try {
if (rs.next()) {
@@ -899,7 +899,7 @@
throws SQLException {
ArrayList<SqlQueryStat> result = new ArrayList<SqlQueryStat>();
- String where = "where 1";
+ String where = "WHERE TRUE ";
if (filter == 1)
where += "AND current_query != 'IDLE' ";
@@ -907,17 +907,17 @@
where += "AND current_query not like '<IDLE>%' ";
if (datName != null)
- where += " and datname like '" + datName + "'";
+ where += " AND datname like '" + datName + "'";
if (minSecondsRunning != null) {
if (minSecondsRunning < 0)
throw new IllegalStateException();
- where += " and age (now(),query_start) >= interval '" + minSecondsRunning + "s' ";
+ where += " AND age (now(),query_start) >= interval '" + minSecondsRunning + "s' ";
}
- final String sql = "select current_query, age (now(),query_start) as qage, waiting, procpid, client_addr, usename, application_name from pg_stat_activity "
- + where + " order by qage desc";
+ final String sql = "SELECT current_query, age (now(),query_start) as qage, waiting, procpid, client_addr, usename, application_name from pg_stat_activity "
+ + where + " ORDER BY qage desc";
ResultSet rs = c.createStatement().executeQuery(sql);
try {
More information about the Schmitzm-commits
mailing list